| 1 | /* tokens.h --- Types for DIGEST-MD5 tokens. |
| 2 | * Copyright (C) 2004-2012 Simon Josefsson |
| 3 | * |
| 4 | * This file is part of GNU SASL Library. |
| 5 | * |
| 6 | * GNU SASL Library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public License |
| 8 | * as published by the Free Software Foundation; either version 2.1 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * GNU SASL Library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with GNU SASL Library; if not, write to the Free |
| 18 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifndef DIGEST_MD5_TOKENS_H |
| 24 | #define DIGEST_MD5_TOKENS_H |
| 25 | |
| 26 | /* Get size_t. */ |
| 27 | #include <stddef.h> |
| 28 | |
| 29 | /* Length of MD5 output. */ |
| 30 | #define DIGEST_MD5_LENGTH 16 |
| 31 | |
| 32 | /* Quality of Protection types. */ |
| 33 | enum digest_md5_qop |
| 34 | { |
| 35 | DIGEST_MD5_QOP_AUTH = 1, |
| 36 | DIGEST_MD5_QOP_AUTH_INT = 2, |
| 37 | DIGEST_MD5_QOP_AUTH_CONF = 4 |
| 38 | }; |
| 39 | typedef enum digest_md5_qop digest_md5_qop; |
| 40 | |
| 41 | /* Cipher types. */ |
| 42 | enum digest_md5_cipher |
| 43 | { |
| 44 | DIGEST_MD5_CIPHER_DES = 1, |
| 45 | DIGEST_MD5_CIPHER_3DES = 2, |
| 46 | DIGEST_MD5_CIPHER_RC4 = 4, |
| 47 | DIGEST_MD5_CIPHER_RC4_40 = 8, |
| 48 | DIGEST_MD5_CIPHER_RC4_56 = 16, |
| 49 | DIGEST_MD5_CIPHER_AES_CBC = 32 |
| 50 | }; |
| 51 | typedef enum digest_md5_cipher digest_md5_cipher; |
| 52 | |
| 53 | /* |
| 54 | * digest-challenge = |
| 55 | * 1#( realm | nonce | qop-options | stale | server_maxbuf | charset |
| 56 | * algorithm | cipher-opts | auth-param ) |
| 57 | * |
| 58 | * realm = "realm" "=" <"> realm-value <"> |
| 59 | * realm-value = qdstr-val |
| 60 | * nonce = "nonce" "=" <"> nonce-value <"> |
| 61 | * nonce-value = *qdtext |
| 62 | * qop-options = "qop" "=" <"> qop-list <"> |
| 63 | * qop-list = 1#qop-value |
| 64 | * qop-value = "auth" | "auth-int" | "auth-conf" | qop-token |
| 65 | * ;; qop-token is reserved for identifying future |
| 66 | * ;; extensions to DIGEST-MD5 |
| 67 | * qop-token = token |
| 68 | * stale = "stale" "=" "true" |
| 69 | * server_maxbuf = "maxbuf" "=" maxbuf-value |
| 70 | * maxbuf-value = 1*DIGIT |
| 71 | * charset = "charset" "=" "utf-8" |
| 72 | * algorithm = "algorithm" "=" "md5-sess" |
| 73 | * cipher-opts = "cipher" "=" <"> 1#cipher-value <"> |
| 74 | * cipher-value = "3des" | "des" | "rc4-40" | "rc4" | |
| 75 | * "rc4-56" | "aes-cbc" | cipher-token |
| 76 | * ;; "des" and "3des" ciphers are obsolete. |
| 77 | * ;; cipher-token is reserved for new ciphersuites |
| 78 | * cipher-token = token |
| 79 | * auth-param = token "=" ( token | quoted-string ) |
| 80 | * |
| 81 | */ |
| 82 | struct digest_md5_challenge |
| 83 | { |
| 84 | size_t nrealms; |
| 85 | char **realms; |
| 86 | char *nonce; |
| 87 | int qops; |
| 88 | int stale; |
| 89 | unsigned long servermaxbuf; |
| 90 | int utf8; |
| 91 | int ciphers; |
| 92 | }; |
| 93 | typedef struct digest_md5_challenge digest_md5_challenge; |
| 94 | |
| 95 | #define DIGEST_MD5_RESPONSE_LENGTH 32 |
| 96 | |
| 97 | /* |
| 98 | * digest-response = 1#( username | realm | nonce | cnonce | |
| 99 | * nonce-count | qop | digest-uri | response | |
| 100 | * client_maxbuf | charset | cipher | authzid | |
| 101 | * auth-param ) |
| 102 | * |
| 103 | * username = "username" "=" <"> username-value <"> |
| 104 | * username-value = qdstr-val |
| 105 | * cnonce = "cnonce" "=" <"> cnonce-value <"> |
| 106 | * cnonce-value = *qdtext |
| 107 | * nonce-count = "nc" "=" nc-value |
| 108 | * nc-value = 8LHEX |
| 109 | * client_maxbuf = "maxbuf" "=" maxbuf-value |
| 110 | * qop = "qop" "=" qop-value |
| 111 | * digest-uri = "digest-uri" "=" <"> digest-uri-value <"> |
| 112 | * digest-uri-value = serv-type "/" host [ "/" serv-name ] |
| 113 | * serv-type = 1*ALPHA |
| 114 | * serv-name = host |
| 115 | * response = "response" "=" response-value |
| 116 | * response-value = 32LHEX |
| 117 | * LHEX = "0" | "1" | "2" | "3" | |
| 118 | * "4" | "5" | "6" | "7" | |
| 119 | * "8" | "9" | "a" | "b" | |
| 120 | * "c" | "d" | "e" | "f" |
| 121 | * cipher = "cipher" "=" cipher-value |
| 122 | * authzid = "authzid" "=" <"> authzid-value <"> |
| 123 | * authzid-value = qdstr-val |
| 124 | * |
| 125 | */ |
| 126 | struct digest_md5_response |
| 127 | { |
| 128 | char *username; |
| 129 | char *realm; |
| 130 | char *nonce; |
| 131 | char *cnonce; |
| 132 | unsigned long nc; |
| 133 | digest_md5_qop qop; |
| 134 | char *digesturi; |
| 135 | unsigned long clientmaxbuf; |
| 136 | int utf8; |
| 137 | digest_md5_cipher cipher; |
| 138 | char *authzid; |
| 139 | char response[DIGEST_MD5_RESPONSE_LENGTH + 1]; |
| 140 | }; |
| 141 | typedef struct digest_md5_response digest_md5_response; |
| 142 | |
| 143 | /* |
| 144 | * response-auth = "rspauth" "=" response-value |
| 145 | */ |
| 146 | struct digest_md5_finish |
| 147 | { |
| 148 | char rspauth[DIGEST_MD5_RESPONSE_LENGTH + 1]; |
| 149 | }; |
| 150 | typedef struct digest_md5_finish digest_md5_finish; |
| 151 | |
| 152 | #endif /* DIGEST_MD5_TOKENS_H */ |
| 153 | |