6 * Implementation of the EAP-PSK packet management
9 * Copyright (C) France Télécom R&D (DR&D/MAPS/NSS)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 * Copyright 2006 The FreeRADIUS server project
34 #include <freeradius-devel/ident.h>
35 RCSIDH(eap_psk_h, "$Id$")
39 #if defined(__cplusplus)
45 #define EAPPSK_TYPE 255
47 // EXT_Payload maximum length in bytes
48 #define EXT_PAYLOAD_MAX_LEN 977
50 #define PSK_PCHANNEL_REPLAY_COUNTER_SIZE sizeof(unsigned long int) // size in octets
51 #define PSK_KEY_SIZE (PSK_AK_SIZE+PSK_KDK_SIZE) // size in octets
52 #define PSK_AK_SIZE 16 // size in octets
53 #define PSK_KDK_SIZE 16 // size in octets
54 #define PSK_TEK_SIZE 16 // size in octets
55 #define PSK_MSK_SIZE 64 // size in octets
56 #define PSK_EMSK_SIZE 64 // size in octets
57 #define PSK_RANDOM_NUMBER_SIZE 16 // size in octets
58 #define PSK_MAC_SIZE 16 // size in octets
59 #define EAP_HEADER_SIZE 5 // size in octets
64 // EAP-PSK attribute flags
65 #define PSK_STATUS_CONT 0x40
66 #define PSK_STATUS_DONE_FAILURE 0xC0
67 #define PSK_STATUS_DONE_SUCCESS 0x80
69 #define PSK_IS_EXT 0x20
72 // the EAP-PSK configuration parameters
73 typedef struct eap_psk_conf {
74 unsigned char *privateKey; // the server private key
75 unsigned char *id_s; // the server name
76 unsigned int ldapSupport; // if an LDAP directory is used
77 unsigned char *peerNaiAttribute; // the LDAP attribute name which corresponds to the peer NAI
78 unsigned char *peerKeyAttribute; // the LDAP attribute name which corresponds to the peer Key = AK || KDK
79 unsigned char *usersFilePath; // the EAP-PSK users file path
80 unsigned int nbRetry; // the number of bad authorized responses while the EAP-PSK authentication
81 unsigned int maxDelay; // the maximum interval in seconds between two correct responses
85 // data format of the first EAP-PSK message
86 typedef struct psk_message_1 {
87 unsigned char rand_s[PSK_RANDOM_NUMBER_SIZE];
90 // data format of the second EAP-PSK message
91 typedef struct psk_message_2 {
92 unsigned char rand_p[PSK_RANDOM_NUMBER_SIZE];
93 unsigned char mac_p[16];
97 // data format of the third EAP-PSK message
98 typedef struct psk_message_3 {
99 unsigned char mac_s[16];
100 unsigned long int nonce;
101 unsigned char tag[16];
103 unsigned char ext_type;
104 unsigned char *extPayload;
107 // data format of the fourth EAP-PSK message
108 typedef struct psk_message_4 {
109 unsigned long int nonce;
110 unsigned char tag[16];
112 unsigned char ext_type;
113 unsigned char *ext_payload;
118 *@memo this function converts a string into hexa
119 *@param inbytes, pointer to a string
120 *@param outstr, pointer to the hexa conversion
121 *@param numbytes, number of bytes to convert
122 *@return 0 if an error has occured
124 int pskConvertHex(char *inbytes, char *outstr, int numbytes);
128 *@memo this function converts a string which contains hexa characters into hexa
129 *@param inbytes, the string to convert
130 *@param outstr, the conversion in hexa
131 *@param numbytes, the number of bytes to convert
132 *@return 0 if an error has occured
134 int pskHex2Bin(const char *hex, unsigned char *bin, int numbytes);
138 *@memo this function delivers random bytes
139 *@param buf, pointer to the buffer to fill
140 *@param nbytes, number of bytes to generate
141 *@return 0 if an error has occured
143 int pskGetRandomBytes(void *buf, int nbytes);
146 #if defined(__cplusplus)
150 #endif /*_EAP_PSK_H*/