00001 /* tokens.h --- Types for DIGEST-MD5 tokens. 00002 * Copyright (C) 2004 Simon Josefsson 00003 * 00004 * This file is part of GNU SASL Library. 00005 * 00006 * GNU SASL Library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation; either version 2.1 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * GNU SASL Library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with GNU SASL Library; if not, write to the Free 00018 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #ifndef DIGEST_MD5_TOKENS_H 00024 # define DIGEST_MD5_TOKENS_H 00025 00026 /* Get size_t. */ 00027 #include <stddef.h> 00028 00029 /* Length of MD5 output. */ 00030 #define DIGEST_MD5_LENGTH 16 00031 00032 /* Quality of Protection types. */ 00033 enum digest_md5_qop 00034 { 00035 DIGEST_MD5_QOP_AUTH = 1, 00036 DIGEST_MD5_QOP_AUTH_INT = 2, 00037 DIGEST_MD5_QOP_AUTH_CONF = 4 00038 }; 00039 typedef enum digest_md5_qop digest_md5_qop; 00040 00041 /* Cipher types. */ 00042 enum digest_md5_cipher 00043 { 00044 DIGEST_MD5_CIPHER_DES = 1, 00045 DIGEST_MD5_CIPHER_3DES = 2, 00046 DIGEST_MD5_CIPHER_RC4 = 4, 00047 DIGEST_MD5_CIPHER_RC4_40 = 8, 00048 DIGEST_MD5_CIPHER_RC4_56 = 16, 00049 DIGEST_MD5_CIPHER_AES_CBC = 32 00050 }; 00051 typedef enum digest_md5_cipher digest_md5_cipher; 00052 00053 /* 00054 * digest-challenge = 00055 * 1#( realm | nonce | qop-options | stale | server_maxbuf | charset 00056 * algorithm | cipher-opts | auth-param ) 00057 * 00058 * realm = "realm" "=" <"> realm-value <"> 00059 * realm-value = qdstr-val 00060 * nonce = "nonce" "=" <"> nonce-value <"> 00061 * nonce-value = *qdtext 00062 * qop-options = "qop" "=" <"> qop-list <"> 00063 * qop-list = 1#qop-value 00064 * qop-value = "auth" | "auth-int" | "auth-conf" | qop-token 00065 * ;; qop-token is reserved for identifying future 00066 * ;; extensions to DIGEST-MD5 00067 * qop-token = token 00068 * stale = "stale" "=" "true" 00069 * server_maxbuf = "maxbuf" "=" maxbuf-value 00070 * maxbuf-value = 1*DIGIT 00071 * charset = "charset" "=" "utf-8" 00072 * algorithm = "algorithm" "=" "md5-sess" 00073 * cipher-opts = "cipher" "=" <"> 1#cipher-value <"> 00074 * cipher-value = "3des" | "des" | "rc4-40" | "rc4" | 00075 * "rc4-56" | "aes-cbc" | cipher-token 00076 * ;; "des" and "3des" ciphers are obsolete. 00077 * ;; cipher-token is reserved for new ciphersuites 00078 * cipher-token = token 00079 * auth-param = token "=" ( token | quoted-string ) 00080 * 00081 */ 00082 struct digest_md5_challenge 00083 { 00084 size_t nrealms; 00085 char **realms; 00086 char *nonce; 00087 int qops; 00088 int stale; 00089 unsigned long servermaxbuf; 00090 int utf8; 00091 int ciphers; 00092 }; 00093 typedef struct digest_md5_challenge digest_md5_challenge; 00094 00095 #define DIGEST_MD5_RESPONSE_LENGTH 32 00096 00097 /* 00098 * digest-response = 1#( username | realm | nonce | cnonce | 00099 * nonce-count | qop | digest-uri | response | 00100 * client_maxbuf | charset | cipher | authzid | 00101 * auth-param ) 00102 * 00103 * username = "username" "=" <"> username-value <"> 00104 * username-value = qdstr-val 00105 * cnonce = "cnonce" "=" <"> cnonce-value <"> 00106 * cnonce-value = *qdtext 00107 * nonce-count = "nc" "=" nc-value 00108 * nc-value = 8LHEX 00109 * client_maxbuf = "maxbuf" "=" maxbuf-value 00110 * qop = "qop" "=" qop-value 00111 * digest-uri = "digest-uri" "=" <"> digest-uri-value <"> 00112 * digest-uri-value = serv-type "/" host [ "/" serv-name ] 00113 * serv-type = 1*ALPHA 00114 * serv-name = host 00115 * response = "response" "=" response-value 00116 * response-value = 32LHEX 00117 * LHEX = "0" | "1" | "2" | "3" | 00118 * "4" | "5" | "6" | "7" | 00119 * "8" | "9" | "a" | "b" | 00120 * "c" | "d" | "e" | "f" 00121 * cipher = "cipher" "=" cipher-value 00122 * authzid = "authzid" "=" <"> authzid-value <"> 00123 * authzid-value = qdstr-val 00124 * 00125 */ 00126 struct digest_md5_response 00127 { 00128 char *username; 00129 char *realm; 00130 char *nonce; 00131 char *cnonce; 00132 unsigned long nc; 00133 digest_md5_qop qop; 00134 char *digesturi; 00135 unsigned long clientmaxbuf; 00136 int utf8; 00137 digest_md5_cipher cipher; 00138 char *authzid; 00139 char response[DIGEST_MD5_RESPONSE_LENGTH + 1]; 00140 }; 00141 typedef struct digest_md5_response digest_md5_response; 00142 00143 /* 00144 * response-auth = "rspauth" "=" response-value 00145 */ 00146 struct digest_md5_finish 00147 { 00148 char rspauth[DIGEST_MD5_RESPONSE_LENGTH + 1]; 00149 }; 00150 typedef struct digest_md5_finish digest_md5_finish; 00151 00152 #endif /* DIGEST_MD5_TOKENS_H */