File: tokens.h

package info (click to toggle)
gsasl 2.2.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,600 kB
  • sloc: ansic: 16,551; sh: 1,739; makefile: 676; xml: 301; php: 172; perl: 4
file content (151 lines) | stat: -rw-r--r-- 4,815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* tokens.h --- Types for DIGEST-MD5 tokens.
 * Copyright (C) 2004-2025 Simon Josefsson
 *
 * This file is part of GNU SASL Library.
 *
 * GNU SASL Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * GNU SASL Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GNU SASL Library; if not, see
 * <https://www.gnu.org/licenses/>.
 *
 */

#ifndef DIGEST_MD5_TOKENS_H
# define DIGEST_MD5_TOKENS_H

/* Get size_t. */
# include <stddef.h>

/* Length of MD5 output. */
# define DIGEST_MD5_LENGTH 16

/* Quality of Protection types. */
enum digest_md5_qop
{
  DIGEST_MD5_QOP_AUTH = 1,
  DIGEST_MD5_QOP_AUTH_INT = 2,
  DIGEST_MD5_QOP_AUTH_CONF = 4
};
typedef enum digest_md5_qop digest_md5_qop;

/* Cipher types. */
enum digest_md5_cipher
{
  DIGEST_MD5_CIPHER_DES = 1,
  DIGEST_MD5_CIPHER_3DES = 2,
  DIGEST_MD5_CIPHER_RC4 = 4,
  DIGEST_MD5_CIPHER_RC4_40 = 8,
  DIGEST_MD5_CIPHER_RC4_56 = 16,
  DIGEST_MD5_CIPHER_AES_CBC = 32
};
typedef enum digest_md5_cipher digest_md5_cipher;

/*
 * digest-challenge  =
 *       1#( realm | nonce | qop-options | stale | server_maxbuf | charset
 *             algorithm | cipher-opts | auth-param )
 *
 * realm             = "realm" "=" <"> realm-value <">
 * realm-value       = qdstr-val
 * nonce             = "nonce" "=" <"> nonce-value <">
 * nonce-value       = *qdtext
 * qop-options       = "qop" "=" <"> qop-list <">
 * qop-list          = 1#qop-value
 * qop-value         = "auth" | "auth-int" | "auth-conf" | qop-token
 *                    ;; qop-token is reserved for identifying future
 *                    ;; extensions to DIGEST-MD5
 * qop-token         = token
 * stale             = "stale" "=" "true"
 * server_maxbuf     = "maxbuf" "=" maxbuf-value
 * maxbuf-value      = 1*DIGIT
 * charset           = "charset" "=" "utf-8"
 * algorithm         = "algorithm" "=" "md5-sess"
 * cipher-opts       = "cipher" "=" <"> 1#cipher-value <">
 * cipher-value      = "3des" | "des" | "rc4-40" | "rc4" |
 *                     "rc4-56" | "aes-cbc" | cipher-token
 *                     ;; "des" and "3des" ciphers are obsolete.
 *                     ;; cipher-token is reserved for new ciphersuites
 * cipher-token      = token
 * auth-param        = token "=" ( token | quoted-string )
 *
 */
struct digest_md5_challenge
{
  size_t nrealms;
  char **realms;
  char *nonce;
  int qops;
  int stale;
  unsigned long servermaxbuf;
  int utf8;
  int ciphers;
};
typedef struct digest_md5_challenge digest_md5_challenge;

# define DIGEST_MD5_RESPONSE_LENGTH 32

/*
 * digest-response  = 1#( username | realm | nonce | cnonce |
 *                        nonce-count | qop | digest-uri | response |
 *                        client_maxbuf | charset | cipher | authzid |
 *                        auth-param )
 *
 *     username         = "username" "=" <"> username-value <">
 *     username-value   = qdstr-val
 *     cnonce           = "cnonce" "=" <"> cnonce-value <">
 *     cnonce-value     = *qdtext
 *     nonce-count      = "nc" "=" nc-value
 *     nc-value         = 8LHEX
 *     client_maxbuf    = "maxbuf" "=" maxbuf-value
 *     qop              = "qop" "=" qop-value
 *     digest-uri       = "digest-uri" "=" <"> digest-uri-value <">
 *     digest-uri-value  = serv-type "/" host [ "/" serv-name ]
 *     serv-type        = 1*ALPHA
 *     serv-name        = host
 *     response         = "response" "=" response-value
 *     response-value   = 32LHEX
 *     LHEX             = "0" | "1" | "2" | "3" |
 *                        "4" | "5" | "6" | "7" |
 *                        "8" | "9" | "a" | "b" |
 *                        "c" | "d" | "e" | "f"
 *     cipher           = "cipher" "=" cipher-value
 *     authzid          = "authzid" "=" <"> authzid-value <">
 *     authzid-value    = qdstr-val
 *
 */
struct digest_md5_response
{
  char *username;
  char *realm;
  char *nonce;
  char *cnonce;
  unsigned long nc;
  digest_md5_qop qop;
  char *digesturi;
  unsigned long clientmaxbuf;
  int utf8;
  digest_md5_cipher cipher;
  char *authzid;
  char response[DIGEST_MD5_RESPONSE_LENGTH + 1];
};
typedef struct digest_md5_response digest_md5_response;

/*
 * response-auth = "rspauth" "=" response-value
 */
struct digest_md5_finish
{
  char rspauth[DIGEST_MD5_RESPONSE_LENGTH + 1];
};
typedef struct digest_md5_finish digest_md5_finish;

#endif /* DIGEST_MD5_TOKENS_H */