Improve subject_match and domain_suffix_match documentation
[mech_eap.git] / src / eap_peer / eap_config.h
1 /*
2  * EAP peer configuration data
3  * Copyright (c) 2003-2013, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8
9 #ifndef EAP_CONFIG_H
10 #define EAP_CONFIG_H
11
12 /**
13  * struct eap_peer_config - EAP peer configuration/credentials
14  */
15 struct eap_peer_config {
16         /**
17          * identity - EAP Identity
18          *
19          * This field is used to set the real user identity or NAI (for
20          * EAP-PSK/PAX/SAKE/GPSK).
21          */
22         u8 *identity;
23
24         /**
25          * identity_len - EAP Identity length
26          */
27         size_t identity_len;
28
29         /**
30          * anonymous_identity -  Anonymous EAP Identity
31          *
32          * This field is used for unencrypted use with EAP types that support
33          * different tunnelled identity, e.g., EAP-TTLS, in order to reveal the
34          * real identity (identity field) only to the authentication server.
35          *
36          * If not set, the identity field will be used for both unencrypted and
37          * protected fields.
38          *
39          * This field can also be used with EAP-SIM/AKA/AKA' to store the
40          * pseudonym identity.
41          */
42         u8 *anonymous_identity;
43
44         /**
45          * anonymous_identity_len - Length of anonymous_identity
46          */
47         size_t anonymous_identity_len;
48
49         /**
50          * password - Password string for EAP
51          *
52          * This field can include either the plaintext password (default
53          * option) or a NtPasswordHash (16-byte MD4 hash of the unicode
54          * presentation of the password) if flags field has
55          * EAP_CONFIG_FLAGS_PASSWORD_NTHASH bit set to 1. NtPasswordHash can
56          * only be used with authentication mechanism that use this hash as the
57          * starting point for operation: MSCHAP and MSCHAPv2 (EAP-MSCHAPv2,
58          * EAP-TTLS/MSCHAPv2, EAP-TTLS/MSCHAP, LEAP).
59          *
60          * In addition, this field is used to configure a pre-shared key for
61          * EAP-PSK/PAX/SAKE/GPSK. The length of the PSK must be 16 for EAP-PSK
62          * and EAP-PAX and 32 for EAP-SAKE. EAP-GPSK can use a variable length
63          * PSK.
64          */
65         u8 *password;
66
67         /**
68          * password_len - Length of password field
69          */
70         size_t password_len;
71
72         /**
73          * ca_cert - File path to CA certificate file (PEM/DER)
74          *
75          * This file can have one or more trusted CA certificates. If ca_cert
76          * and ca_path are not included, server certificate will not be
77          * verified. This is insecure and a trusted CA certificate should
78          * always be configured when using EAP-TLS/TTLS/PEAP. Full path to the
79          * file should be used since working directory may change when
80          * wpa_supplicant is run in the background.
81          *
82          * Alternatively, a named configuration blob can be used by setting
83          * this to blob://blob_name.
84          *
85          * Alternatively, this can be used to only perform matching of the
86          * server certificate (SHA-256 hash of the DER encoded X.509
87          * certificate). In this case, the possible CA certificates in the
88          * server certificate chain are ignored and only the server certificate
89          * is verified. This is configured with the following format:
90          * hash:://server/sha256/cert_hash_in_hex
91          * For example: "hash://server/sha256/
92          * 5a1bc1296205e6fdbe3979728efe3920798885c1c4590b5f90f43222d239ca6a"
93          *
94          * On Windows, trusted CA certificates can be loaded from the system
95          * certificate store by setting this to cert_store://name, e.g.,
96          * ca_cert="cert_store://CA" or ca_cert="cert_store://ROOT".
97          * Note that when running wpa_supplicant as an application, the user
98          * certificate store (My user account) is used, whereas computer store
99          * (Computer account) is used when running wpasvc as a service.
100          */
101         u8 *ca_cert;
102
103         /**
104          * ca_path - Directory path for CA certificate files (PEM)
105          *
106          * This path may contain multiple CA certificates in OpenSSL format.
107          * Common use for this is to point to system trusted CA list which is
108          * often installed into directory like /etc/ssl/certs. If configured,
109          * these certificates are added to the list of trusted CAs. ca_cert
110          * may also be included in that case, but it is not required.
111          */
112         u8 *ca_path;
113
114         /**
115          * client_cert - File path to client certificate file (PEM/DER)
116          *
117          * This field is used with EAP method that use TLS authentication.
118          * Usually, this is only configured for EAP-TLS, even though this could
119          * in theory be used with EAP-TTLS and EAP-PEAP, too. Full path to the
120          * file should be used since working directory may change when
121          * wpa_supplicant is run in the background.
122          *
123          * Alternatively, a named configuration blob can be used by setting
124          * this to blob://blob_name.
125          */
126         u8 *client_cert;
127
128         /**
129          * private_key - File path to client private key file (PEM/DER/PFX)
130          *
131          * When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be
132          * commented out. Both the private key and certificate will be read
133          * from the PKCS#12 file in this case. Full path to the file should be
134          * used since working directory may change when wpa_supplicant is run
135          * in the background.
136          *
137          * Windows certificate store can be used by leaving client_cert out and
138          * configuring private_key in one of the following formats:
139          *
140          * cert://substring_to_match
141          *
142          * hash://certificate_thumbprint_in_hex
143          *
144          * For example: private_key="hash://63093aa9c47f56ae88334c7b65a4"
145          *
146          * Note that when running wpa_supplicant as an application, the user
147          * certificate store (My user account) is used, whereas computer store
148          * (Computer account) is used when running wpasvc as a service.
149          *
150          * Alternatively, a named configuration blob can be used by setting
151          * this to blob://blob_name.
152          */
153         u8 *private_key;
154
155         /**
156          * private_key_passwd - Password for private key file
157          *
158          * If left out, this will be asked through control interface.
159          */
160         char *private_key_passwd;
161
162         /**
163          * dh_file - File path to DH/DSA parameters file (in PEM format)
164          *
165          * This is an optional configuration file for setting parameters for an
166          * ephemeral DH key exchange. In most cases, the default RSA
167          * authentication does not use this configuration. However, it is
168          * possible setup RSA to use ephemeral DH key exchange. In addition,
169          * ciphers with DSA keys always use ephemeral DH keys. This can be used
170          * to achieve forward secrecy. If the file is in DSA parameters format,
171          * it will be automatically converted into DH params. Full path to the
172          * file should be used since working directory may change when
173          * wpa_supplicant is run in the background.
174          *
175          * Alternatively, a named configuration blob can be used by setting
176          * this to blob://blob_name.
177          */
178         u8 *dh_file;
179
180         /**
181          * subject_match - Constraint for server certificate subject
182          *
183          * This substring is matched against the subject of the authentication
184          * server certificate. If this string is set, the server sertificate is
185          * only accepted if it contains this string in the subject. The subject
186          * string is in following format:
187          *
188          * /C=US/ST=CA/L=San Francisco/CN=Test AS/emailAddress=as@n.example.com
189          *
190          * Note: Since this is a substring match, this cannot be used securily
191          * to do a suffix match against a possible domain name in the CN entry.
192          * For such a use case, domain_suffix_match should be used instead.
193          */
194         u8 *subject_match;
195
196         /**
197          * altsubject_match - Constraint for server certificate alt. subject
198          *
199          * Semicolon separated string of entries to be matched against the
200          * alternative subject name of the authentication server certificate.
201          * If this string is set, the server sertificate is only accepted if it
202          * contains one of the entries in an alternative subject name
203          * extension.
204          *
205          * altSubjectName string is in following format: TYPE:VALUE
206          *
207          * Example: EMAIL:server@example.com
208          * Example: DNS:server.example.com;DNS:server2.example.com
209          *
210          * Following types are supported: EMAIL, DNS, URI
211          */
212         u8 *altsubject_match;
213
214         /**
215          * domain_suffix_match - Constraint for server domain name
216          *
217          * If set, this FQDN is used as a suffix match requirement for the
218          * server certificate in SubjectAltName dNSName element(s). If a
219          * matching dNSName is found, this constraint is met. If no dNSName
220          * values are present, this constraint is matched against SubjetName CN
221          * using same suffix match comparison. Suffix match here means that the
222          * host/domain name is compared one label at a time starting from the
223          * top-level domain and all the labels in domain_suffix_match shall be
224          * included in the certificate. The certificate may include additional
225          * sub-level labels in addition to the required labels.
226          *
227          * For example, domain_suffix_match=example.com would match
228          * test.example.com but would not match test-example.com.
229          */
230         char *domain_suffix_match;
231
232         /**
233          * ca_cert2 - File path to CA certificate file (PEM/DER) (Phase 2)
234          *
235          * This file can have one or more trusted CA certificates. If ca_cert2
236          * and ca_path2 are not included, server certificate will not be
237          * verified. This is insecure and a trusted CA certificate should
238          * always be configured. Full path to the file should be used since
239          * working directory may change when wpa_supplicant is run in the
240          * background.
241          *
242          * This field is like ca_cert, but used for phase 2 (inside
243          * EAP-TTLS/PEAP/FAST tunnel) authentication.
244          *
245          * Alternatively, a named configuration blob can be used by setting
246          * this to blob://blob_name.
247          */
248         u8 *ca_cert2;
249
250         /**
251          * ca_path2 - Directory path for CA certificate files (PEM) (Phase 2)
252          *
253          * This path may contain multiple CA certificates in OpenSSL format.
254          * Common use for this is to point to system trusted CA list which is
255          * often installed into directory like /etc/ssl/certs. If configured,
256          * these certificates are added to the list of trusted CAs. ca_cert
257          * may also be included in that case, but it is not required.
258          *
259          * This field is like ca_path, but used for phase 2 (inside
260          * EAP-TTLS/PEAP/FAST tunnel) authentication.
261          */
262         u8 *ca_path2;
263
264         /**
265          * client_cert2 - File path to client certificate file
266          *
267          * This field is like client_cert, but used for phase 2 (inside
268          * EAP-TTLS/PEAP/FAST tunnel) authentication. Full path to the
269          * file should be used since working directory may change when
270          * wpa_supplicant is run in the background.
271          *
272          * Alternatively, a named configuration blob can be used by setting
273          * this to blob://blob_name.
274          */
275         u8 *client_cert2;
276
277         /**
278          * private_key2 - File path to client private key file
279          *
280          * This field is like private_key, but used for phase 2 (inside
281          * EAP-TTLS/PEAP/FAST tunnel) authentication. Full path to the
282          * file should be used since working directory may change when
283          * wpa_supplicant is run in the background.
284          *
285          * Alternatively, a named configuration blob can be used by setting
286          * this to blob://blob_name.
287          */
288         u8 *private_key2;
289
290         /**
291          * private_key2_passwd -  Password for private key file
292          *
293          * This field is like private_key_passwd, but used for phase 2 (inside
294          * EAP-TTLS/PEAP/FAST tunnel) authentication.
295          */
296         char *private_key2_passwd;
297
298         /**
299          * dh_file2 - File path to DH/DSA parameters file (in PEM format)
300          *
301          * This field is like dh_file, but used for phase 2 (inside
302          * EAP-TTLS/PEAP/FAST tunnel) authentication. Full path to the
303          * file should be used since working directory may change when
304          * wpa_supplicant is run in the background.
305          *
306          * Alternatively, a named configuration blob can be used by setting
307          * this to blob://blob_name.
308          */
309         u8 *dh_file2;
310
311         /**
312          * subject_match2 - Constraint for server certificate subject
313          *
314          * This field is like subject_match, but used for phase 2 (inside
315          * EAP-TTLS/PEAP/FAST tunnel) authentication.
316          */
317         u8 *subject_match2;
318
319         /**
320          * altsubject_match2 - Constraint for server certificate alt. subject
321          *
322          * This field is like altsubject_match, but used for phase 2 (inside
323          * EAP-TTLS/PEAP/FAST tunnel) authentication.
324          */
325         u8 *altsubject_match2;
326
327         /**
328          * domain_suffix_match2 - Constraint for server domain name
329          *
330          * This field is like domain_suffix_match, but used for phase 2 (inside
331          * EAP-TTLS/PEAP/FAST tunnel) authentication.
332          */
333         char *domain_suffix_match2;
334
335         /**
336          * eap_methods - Allowed EAP methods
337          *
338          * (vendor=EAP_VENDOR_IETF,method=EAP_TYPE_NONE) terminated list of
339          * allowed EAP methods or %NULL if all methods are accepted.
340          */
341         struct eap_method_type *eap_methods;
342
343         /**
344          * phase1 - Phase 1 (outer authentication) parameters
345          *
346          * String with field-value pairs, e.g., "peapver=0" or
347          * "peapver=1 peaplabel=1".
348          *
349          * 'peapver' can be used to force which PEAP version (0 or 1) is used.
350          *
351          * 'peaplabel=1' can be used to force new label, "client PEAP
352          * encryption", to be used during key derivation when PEAPv1 or newer.
353          *
354          * Most existing PEAPv1 implementation seem to be using the old label,
355          * "client EAP encryption", and wpa_supplicant is now using that as the
356          * default value.
357          *
358          * Some servers, e.g., Radiator, may require peaplabel=1 configuration
359          * to interoperate with PEAPv1; see eap_testing.txt for more details.
360          *
361          * 'peap_outer_success=0' can be used to terminate PEAP authentication
362          * on tunneled EAP-Success. This is required with some RADIUS servers
363          * that implement draft-josefsson-pppext-eap-tls-eap-05.txt (e.g.,
364          * Lucent NavisRadius v4.4.0 with PEAP in "IETF Draft 5" mode).
365          *
366          * include_tls_length=1 can be used to force wpa_supplicant to include
367          * TLS Message Length field in all TLS messages even if they are not
368          * fragmented.
369          *
370          * sim_min_num_chal=3 can be used to configure EAP-SIM to require three
371          * challenges (by default, it accepts 2 or 3).
372          *
373          * result_ind=1 can be used to enable EAP-SIM and EAP-AKA to use
374          * protected result indication.
375          *
376          * fast_provisioning option can be used to enable in-line provisioning
377          * of EAP-FAST credentials (PAC):
378          * 0 = disabled,
379          * 1 = allow unauthenticated provisioning,
380          * 2 = allow authenticated provisioning,
381          * 3 = allow both unauthenticated and authenticated provisioning
382          *
383          * fast_max_pac_list_len=num option can be used to set the maximum
384          * number of PAC entries to store in a PAC list (default: 10).
385          *
386          * fast_pac_format=binary option can be used to select binary format
387          * for storing PAC entries in order to save some space (the default
388          * text format uses about 2.5 times the size of minimal binary format).
389          *
390          * crypto_binding option can be used to control PEAPv0 cryptobinding
391          * behavior:
392          * 0 = do not use cryptobinding (default)
393          * 1 = use cryptobinding if server supports it
394          * 2 = require cryptobinding
395          *
396          * EAP-WSC (WPS) uses following options: pin=Device_Password and
397          * uuid=Device_UUID
398          */
399         char *phase1;
400
401         /**
402          * phase2 - Phase2 (inner authentication with TLS tunnel) parameters
403          *
404          * String with field-value pairs, e.g., "auth=MSCHAPV2" for EAP-PEAP or
405          * "autheap=MSCHAPV2 autheap=MD5" for EAP-TTLS.
406          */
407         char *phase2;
408
409         /**
410          * pcsc - Parameters for PC/SC smartcard interface for USIM and GSM SIM
411          *
412          * This field is used to configure PC/SC smartcard interface.
413          * Currently, the only configuration is whether this field is %NULL (do
414          * not use PC/SC) or non-NULL (e.g., "") to enable PC/SC.
415          *
416          * This field is used for EAP-SIM and EAP-AKA.
417          */
418         char *pcsc;
419
420         /**
421          * pin - PIN for USIM, GSM SIM, and smartcards
422          *
423          * This field is used to configure PIN for SIM and smartcards for
424          * EAP-SIM and EAP-AKA. In addition, this is used with EAP-TLS if a
425          * smartcard is used for private key operations.
426          *
427          * If left out, this will be asked through control interface.
428          */
429         char *pin;
430
431         /**
432          * engine - Enable OpenSSL engine (e.g., for smartcard access)
433          *
434          * This is used if private key operations for EAP-TLS are performed
435          * using a smartcard.
436          */
437         int engine;
438
439         /**
440          * engine_id - Engine ID for OpenSSL engine
441          *
442          * "opensc" to select OpenSC engine or "pkcs11" to select PKCS#11
443          * engine.
444          *
445          * This is used if private key operations for EAP-TLS are performed
446          * using a smartcard.
447          */
448         char *engine_id;
449
450         /**
451          * engine2 - Enable OpenSSL engine (e.g., for smartcard) (Phase 2)
452          *
453          * This is used if private key operations for EAP-TLS are performed
454          * using a smartcard.
455          *
456          * This field is like engine, but used for phase 2 (inside
457          * EAP-TTLS/PEAP/FAST tunnel) authentication.
458          */
459         int engine2;
460
461
462         /**
463          * pin2 - PIN for USIM, GSM SIM, and smartcards (Phase 2)
464          *
465          * This field is used to configure PIN for SIM and smartcards for
466          * EAP-SIM and EAP-AKA. In addition, this is used with EAP-TLS if a
467          * smartcard is used for private key operations.
468          *
469          * This field is like pin2, but used for phase 2 (inside
470          * EAP-TTLS/PEAP/FAST tunnel) authentication.
471          *
472          * If left out, this will be asked through control interface.
473          */
474         char *pin2;
475
476         /**
477          * engine2_id - Engine ID for OpenSSL engine (Phase 2)
478          *
479          * "opensc" to select OpenSC engine or "pkcs11" to select PKCS#11
480          * engine.
481          *
482          * This is used if private key operations for EAP-TLS are performed
483          * using a smartcard.
484          *
485          * This field is like engine_id, but used for phase 2 (inside
486          * EAP-TTLS/PEAP/FAST tunnel) authentication.
487          */
488         char *engine2_id;
489
490
491         /**
492          * key_id - Key ID for OpenSSL engine
493          *
494          * This is used if private key operations for EAP-TLS are performed
495          * using a smartcard.
496          */
497         char *key_id;
498
499         /**
500          * cert_id - Cert ID for OpenSSL engine
501          *
502          * This is used if the certificate operations for EAP-TLS are performed
503          * using a smartcard.
504          */
505         char *cert_id;
506
507         /**
508          * ca_cert_id - CA Cert ID for OpenSSL engine
509          *
510          * This is used if the CA certificate for EAP-TLS is on a smartcard.
511          */
512         char *ca_cert_id;
513
514         /**
515          * key2_id - Key ID for OpenSSL engine (phase2)
516          *
517          * This is used if private key operations for EAP-TLS are performed
518          * using a smartcard.
519          */
520         char *key2_id;
521
522         /**
523          * cert2_id - Cert ID for OpenSSL engine (phase2)
524          *
525          * This is used if the certificate operations for EAP-TLS are performed
526          * using a smartcard.
527          */
528         char *cert2_id;
529
530         /**
531          * ca_cert2_id - CA Cert ID for OpenSSL engine (phase2)
532          *
533          * This is used if the CA certificate for EAP-TLS is on a smartcard.
534          */
535         char *ca_cert2_id;
536
537         /**
538          * otp - One-time-password
539          *
540          * This field should not be set in configuration step. It is only used
541          * internally when OTP is entered through the control interface.
542          */
543         u8 *otp;
544
545         /**
546          * otp_len - Length of the otp field
547          */
548         size_t otp_len;
549
550         /**
551          * pending_req_identity - Whether there is a pending identity request
552          *
553          * This field should not be set in configuration step. It is only used
554          * internally when control interface is used to request needed
555          * information.
556          */
557         int pending_req_identity;
558
559         /**
560          * pending_req_password - Whether there is a pending password request
561          *
562          * This field should not be set in configuration step. It is only used
563          * internally when control interface is used to request needed
564          * information.
565          */
566         int pending_req_password;
567
568         /**
569          * pending_req_pin - Whether there is a pending PIN request
570          *
571          * This field should not be set in configuration step. It is only used
572          * internally when control interface is used to request needed
573          * information.
574          */
575         int pending_req_pin;
576
577         /**
578          * pending_req_new_password - Pending password update request
579          *
580          * This field should not be set in configuration step. It is only used
581          * internally when control interface is used to request needed
582          * information.
583          */
584         int pending_req_new_password;
585
586         /**
587          * pending_req_passphrase - Pending passphrase request
588          *
589          * This field should not be set in configuration step. It is only used
590          * internally when control interface is used to request needed
591          * information.
592          */
593         int pending_req_passphrase;
594
595         /**
596          * pending_req_otp - Whether there is a pending OTP request
597          *
598          * This field should not be set in configuration step. It is only used
599          * internally when control interface is used to request needed
600          * information.
601          */
602         char *pending_req_otp;
603
604         /**
605          * pending_req_otp_len - Length of the pending OTP request
606          */
607         size_t pending_req_otp_len;
608
609         /**
610          * pac_file - File path or blob name for the PAC entries (EAP-FAST)
611          *
612          * wpa_supplicant will need to be able to create this file and write
613          * updates to it when PAC is being provisioned or refreshed. Full path
614          * to the file should be used since working directory may change when
615          * wpa_supplicant is run in the background.
616          * Alternatively, a named configuration blob can be used by setting
617          * this to blob://blob_name.
618          */
619         char *pac_file;
620
621         /**
622          * mschapv2_retry - MSCHAPv2 retry in progress
623          *
624          * This field is used internally by EAP-MSCHAPv2 and should not be set
625          * as part of configuration.
626          */
627         int mschapv2_retry;
628
629         /**
630          * new_password - New password for password update
631          *
632          * This field is used during MSCHAPv2 password update. This is normally
633          * requested from the user through the control interface and not set
634          * from configuration.
635          */
636         u8 *new_password;
637
638         /**
639          * new_password_len - Length of new_password field
640          */
641         size_t new_password_len;
642
643         /**
644          * fragment_size - Maximum EAP fragment size in bytes (default 1398)
645          *
646          * This value limits the fragment size for EAP methods that support
647          * fragmentation (e.g., EAP-TLS and EAP-PEAP). This value should be set
648          * small enough to make the EAP messages fit in MTU of the network
649          * interface used for EAPOL. The default value is suitable for most
650          * cases.
651          */
652         int fragment_size;
653
654 #define EAP_CONFIG_FLAGS_PASSWORD_NTHASH BIT(0)
655 #define EAP_CONFIG_FLAGS_EXT_PASSWORD BIT(1)
656         /**
657          * flags - Network configuration flags (bitfield)
658          *
659          * This variable is used for internal flags to describe further details
660          * for the network parameters.
661          * bit 0 = password is represented as a 16-byte NtPasswordHash value
662          *         instead of plaintext password
663          * bit 1 = password is stored in external storage; the value in the
664          *         password field is the name of that external entry
665          */
666         u32 flags;
667
668         /**
669          * ocsp - Whether to use/require OCSP to check server certificate
670          *
671          * 0 = do not use OCSP stapling (TLS certificate status extension)
672          * 1 = try to use OCSP stapling, but not require response
673          * 2 = require valid OCSP stapling response
674          */
675         int ocsp;
676
677         /**
678          * external_sim_resp - Response from external SIM processing
679          *
680          * This field should not be set in configuration step. It is only used
681          * internally when control interface is used to request external
682          * SIM/USIM processing.
683          */
684         char *external_sim_resp;
685
686         /**
687          * sim_num - User selected SIM identifier
688          *
689          * This variable is used for identifying which SIM is used if the system
690          * has more than one.
691          */
692         int sim_num;
693
694         /**
695          * openssl_ciphers - OpenSSL cipher string
696          *
697          * This is an OpenSSL specific configuration option for configuring the
698          * ciphers for this connection. If not set, the default cipher suite
699          * list is used.
700          */
701         char *openssl_ciphers;
702
703         /**
704          * erp - Whether EAP Re-authentication Protocol (ERP) is enabled
705          */
706         int erp;
707 };
708
709
710 /**
711  * struct wpa_config_blob - Named configuration blob
712  *
713  * This data structure is used to provide storage for binary objects to store
714  * abstract information like certificates and private keys inlined with the
715  * configuration data.
716  */
717 struct wpa_config_blob {
718         /**
719          * name - Blob name
720          */
721         char *name;
722
723         /**
724          * data - Pointer to binary data
725          */
726         u8 *data;
727
728         /**
729          * len - Length of binary data
730          */
731         size_t len;
732
733         /**
734          * next - Pointer to next blob in the configuration
735          */
736         struct wpa_config_blob *next;
737 };
738
739 #endif /* EAP_CONFIG_H */