forked from espressif/arduino-esp32
Update tools to latest IDF
This commit is contained in:
66
tools/sdk/include/wpa_supplicant/wpa2/tls/asn1.h
Normal file
66
tools/sdk/include/wpa_supplicant/wpa2/tls/asn1.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* ASN.1 DER parsing
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ASN1_H
|
||||
#define ASN1_H
|
||||
|
||||
#define ASN1_TAG_EOC 0x00 /* not used with DER */
|
||||
#define ASN1_TAG_BOOLEAN 0x01
|
||||
#define ASN1_TAG_INTEGER 0x02
|
||||
#define ASN1_TAG_BITSTRING 0x03
|
||||
#define ASN1_TAG_OCTETSTRING 0x04
|
||||
#define ASN1_TAG_NULL 0x05
|
||||
#define ASN1_TAG_OID 0x06
|
||||
#define ASN1_TAG_OBJECT_DESCRIPTOR 0x07 /* not yet parsed */
|
||||
#define ASN1_TAG_EXTERNAL 0x08 /* not yet parsed */
|
||||
#define ASN1_TAG_REAL 0x09 /* not yet parsed */
|
||||
#define ASN1_TAG_ENUMERATED 0x0A /* not yet parsed */
|
||||
#define ASN1_TAG_UTF8STRING 0x0C /* not yet parsed */
|
||||
#define ANS1_TAG_RELATIVE_OID 0x0D
|
||||
#define ASN1_TAG_SEQUENCE 0x10 /* shall be constructed */
|
||||
#define ASN1_TAG_SET 0x11
|
||||
#define ASN1_TAG_NUMERICSTRING 0x12 /* not yet parsed */
|
||||
#define ASN1_TAG_PRINTABLESTRING 0x13
|
||||
#define ASN1_TAG_TG1STRING 0x14 /* not yet parsed */
|
||||
#define ASN1_TAG_VIDEOTEXSTRING 0x15 /* not yet parsed */
|
||||
#define ASN1_TAG_IA5STRING 0x16
|
||||
#define ASN1_TAG_UTCTIME 0x17
|
||||
#define ASN1_TAG_GENERALIZEDTIME 0x18 /* not yet parsed */
|
||||
#define ASN1_TAG_GRAPHICSTRING 0x19 /* not yet parsed */
|
||||
#define ASN1_TAG_VISIBLESTRING 0x1A
|
||||
#define ASN1_TAG_GENERALSTRING 0x1B /* not yet parsed */
|
||||
#define ASN1_TAG_UNIVERSALSTRING 0x1C /* not yet parsed */
|
||||
#define ASN1_TAG_BMPSTRING 0x1D /* not yet parsed */
|
||||
|
||||
#define ASN1_CLASS_UNIVERSAL 0
|
||||
#define ASN1_CLASS_APPLICATION 1
|
||||
#define ASN1_CLASS_CONTEXT_SPECIFIC 2
|
||||
#define ASN1_CLASS_PRIVATE 3
|
||||
|
||||
|
||||
struct asn1_hdr {
|
||||
const u8 *payload;
|
||||
u8 identifier, class, constructed;
|
||||
unsigned int tag, length;
|
||||
};
|
||||
|
||||
#define ASN1_MAX_OID_LEN 20
|
||||
struct asn1_oid {
|
||||
unsigned long oid[ASN1_MAX_OID_LEN];
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
||||
int asn1_get_next(const u8 *buf, size_t len, struct asn1_hdr *hdr);
|
||||
int asn1_parse_oid(const u8 *buf, size_t len, struct asn1_oid *oid);
|
||||
int asn1_get_oid(const u8 *buf, size_t len, struct asn1_oid *oid,
|
||||
const u8 **next);
|
||||
void asn1_oid_to_str(struct asn1_oid *oid, char *buf, size_t len);
|
||||
unsigned long asn1_bit_string_to_long(const u8 *buf, size_t len);
|
||||
|
||||
#endif /* ASN1_H */
|
38
tools/sdk/include/wpa_supplicant/wpa2/tls/bignum.h
Normal file
38
tools/sdk/include/wpa_supplicant/wpa2/tls/bignum.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Big number math
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef BIGNUM_H
|
||||
#define BIGNUM_H
|
||||
|
||||
struct bignum;
|
||||
|
||||
struct bignum * bignum_init(void);
|
||||
void bignum_deinit(struct bignum *n);
|
||||
size_t bignum_get_unsigned_bin_len(struct bignum *n);
|
||||
int bignum_get_unsigned_bin(const struct bignum *n, u8 *buf, size_t *len);
|
||||
int bignum_set_unsigned_bin(struct bignum *n, const u8 *buf, size_t len);
|
||||
int bignum_cmp(const struct bignum *a, const struct bignum *b);
|
||||
int bignum_cmp_d(const struct bignum *a, unsigned long b);
|
||||
int bignum_add(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_sub(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_mul(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_mulmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
int bignum_exptmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
|
||||
#endif /* BIGNUM_H */
|
3443
tools/sdk/include/wpa_supplicant/wpa2/tls/libtommath.h
Normal file
3443
tools/sdk/include/wpa_supplicant/wpa2/tls/libtommath.h
Normal file
File diff suppressed because it is too large
Load Diff
22
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs1.h
Normal file
22
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs1.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* PKCS #1 (RSA Encryption)
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS1_H
|
||||
#define PKCS1_H
|
||||
|
||||
int pkcs1_encrypt(int block_type, struct crypto_rsa_key *key,
|
||||
int use_private, const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
int pkcs1_v15_private_key_decrypt(struct crypto_rsa_key *key,
|
||||
const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
int pkcs1_decrypt_public_key(struct crypto_rsa_key *key,
|
||||
const u8 *crypt, size_t crypt_len,
|
||||
u8 *plain, size_t *plain_len);
|
||||
|
||||
#endif /* PKCS1_H */
|
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs5.h
Normal file
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs5.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* PKCS #5 (Password-based Encryption)
|
||||
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS5_H
|
||||
#define PKCS5_H
|
||||
|
||||
u8 * pkcs5_decrypt(const u8 *enc_alg, size_t enc_alg_len,
|
||||
const u8 *enc_data, size_t enc_data_len,
|
||||
const char *passwd, size_t *data_len);
|
||||
|
||||
#endif /* PKCS5_H */
|
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs8.h
Normal file
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs8.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* PKCS #8 (Private-key information syntax)
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS8_H
|
||||
#define PKCS8_H
|
||||
|
||||
struct crypto_private_key * pkcs8_key_import(const u8 *buf, size_t len);
|
||||
struct crypto_private_key *
|
||||
pkcs8_enc_key_import(const u8 *buf, size_t len, const char *passwd);
|
||||
|
||||
#endif /* PKCS8_H */
|
23
tools/sdk/include/wpa_supplicant/wpa2/tls/rsa.h
Normal file
23
tools/sdk/include/wpa_supplicant/wpa2/tls/rsa.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* RSA
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef RSA_H
|
||||
#define RSA_H
|
||||
|
||||
struct crypto_rsa_key;
|
||||
|
||||
struct crypto_rsa_key *
|
||||
crypto_rsa_import_public_key(const u8 *buf, size_t len);
|
||||
struct crypto_rsa_key *
|
||||
crypto_rsa_import_private_key(const u8 *buf, size_t len);
|
||||
size_t crypto_rsa_get_modulus_len(struct crypto_rsa_key *key);
|
||||
int crypto_rsa_exptmod(const u8 *in, size_t inlen, u8 *out, size_t *outlen,
|
||||
struct crypto_rsa_key *key, int use_private);
|
||||
void crypto_rsa_free(struct crypto_rsa_key *key);
|
||||
|
||||
#endif /* RSA_H */
|
537
tools/sdk/include/wpa_supplicant/wpa2/tls/tls.h
Normal file
537
tools/sdk/include/wpa_supplicant/wpa2/tls/tls.h
Normal file
@ -0,0 +1,537 @@
|
||||
/*
|
||||
* SSL/TLS interface definition
|
||||
* Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLS_H
|
||||
#define TLS_H
|
||||
|
||||
struct tls_connection;
|
||||
|
||||
struct tls_keys {
|
||||
const u8 *master_key; /* TLS master secret */
|
||||
size_t master_key_len;
|
||||
const u8 *client_random;
|
||||
size_t client_random_len;
|
||||
const u8 *server_random;
|
||||
size_t server_random_len;
|
||||
};
|
||||
|
||||
enum tls_event {
|
||||
TLS_CERT_CHAIN_SUCCESS,
|
||||
TLS_CERT_CHAIN_FAILURE,
|
||||
TLS_PEER_CERTIFICATE,
|
||||
TLS_ALERT
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: These are used as identifier with external programs and as such, the
|
||||
* values must not be changed.
|
||||
*/
|
||||
enum tls_fail_reason {
|
||||
TLS_FAIL_UNSPECIFIED = 0,
|
||||
TLS_FAIL_UNTRUSTED = 1,
|
||||
TLS_FAIL_REVOKED = 2,
|
||||
TLS_FAIL_NOT_YET_VALID = 3,
|
||||
TLS_FAIL_EXPIRED = 4,
|
||||
TLS_FAIL_SUBJECT_MISMATCH = 5,
|
||||
TLS_FAIL_ALTSUBJECT_MISMATCH = 6,
|
||||
TLS_FAIL_BAD_CERTIFICATE = 7,
|
||||
TLS_FAIL_SERVER_CHAIN_PROBE = 8
|
||||
};
|
||||
|
||||
union tls_event_data {
|
||||
struct {
|
||||
int depth;
|
||||
const char *subject;
|
||||
enum tls_fail_reason reason;
|
||||
const char *reason_txt;
|
||||
const struct wpabuf *cert;
|
||||
} cert_fail;
|
||||
|
||||
struct {
|
||||
int depth;
|
||||
const char *subject;
|
||||
const struct wpabuf *cert;
|
||||
const u8 *hash;
|
||||
size_t hash_len;
|
||||
} peer_cert;
|
||||
|
||||
struct {
|
||||
int is_local;
|
||||
const char *type;
|
||||
const char *description;
|
||||
} alert;
|
||||
};
|
||||
|
||||
struct tls_config {
|
||||
const char *opensc_engine_path;
|
||||
const char *pkcs11_engine_path;
|
||||
const char *pkcs11_module_path;
|
||||
int fips_mode;
|
||||
int cert_in_cb;
|
||||
|
||||
void (*event_cb)(void *ctx, enum tls_event ev,
|
||||
union tls_event_data *data);
|
||||
void *cb_ctx;
|
||||
};
|
||||
|
||||
#define TLS_CONN_ALLOW_SIGN_RSA_MD5 BIT(0)
|
||||
#define TLS_CONN_DISABLE_TIME_CHECKS BIT(1)
|
||||
#define TLS_CONN_DISABLE_SESSION_TICKET BIT(2)
|
||||
#define TLS_CONN_REQUEST_OCSP BIT(3)
|
||||
#define TLS_CONN_REQUIRE_OCSP BIT(4)
|
||||
|
||||
/**
|
||||
* struct tls_connection_params - Parameters for TLS connection
|
||||
* @ca_cert: File or reference name for CA X.509 certificate in PEM or DER
|
||||
* format
|
||||
* @ca_cert_blob: ca_cert as inlined data or %NULL if not used
|
||||
* @ca_cert_blob_len: ca_cert_blob length
|
||||
* @ca_path: Path to CA certificates (OpenSSL specific)
|
||||
* @subject_match: String to match in the subject of the peer certificate or
|
||||
* %NULL to allow all subjects
|
||||
* @altsubject_match: String to match in the alternative subject of the peer
|
||||
* certificate or %NULL to allow all alternative subjects
|
||||
* @client_cert: File or reference name for client X.509 certificate in PEM or
|
||||
* DER format
|
||||
* @client_cert_blob: client_cert as inlined data or %NULL if not used
|
||||
* @client_cert_blob_len: client_cert_blob length
|
||||
* @private_key: File or reference name for client private key in PEM or DER
|
||||
* format (traditional format (RSA PRIVATE KEY) or PKCS#8 (PRIVATE KEY)
|
||||
* @private_key_blob: private_key as inlined data or %NULL if not used
|
||||
* @private_key_blob_len: private_key_blob length
|
||||
* @private_key_passwd: Passphrase for decrypted private key, %NULL if no
|
||||
* passphrase is used.
|
||||
* @dh_file: File name for DH/DSA data in PEM format, or %NULL if not used
|
||||
* @dh_blob: dh_file as inlined data or %NULL if not used
|
||||
* @dh_blob_len: dh_blob length
|
||||
* @engine: 1 = use engine (e.g., a smartcard) for private key operations
|
||||
* (this is OpenSSL specific for now)
|
||||
* @engine_id: engine id string (this is OpenSSL specific for now)
|
||||
* @ppin: pointer to the pin variable in the configuration
|
||||
* (this is OpenSSL specific for now)
|
||||
* @key_id: the private key's id when using engine (this is OpenSSL
|
||||
* specific for now)
|
||||
* @cert_id: the certificate's id when using engine
|
||||
* @ca_cert_id: the CA certificate's id when using engine
|
||||
* @flags: Parameter options (TLS_CONN_*)
|
||||
* @ocsp_stapling_response: DER encoded file with cached OCSP stapling response
|
||||
* or %NULL if OCSP is not enabled
|
||||
*
|
||||
* TLS connection parameters to be configured with tls_connection_set_params()
|
||||
* and tls_global_set_params().
|
||||
*
|
||||
* Certificates and private key can be configured either as a reference name
|
||||
* (file path or reference to certificate store) or by providing the same data
|
||||
* as a pointer to the data in memory. Only one option will be used for each
|
||||
* field.
|
||||
*/
|
||||
struct tls_connection_params {
|
||||
const char *ca_cert;
|
||||
const u8 *ca_cert_blob;
|
||||
size_t ca_cert_blob_len;
|
||||
const char *ca_path;
|
||||
const char *subject_match;
|
||||
const char *altsubject_match;
|
||||
const char *client_cert;
|
||||
const u8 *client_cert_blob;
|
||||
size_t client_cert_blob_len;
|
||||
const char *private_key;
|
||||
const u8 *private_key_blob;
|
||||
size_t private_key_blob_len;
|
||||
const char *private_key_passwd;
|
||||
const char *dh_file;
|
||||
const u8 *dh_blob;
|
||||
size_t dh_blob_len;
|
||||
|
||||
/* OpenSSL specific variables */
|
||||
int engine;
|
||||
const char *engine_id;
|
||||
const char *pin;
|
||||
const char *key_id;
|
||||
const char *cert_id;
|
||||
const char *ca_cert_id;
|
||||
|
||||
unsigned int flags;
|
||||
const char *ocsp_stapling_response;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* tls_init - Initialize TLS library
|
||||
* @conf: Configuration data for TLS library
|
||||
* Returns: Context data to be used as tls_ctx in calls to other functions,
|
||||
* or %NULL on failure.
|
||||
*
|
||||
* Called once during program startup and once for each RSN pre-authentication
|
||||
* session. In other words, there can be two concurrent TLS contexts. If global
|
||||
* library initialization is needed (i.e., one that is shared between both
|
||||
* authentication types), the TLS library wrapper should maintain a reference
|
||||
* counter and do global initialization only when moving from 0 to 1 reference.
|
||||
*/
|
||||
void * tls_init(void);
|
||||
|
||||
/**
|
||||
* tls_deinit - Deinitialize TLS library
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
*
|
||||
* Called once during program shutdown and once for each RSN pre-authentication
|
||||
* session. If global library deinitialization is needed (i.e., one that is
|
||||
* shared between both authentication types), the TLS library wrapper should
|
||||
* maintain a reference counter and do global deinitialization only when moving
|
||||
* from 1 to 0 references.
|
||||
*/
|
||||
void tls_deinit(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_get_errors - Process pending errors
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Number of found error, 0 if no errors detected.
|
||||
*
|
||||
* Process all pending TLS errors.
|
||||
*/
|
||||
int tls_get_errors(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_connection_init - Initialize a new TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Connection context data, conn for other function calls
|
||||
*/
|
||||
struct tls_connection * tls_connection_init(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_connection_deinit - Free TLS connection data
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
*
|
||||
* Release all resources allocated for TLS connection.
|
||||
*/
|
||||
void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_established - Has the TLS connection been completed?
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 1 if TLS connection has been completed, 0 if not.
|
||||
*/
|
||||
int tls_connection_established(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_shutdown - Shutdown TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Shutdown current TLS connection without releasing all resources. New
|
||||
* connection can be started by using the same conn without having to call
|
||||
* tls_connection_init() or setting certificates etc. again. The new
|
||||
* connection should try to use session resumption.
|
||||
*/
|
||||
int tls_connection_shutdown(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
enum {
|
||||
TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED = -3,
|
||||
TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED = -2
|
||||
};
|
||||
|
||||
/**
|
||||
* tls_connection_set_params - Set TLS connection parameters
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @params: Connection parameters
|
||||
* Returns: 0 on success, -1 on failure,
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on possible PIN error causing
|
||||
* PKCS#11 engine failure, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
|
||||
* PKCS#11 engine private key.
|
||||
*/
|
||||
int __must_check
|
||||
tls_connection_set_params(void *tls_ctx, struct tls_connection *conn,
|
||||
const struct tls_connection_params *params);
|
||||
|
||||
/**
|
||||
* tls_global_set_params - Set TLS parameters for all TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @params: Global TLS parameters
|
||||
* Returns: 0 on success, -1 on failure,
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on possible PIN error causing
|
||||
* PKCS#11 engine failure, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
|
||||
* PKCS#11 engine private key.
|
||||
*/
|
||||
int __must_check tls_global_set_params(
|
||||
void *tls_ctx, const struct tls_connection_params *params);
|
||||
|
||||
/**
|
||||
* tls_global_set_verify - Set global certificate verification options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @check_crl: 0 = do not verify CRLs, 1 = verify CRL for the user certificate,
|
||||
* 2 = verify CRL for all certificates
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_global_set_verify(void *tls_ctx, int check_crl);
|
||||
|
||||
/**
|
||||
* tls_connection_set_verify - Set certificate verification options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @verify_peer: 1 = verify peer certificate
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_set_verify(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
int verify_peer);
|
||||
|
||||
/**
|
||||
* tls_connection_get_keys - Get master key and random data from TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @keys: Structure of key/random data (filled on success)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_get_keys(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
struct tls_keys *keys);
|
||||
|
||||
/**
|
||||
* tls_connection_prf - Use TLS-PRF to derive keying material
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @label: Label (e.g., description of the key) for PRF
|
||||
* @server_random_first: seed is 0 = client_random|server_random,
|
||||
* 1 = server_random|client_random
|
||||
* @out: Buffer for output data from TLS-PRF
|
||||
* @out_len: Length of the output buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is optional to implement if tls_connection_get_keys() provides
|
||||
* access to master secret and server/client random values. If these values are
|
||||
* not exported from the TLS library, tls_connection_prf() is required so that
|
||||
* further keying material can be derived from the master secret. If not
|
||||
* implemented, the function will still need to be defined, but it can just
|
||||
* return -1. Example implementation of this function is in tls_prf_sha1_md5()
|
||||
* when it is called with seed set to client_random|server_random (or
|
||||
* server_random|client_random).
|
||||
*/
|
||||
int __must_check tls_connection_prf(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const char *label,
|
||||
int server_random_first,
|
||||
u8 *out, size_t out_len);
|
||||
|
||||
/**
|
||||
* tls_connection_handshake - Process TLS handshake (client side)
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Input data from TLS server
|
||||
* @appl_data: Pointer to application data pointer, or %NULL if dropped
|
||||
* Returns: Output data, %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the returned output data. If the final
|
||||
* handshake message includes application data, this is decrypted and
|
||||
* appl_data (if not %NULL) is set to point this data. The caller is
|
||||
* responsible for freeing appl_data.
|
||||
*
|
||||
* This function is used during TLS handshake. The first call is done with
|
||||
* in_data == %NULL and the library is expected to return ClientHello packet.
|
||||
* This packet is then send to the server and a response from server is given
|
||||
* to TLS library by calling this function again with in_data pointing to the
|
||||
* TLS message from the server.
|
||||
*
|
||||
* If the TLS handshake fails, this function may return %NULL. However, if the
|
||||
* TLS library has a TLS alert to send out, that should be returned as the
|
||||
* output data. In this case, tls_connection_get_failed() must return failure
|
||||
* (> 0).
|
||||
*
|
||||
* tls_connection_established() should return 1 once the TLS handshake has been
|
||||
* completed successfully.
|
||||
*/
|
||||
struct wpabuf * tls_connection_handshake(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data);
|
||||
|
||||
struct wpabuf * tls_connection_handshake2(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data,
|
||||
int *more_data_needed);
|
||||
|
||||
/**
|
||||
* tls_connection_server_handshake - Process TLS handshake (server side)
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Input data from TLS peer
|
||||
* @appl_data: Pointer to application data pointer, or %NULL if dropped
|
||||
* Returns: Output data, %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_server_handshake(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data);
|
||||
|
||||
/**
|
||||
* tls_connection_encrypt - Encrypt data into TLS tunnel
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Plaintext data to be encrypted
|
||||
* Returns: Encrypted TLS data or %NULL on failure
|
||||
*
|
||||
* This function is used after TLS handshake has been completed successfully to
|
||||
* send data in the encrypted tunnel. The caller is responsible for freeing the
|
||||
* returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_encrypt(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data);
|
||||
|
||||
/**
|
||||
* tls_connection_decrypt - Decrypt data from TLS tunnel
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Encrypted TLS data
|
||||
* Returns: Decrypted TLS data or %NULL on failure
|
||||
*
|
||||
* This function is used after TLS handshake has been completed successfully to
|
||||
* receive data from the encrypted tunnel. The caller is responsible for
|
||||
* freeing the returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_decrypt(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data);
|
||||
|
||||
struct wpabuf * tls_connection_decrypt2(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
int *more_data_needed);
|
||||
|
||||
/**
|
||||
* tls_connection_resumed - Was session resumption used
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 1 if current session used session resumption, 0 if not
|
||||
*/
|
||||
int tls_connection_resumed(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
enum {
|
||||
TLS_CIPHER_NONE,
|
||||
TLS_CIPHER_RC4_SHA /* 0x0005 */,
|
||||
TLS_CIPHER_AES128_SHA /* 0x002f */,
|
||||
TLS_CIPHER_RSA_DHE_AES128_SHA /* 0x0031 */,
|
||||
TLS_CIPHER_ANON_DH_AES128_SHA /* 0x0034 */
|
||||
};
|
||||
|
||||
/**
|
||||
* tls_connection_set_cipher_list - Configure acceptable cipher suites
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @ciphers: Zero (TLS_CIPHER_NONE) terminated list of allowed ciphers
|
||||
* (TLS_CIPHER_*).
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_set_cipher_list(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
u8 *ciphers);
|
||||
|
||||
/**
|
||||
* tls_get_cipher - Get current cipher name
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @buf: Buffer for the cipher name
|
||||
* @buflen: buf size
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Get the name of the currently used cipher.
|
||||
*/
|
||||
int __must_check tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
|
||||
char *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* tls_connection_enable_workaround - Enable TLS workaround options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is used to enable connection-specific workaround options for
|
||||
* buffer SSL/TLS implementations.
|
||||
*/
|
||||
int __must_check tls_connection_enable_workaround(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_client_hello_ext - Set TLS extension for ClientHello
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @ext_type: Extension type
|
||||
* @data: Extension payload (%NULL to remove extension)
|
||||
* @data_len: Extension payload length
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_client_hello_ext(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
int ext_type, const u8 *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* tls_connection_get_failed - Get connection failure status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
*
|
||||
* Returns >0 if connection has failed, 0 if not.
|
||||
*/
|
||||
int tls_connection_get_failed(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_read_alerts - Get connection read alert status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Number of times a fatal read (remote end reported error) has
|
||||
* happened during this connection.
|
||||
*/
|
||||
int tls_connection_get_read_alerts(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_write_alerts - Get connection write alert status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Number of times a fatal write (locally detected error) has happened
|
||||
* during this connection.
|
||||
*/
|
||||
int tls_connection_get_write_alerts(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_keyblock_size - Get TLS key_block size
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Size of the key_block for the negotiated cipher suite or -1 on
|
||||
* failure
|
||||
*/
|
||||
int tls_connection_get_keyblock_size(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_capabilities - Get supported TLS capabilities
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Bit field of supported TLS capabilities (TLS_CAPABILITY_*)
|
||||
*/
|
||||
unsigned int tls_capabilities(void *tls_ctx);
|
||||
|
||||
typedef int (*tls_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
int __must_check tls_connection_set_session_ticket_cb(
|
||||
void *tls_ctx, struct tls_connection *conn,
|
||||
tls_session_ticket_cb cb, void *ctx);
|
||||
|
||||
int tls_prf_sha1_md5(const u8 *secret, size_t secret_len, const char *label,
|
||||
const u8 *seed, size_t seed_len, u8 *out, size_t outlen);
|
||||
|
||||
#endif /* TLS_H */
|
54
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client.h
Normal file
54
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246)
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CLIENT_H
|
||||
#define TLSV1_CLIENT_H
|
||||
|
||||
#include "tlsv1_cred.h"
|
||||
|
||||
struct tlsv1_client;
|
||||
|
||||
int tlsv1_client_global_init(void);
|
||||
void tlsv1_client_global_deinit(void);
|
||||
struct tlsv1_client * tlsv1_client_init(void);
|
||||
void tlsv1_client_deinit(struct tlsv1_client *conn);
|
||||
int tlsv1_client_established(struct tlsv1_client *conn);
|
||||
int tlsv1_client_prf(struct tlsv1_client *conn, const char *label,
|
||||
int server_random_first, u8 *out, size_t out_len);
|
||||
u8 * tlsv1_client_handshake(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
size_t *out_len, u8 **appl_data,
|
||||
size_t *appl_data_len, int *need_more_data);
|
||||
int tlsv1_client_encrypt(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
struct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
int *need_more_data);
|
||||
int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf,
|
||||
size_t buflen);
|
||||
int tlsv1_client_shutdown(struct tlsv1_client *conn);
|
||||
int tlsv1_client_resumed(struct tlsv1_client *conn);
|
||||
int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type,
|
||||
const u8 *data, size_t data_len);
|
||||
int tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys);
|
||||
int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn);
|
||||
int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers);
|
||||
int tlsv1_client_set_cred(struct tlsv1_client *conn,
|
||||
struct tlsv1_credentials *cred);
|
||||
void tlsv1_client_set_time_checks(struct tlsv1_client *conn, int enabled);
|
||||
|
||||
typedef int (*tlsv1_client_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn,
|
||||
tlsv1_client_session_ticket_cb cb,
|
||||
void *ctx);
|
||||
|
||||
#endif /* TLSV1_CLIENT_H */
|
84
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client_i.h
Normal file
84
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client_i.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* TLSv1 client - internal structures
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CLIENT_I_H
|
||||
#define TLSV1_CLIENT_I_H
|
||||
|
||||
struct tlsv1_client {
|
||||
enum {
|
||||
CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
|
||||
SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
|
||||
SERVER_HELLO_DONE, CLIENT_KEY_EXCHANGE, CHANGE_CIPHER_SPEC,
|
||||
SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, ACK_FINISHED,
|
||||
ESTABLISHED, FAILED
|
||||
} state;
|
||||
|
||||
struct tlsv1_record_layer rl;
|
||||
|
||||
u8 session_id[TLS_SESSION_ID_MAX_LEN];
|
||||
size_t session_id_len;
|
||||
u8 client_random[TLS_RANDOM_LEN];
|
||||
u8 server_random[TLS_RANDOM_LEN];
|
||||
u8 master_secret[TLS_MASTER_SECRET_LEN];
|
||||
|
||||
u8 alert_level;
|
||||
u8 alert_description;
|
||||
|
||||
unsigned int certificate_requested:1;
|
||||
unsigned int session_resumed:1;
|
||||
unsigned int session_ticket_included:1;
|
||||
unsigned int use_session_ticket:1;
|
||||
unsigned int disable_time_checks:1;
|
||||
|
||||
struct crypto_public_key *server_rsa_key;
|
||||
|
||||
struct tls_verify_hash verify;
|
||||
|
||||
#define MAX_CIPHER_COUNT 30
|
||||
u16 cipher_suites[MAX_CIPHER_COUNT];
|
||||
size_t num_cipher_suites;
|
||||
|
||||
u16 prev_cipher_suite;
|
||||
|
||||
u8 *client_hello_ext;
|
||||
size_t client_hello_ext_len;
|
||||
|
||||
/* The prime modulus used for Diffie-Hellman */
|
||||
u8 *dh_p;
|
||||
size_t dh_p_len;
|
||||
/* The generator used for Diffie-Hellman */
|
||||
u8 *dh_g;
|
||||
size_t dh_g_len;
|
||||
/* The server's Diffie-Hellman public value */
|
||||
u8 *dh_ys;
|
||||
size_t dh_ys_len;
|
||||
|
||||
struct tlsv1_credentials *cred;
|
||||
|
||||
tlsv1_client_session_ticket_cb session_ticket_cb;
|
||||
void *session_ticket_cb_ctx;
|
||||
|
||||
struct wpabuf *partial_input;
|
||||
};
|
||||
|
||||
|
||||
void tls_alert(struct tlsv1_client *conn, u8 level, u8 description);
|
||||
void tlsv1_client_free_dh(struct tlsv1_client *conn);
|
||||
int tls_derive_pre_master_secret(u8 *pre_master_secret);
|
||||
int tls_derive_keys(struct tlsv1_client *conn,
|
||||
const u8 *pre_master_secret, size_t pre_master_secret_len);
|
||||
u8 * tls_send_client_hello(struct tlsv1_client *conn, size_t *out_len);
|
||||
u8 * tlsv1_client_send_alert(struct tlsv1_client *conn, u8 level,
|
||||
u8 description, size_t *out_len);
|
||||
u8 * tlsv1_client_handshake_write(struct tlsv1_client *conn, size_t *out_len,
|
||||
int no_appl_data);
|
||||
int tlsv1_client_process_handshake(struct tlsv1_client *conn, u8 ct,
|
||||
const u8 *buf, size_t *len,
|
||||
u8 **out_data, size_t *out_len);
|
||||
|
||||
#endif /* TLSV1_CLIENT_I_H */
|
261
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_common.h
Normal file
261
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_common.h
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* TLSv1 common definitions
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_COMMON_H
|
||||
#define TLSV1_COMMON_H
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
#define TLS_VERSION_1 0x0301 /* TLSv1 */
|
||||
#define TLS_VERSION_1_1 0x0302 /* TLSv1.1 */
|
||||
#define TLS_VERSION_1_2 0x0303 /* TLSv1.2 */
|
||||
#ifdef CONFIG_TLSV12
|
||||
#define TLS_VERSION TLS_VERSION_1_2
|
||||
#else /* CONFIG_TLSV12 */
|
||||
#ifdef CONFIG_TLSV11
|
||||
#define TLS_VERSION TLS_VERSION_1_1
|
||||
#else /* CONFIG_TLSV11 */
|
||||
#define TLS_VERSION TLS_VERSION_1
|
||||
#endif /* CONFIG_TLSV11 */
|
||||
#endif /* CONFIG_TLSV12 */
|
||||
#define TLS_RANDOM_LEN 32
|
||||
#define TLS_PRE_MASTER_SECRET_LEN 48
|
||||
#define TLS_MASTER_SECRET_LEN 48
|
||||
#define TLS_SESSION_ID_MAX_LEN 32
|
||||
#define TLS_VERIFY_DATA_LEN 12
|
||||
|
||||
/* HandshakeType */
|
||||
enum {
|
||||
TLS_HANDSHAKE_TYPE_HELLO_REQUEST = 0,
|
||||
TLS_HANDSHAKE_TYPE_CLIENT_HELLO = 1,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_HELLO = 2,
|
||||
TLS_HANDSHAKE_TYPE_NEW_SESSION_TICKET = 4 /* RFC 4507 */,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE = 11,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_KEY_EXCHANGE = 12,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_REQUEST = 13,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_HELLO_DONE = 14,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_VERIFY = 15,
|
||||
TLS_HANDSHAKE_TYPE_CLIENT_KEY_EXCHANGE = 16,
|
||||
TLS_HANDSHAKE_TYPE_FINISHED = 20,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_URL = 21 /* RFC 4366 */,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_STATUS = 22 /* RFC 4366 */
|
||||
};
|
||||
|
||||
/* CipherSuite */
|
||||
#define TLS_NULL_WITH_NULL_NULL 0x0000 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_NULL_MD5 0x0001 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_NULL_SHA 0x0002 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_RC4_40_MD5 0x0003 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_RC4_128_MD5 0x0004 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_RC4_128_SHA 0x0005 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 0x0006 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_IDEA_CBC_SHA 0x0007 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0008 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_DES_CBC_SHA 0x0009 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x000A /* RFC 2246 */
|
||||
#define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 0x000B /* RFC 2246 */
|
||||
#define TLS_DH_DSS_WITH_DES_CBC_SHA 0x000C /* RFC 2246 */
|
||||
#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 0x000D /* RFC 2246 */
|
||||
#define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 0x000E /* RFC 2246 */
|
||||
#define TLS_DH_RSA_WITH_DES_CBC_SHA 0x000F /* RFC 2246 */
|
||||
#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 0x0010 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 0x0011 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_WITH_DES_CBC_SHA 0x0012 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 0x0013 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0014 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x0015 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x0016 /* RFC 2246 */
|
||||
#define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 0x0017 /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_RC4_128_MD5 0x0018 /* RFC 2246 */
|
||||
#define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 0x0019 /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_DES_CBC_SHA 0x001A /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 0x001B /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_AES_128_CBC_SHA 0x002F /* RFC 3268 */
|
||||
#define TLS_DH_DSS_WITH_AES_128_CBC_SHA 0x0030 /* RFC 3268 */
|
||||
#define TLS_DH_RSA_WITH_AES_128_CBC_SHA 0x0031 /* RFC 3268 */
|
||||
#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA 0x0032 /* RFC 3268 */
|
||||
#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x0033 /* RFC 3268 */
|
||||
#define TLS_DH_anon_WITH_AES_128_CBC_SHA 0x0034 /* RFC 3268 */
|
||||
#define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035 /* RFC 3268 */
|
||||
#define TLS_DH_DSS_WITH_AES_256_CBC_SHA 0x0036 /* RFC 3268 */
|
||||
#define TLS_DH_RSA_WITH_AES_256_CBC_SHA 0x0037 /* RFC 3268 */
|
||||
#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA 0x0038 /* RFC 3268 */
|
||||
#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x0039 /* RFC 3268 */
|
||||
#define TLS_DH_anon_WITH_AES_256_CBC_SHA 0x003A /* RFC 3268 */
|
||||
#define TLS_RSA_WITH_NULL_SHA256 0x003B /* RFC 5246 */
|
||||
#define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003C /* RFC 5246 */
|
||||
#define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003D /* RFC 5246 */
|
||||
#define TLS_DH_DSS_WITH_AES_128_CBC_SHA256 0x003E /* RFC 5246 */
|
||||
#define TLS_DH_RSA_WITH_AES_128_CBC_SHA256 0x003F /* RFC 5246 */
|
||||
#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 0x0040 /* RFC 5246 */
|
||||
#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x0067 /* RFC 5246 */
|
||||
#define TLS_DH_DSS_WITH_AES_256_CBC_SHA256 0x0068 /* RFC 5246 */
|
||||
#define TLS_DH_RSA_WITH_AES_256_CBC_SHA256 0x0069 /* RFC 5246 */
|
||||
#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 0x006A /* RFC 5246 */
|
||||
#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x006B /* RFC 5246 */
|
||||
#define TLS_DH_anon_WITH_AES_128_CBC_SHA256 0x006C /* RFC 5246 */
|
||||
#define TLS_DH_anon_WITH_AES_256_CBC_SHA256 0x006D /* RFC 5246 */
|
||||
|
||||
/* CompressionMethod */
|
||||
#define TLS_COMPRESSION_NULL 0
|
||||
|
||||
/* HashAlgorithm */
|
||||
enum {
|
||||
TLS_HASH_ALG_NONE = 0,
|
||||
TLS_HASH_ALG_MD5 = 1,
|
||||
TLS_HASH_ALG_SHA1 = 2,
|
||||
TLS_HASH_ALG_SHA224 = 3,
|
||||
TLS_HASH_ALG_SHA256 = 4,
|
||||
TLS_HASH_ALG_SHA384 = 5,
|
||||
TLS_HASH_ALG_SHA512 = 6
|
||||
};
|
||||
|
||||
/* SignatureAlgorithm */
|
||||
enum {
|
||||
TLS_SIGN_ALG_ANONYMOUS = 0,
|
||||
TLS_SIGN_ALG_RSA = 1,
|
||||
TLS_SIGN_ALG_DSA = 2,
|
||||
TLS_SIGN_ALG_ECDSA = 3,
|
||||
};
|
||||
|
||||
/* AlertLevel */
|
||||
#define TLS_ALERT_LEVEL_WARNING 1
|
||||
#define TLS_ALERT_LEVEL_FATAL 2
|
||||
|
||||
/* AlertDescription */
|
||||
#define TLS_ALERT_CLOSE_NOTIFY 0
|
||||
#define TLS_ALERT_UNEXPECTED_MESSAGE 10
|
||||
#define TLS_ALERT_BAD_RECORD_MAC 20
|
||||
#define TLS_ALERT_DECRYPTION_FAILED 21
|
||||
#define TLS_ALERT_RECORD_OVERFLOW 22
|
||||
#define TLS_ALERT_DECOMPRESSION_FAILURE 30
|
||||
#define TLS_ALERT_HANDSHAKE_FAILURE 40
|
||||
#define TLS_ALERT_BAD_CERTIFICATE 42
|
||||
#define TLS_ALERT_UNSUPPORTED_CERTIFICATE 43
|
||||
#define TLS_ALERT_CERTIFICATE_REVOKED 44
|
||||
#define TLS_ALERT_CERTIFICATE_EXPIRED 45
|
||||
#define TLS_ALERT_CERTIFICATE_UNKNOWN 46
|
||||
#define TLS_ALERT_ILLEGAL_PARAMETER 47
|
||||
#define TLS_ALERT_UNKNOWN_CA 48
|
||||
#define TLS_ALERT_ACCESS_DENIED 49
|
||||
#define TLS_ALERT_DECODE_ERROR 50
|
||||
#define TLS_ALERT_DECRYPT_ERROR 51
|
||||
#define TLS_ALERT_EXPORT_RESTRICTION 60
|
||||
#define TLS_ALERT_PROTOCOL_VERSION 70
|
||||
#define TLS_ALERT_INSUFFICIENT_SECURITY 71
|
||||
#define TLS_ALERT_INTERNAL_ERROR 80
|
||||
#define TLS_ALERT_USER_CANCELED 90
|
||||
#define TLS_ALERT_NO_RENEGOTIATION 100
|
||||
#define TLS_ALERT_UNSUPPORTED_EXTENSION 110 /* RFC 4366 */
|
||||
#define TLS_ALERT_CERTIFICATE_UNOBTAINABLE 111 /* RFC 4366 */
|
||||
#define TLS_ALERT_UNRECOGNIZED_NAME 112 /* RFC 4366 */
|
||||
#define TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE 113 /* RFC 4366 */
|
||||
#define TLS_ALERT_BAD_CERTIFICATE_HASH_VALUE 114 /* RFC 4366 */
|
||||
|
||||
/* ChangeCipherSpec */
|
||||
enum {
|
||||
TLS_CHANGE_CIPHER_SPEC = 1
|
||||
};
|
||||
|
||||
/* TLS Extensions */
|
||||
#define TLS_EXT_SERVER_NAME 0 /* RFC 4366 */
|
||||
#define TLS_EXT_MAX_FRAGMENT_LENGTH 1 /* RFC 4366 */
|
||||
#define TLS_EXT_CLIENT_CERTIFICATE_URL 2 /* RFC 4366 */
|
||||
#define TLS_EXT_TRUSTED_CA_KEYS 3 /* RFC 4366 */
|
||||
#define TLS_EXT_TRUNCATED_HMAC 4 /* RFC 4366 */
|
||||
#define TLS_EXT_STATUS_REQUEST 5 /* RFC 4366 */
|
||||
#define TLS_EXT_SESSION_TICKET 35 /* RFC 4507 */
|
||||
|
||||
#define TLS_EXT_PAC_OPAQUE TLS_EXT_SESSION_TICKET /* EAP-FAST terminology */
|
||||
|
||||
|
||||
typedef enum {
|
||||
TLS_KEY_X_NULL,
|
||||
TLS_KEY_X_RSA,
|
||||
TLS_KEY_X_RSA_EXPORT,
|
||||
TLS_KEY_X_DH_DSS_EXPORT,
|
||||
TLS_KEY_X_DH_DSS,
|
||||
TLS_KEY_X_DH_RSA_EXPORT,
|
||||
TLS_KEY_X_DH_RSA,
|
||||
TLS_KEY_X_DHE_DSS_EXPORT,
|
||||
TLS_KEY_X_DHE_DSS,
|
||||
TLS_KEY_X_DHE_RSA_EXPORT,
|
||||
TLS_KEY_X_DHE_RSA,
|
||||
TLS_KEY_X_DH_anon_EXPORT,
|
||||
TLS_KEY_X_DH_anon
|
||||
} tls_key_exchange;
|
||||
|
||||
typedef enum {
|
||||
TLS_CIPHER_NULL,
|
||||
TLS_CIPHER_RC4_40,
|
||||
TLS_CIPHER_RC4_128,
|
||||
TLS_CIPHER_RC2_CBC_40,
|
||||
TLS_CIPHER_IDEA_CBC,
|
||||
TLS_CIPHER_DES40_CBC,
|
||||
TLS_CIPHER_DES_CBC,
|
||||
TLS_CIPHER_3DES_EDE_CBC,
|
||||
TLS_CIPHER_AES_128_CBC,
|
||||
TLS_CIPHER_AES_256_CBC
|
||||
} tls_cipher;
|
||||
|
||||
typedef enum {
|
||||
TLS_HASH_NULL,
|
||||
TLS_HASH_MD5,
|
||||
TLS_HASH_SHA,
|
||||
TLS_HASH_SHA256
|
||||
} tls_hash;
|
||||
|
||||
struct tls_cipher_suite {
|
||||
u16 suite;
|
||||
tls_key_exchange key_exchange;
|
||||
tls_cipher cipher;
|
||||
tls_hash hash;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TLS_CIPHER_STREAM,
|
||||
TLS_CIPHER_BLOCK
|
||||
} tls_cipher_type;
|
||||
|
||||
struct tls_cipher_data {
|
||||
tls_cipher cipher;
|
||||
tls_cipher_type type;
|
||||
size_t key_material;
|
||||
size_t expanded_key_material;
|
||||
size_t block_size; /* also iv_size */
|
||||
enum crypto_cipher_alg alg;
|
||||
};
|
||||
|
||||
|
||||
struct tls_verify_hash {
|
||||
struct crypto_hash *md5_client;
|
||||
struct crypto_hash *sha1_client;
|
||||
struct crypto_hash *sha256_client;
|
||||
struct crypto_hash *md5_server;
|
||||
struct crypto_hash *sha1_server;
|
||||
struct crypto_hash *sha256_server;
|
||||
struct crypto_hash *md5_cert;
|
||||
struct crypto_hash *sha1_cert;
|
||||
struct crypto_hash *sha256_cert;
|
||||
};
|
||||
|
||||
|
||||
const struct tls_cipher_suite * tls_get_cipher_suite(u16 suite);
|
||||
const struct tls_cipher_data * tls_get_cipher_data(tls_cipher cipher);
|
||||
int tls_server_key_exchange_allowed(tls_cipher cipher);
|
||||
int tls_parse_cert(const u8 *buf, size_t len, struct crypto_public_key **pk);
|
||||
int tls_verify_hash_init(struct tls_verify_hash *verify);
|
||||
void tls_verify_hash_add(struct tls_verify_hash *verify, const u8 *buf,
|
||||
size_t len);
|
||||
void tls_verify_hash_free(struct tls_verify_hash *verify);
|
||||
int tls_version_ok(u16 ver);
|
||||
const char * tls_version_str(u16 ver);
|
||||
int tls_prf(u16 ver, const u8 *secret, size_t secret_len, const char *label,
|
||||
const u8 *seed, size_t seed_len, u8 *out, size_t outlen);
|
||||
|
||||
#endif /* TLSV1_COMMON_H */
|
40
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_cred.h
Normal file
40
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_cred.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* TLSv1 credentials
|
||||
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CRED_H
|
||||
#define TLSV1_CRED_H
|
||||
|
||||
struct tlsv1_credentials {
|
||||
struct x509_certificate *trusted_certs;
|
||||
struct x509_certificate *cert;
|
||||
struct crypto_private_key *key;
|
||||
|
||||
/* Diffie-Hellman parameters */
|
||||
u8 *dh_p; /* prime */
|
||||
size_t dh_p_len;
|
||||
u8 *dh_g; /* generator */
|
||||
size_t dh_g_len;
|
||||
};
|
||||
|
||||
|
||||
struct tlsv1_credentials * tlsv1_cred_alloc(void);
|
||||
void tlsv1_cred_free(struct tlsv1_credentials *cred);
|
||||
int tlsv1_set_ca_cert(struct tlsv1_credentials *cred, const char *cert,
|
||||
const u8 *cert_blob, size_t cert_blob_len,
|
||||
const char *path);
|
||||
int tlsv1_set_cert(struct tlsv1_credentials *cred, const char *cert,
|
||||
const u8 *cert_blob, size_t cert_blob_len);
|
||||
int tlsv1_set_private_key(struct tlsv1_credentials *cred,
|
||||
const char *private_key,
|
||||
const char *private_key_passwd,
|
||||
const u8 *private_key_blob,
|
||||
size_t private_key_blob_len);
|
||||
int tlsv1_set_dhparams(struct tlsv1_credentials *cred, const char *dh_file,
|
||||
const u8 *dh_blob, size_t dh_blob_len);
|
||||
|
||||
#endif /* TLSV1_CRED_H */
|
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_record.h
Normal file
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_record.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* TLSv1 Record Protocol
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_RECORD_H
|
||||
#define TLSV1_RECORD_H
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
#define TLS_MAX_WRITE_MAC_SECRET_LEN 32
|
||||
#define TLS_MAX_WRITE_KEY_LEN 32
|
||||
#define TLS_MAX_IV_LEN 16
|
||||
#define TLS_MAX_KEY_BLOCK_LEN (2 * (TLS_MAX_WRITE_MAC_SECRET_LEN + \
|
||||
TLS_MAX_WRITE_KEY_LEN + TLS_MAX_IV_LEN))
|
||||
|
||||
#define TLS_SEQ_NUM_LEN 8
|
||||
#define TLS_RECORD_HEADER_LEN 5
|
||||
|
||||
/* ContentType */
|
||||
enum {
|
||||
TLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC = 20,
|
||||
TLS_CONTENT_TYPE_ALERT = 21,
|
||||
TLS_CONTENT_TYPE_HANDSHAKE = 22,
|
||||
TLS_CONTENT_TYPE_APPLICATION_DATA = 23
|
||||
};
|
||||
|
||||
struct tlsv1_record_layer {
|
||||
u16 tls_version;
|
||||
|
||||
u8 write_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
|
||||
u8 read_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
|
||||
u8 write_key[TLS_MAX_WRITE_KEY_LEN];
|
||||
u8 read_key[TLS_MAX_WRITE_KEY_LEN];
|
||||
u8 write_iv[TLS_MAX_IV_LEN];
|
||||
u8 read_iv[TLS_MAX_IV_LEN];
|
||||
|
||||
size_t hash_size;
|
||||
size_t key_material_len;
|
||||
size_t iv_size; /* also block_size */
|
||||
|
||||
enum crypto_hash_alg hash_alg;
|
||||
enum crypto_cipher_alg cipher_alg;
|
||||
|
||||
u8 write_seq_num[TLS_SEQ_NUM_LEN];
|
||||
u8 read_seq_num[TLS_SEQ_NUM_LEN];
|
||||
|
||||
u16 cipher_suite;
|
||||
u16 write_cipher_suite;
|
||||
u16 read_cipher_suite;
|
||||
|
||||
struct crypto_cipher *write_cbc;
|
||||
struct crypto_cipher *read_cbc;
|
||||
};
|
||||
|
||||
|
||||
int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl,
|
||||
u16 cipher_suite);
|
||||
int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl);
|
||||
int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl);
|
||||
int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf,
|
||||
size_t buf_size, const u8 *payload, size_t payload_len,
|
||||
size_t *out_len);
|
||||
int tlsv1_record_receive(struct tlsv1_record_layer *rl,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t *out_len, u8 *alert);
|
||||
|
||||
#endif /* TLSV1_RECORD_H */
|
48
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server.h
Normal file
48
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* TLS v1.0/v1.1/v1.2 server (RFC 2246, RFC 4346, RFC 5246)
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_SERVER_H
|
||||
#define TLSV1_SERVER_H
|
||||
|
||||
#include "tlsv1_cred.h"
|
||||
|
||||
struct tlsv1_server;
|
||||
|
||||
int tlsv1_server_global_init(void);
|
||||
void tlsv1_server_global_deinit(void);
|
||||
struct tlsv1_server * tlsv1_server_init(struct tlsv1_credentials *cred);
|
||||
void tlsv1_server_deinit(struct tlsv1_server *conn);
|
||||
int tlsv1_server_established(struct tlsv1_server *conn);
|
||||
int tlsv1_server_prf(struct tlsv1_server *conn, const char *label,
|
||||
int server_random_first, u8 *out, size_t out_len);
|
||||
u8 * tlsv1_server_handshake(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len, size_t *out_len);
|
||||
int tlsv1_server_encrypt(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
int tlsv1_server_decrypt(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
int tlsv1_server_get_cipher(struct tlsv1_server *conn, char *buf,
|
||||
size_t buflen);
|
||||
int tlsv1_server_shutdown(struct tlsv1_server *conn);
|
||||
int tlsv1_server_resumed(struct tlsv1_server *conn);
|
||||
int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys);
|
||||
int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn);
|
||||
int tlsv1_server_set_cipher_list(struct tlsv1_server *conn, u8 *ciphers);
|
||||
int tlsv1_server_set_verify(struct tlsv1_server *conn, int verify_peer);
|
||||
|
||||
typedef int (*tlsv1_server_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
void tlsv1_server_set_session_ticket_cb(struct tlsv1_server *conn,
|
||||
tlsv1_server_session_ticket_cb cb,
|
||||
void *ctx);
|
||||
|
||||
#endif /* TLSV1_SERVER_H */
|
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server_i.h
Normal file
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server_i.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* TLSv1 server - internal structures
|
||||
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_SERVER_I_H
|
||||
#define TLSV1_SERVER_I_H
|
||||
|
||||
struct tlsv1_server {
|
||||
enum {
|
||||
CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
|
||||
SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
|
||||
SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE,
|
||||
CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED,
|
||||
SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED,
|
||||
ESTABLISHED, FAILED
|
||||
} state;
|
||||
|
||||
struct tlsv1_record_layer rl;
|
||||
|
||||
u8 session_id[TLS_SESSION_ID_MAX_LEN];
|
||||
size_t session_id_len;
|
||||
u8 client_random[TLS_RANDOM_LEN];
|
||||
u8 server_random[TLS_RANDOM_LEN];
|
||||
u8 master_secret[TLS_MASTER_SECRET_LEN];
|
||||
|
||||
u8 alert_level;
|
||||
u8 alert_description;
|
||||
|
||||
struct crypto_public_key *client_rsa_key;
|
||||
|
||||
struct tls_verify_hash verify;
|
||||
|
||||
#define MAX_CIPHER_COUNT 30
|
||||
u16 cipher_suites[MAX_CIPHER_COUNT];
|
||||
size_t num_cipher_suites;
|
||||
|
||||
u16 cipher_suite;
|
||||
|
||||
struct tlsv1_credentials *cred;
|
||||
|
||||
int verify_peer;
|
||||
u16 client_version;
|
||||
|
||||
u8 *session_ticket;
|
||||
size_t session_ticket_len;
|
||||
|
||||
tlsv1_server_session_ticket_cb session_ticket_cb;
|
||||
void *session_ticket_cb_ctx;
|
||||
|
||||
int use_session_ticket;
|
||||
|
||||
u8 *dh_secret;
|
||||
size_t dh_secret_len;
|
||||
};
|
||||
|
||||
|
||||
void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
|
||||
int tlsv1_server_derive_keys(struct tlsv1_server *conn,
|
||||
const u8 *pre_master_secret,
|
||||
size_t pre_master_secret_len);
|
||||
u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
|
||||
u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
|
||||
u8 description, size_t *out_len);
|
||||
int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
|
||||
const u8 *buf, size_t *len);
|
||||
|
||||
#endif /* TLSV1_SERVER_I_H */
|
123
tools/sdk/include/wpa_supplicant/wpa2/tls/x509v3.h
Normal file
123
tools/sdk/include/wpa_supplicant/wpa2/tls/x509v3.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* X.509v3 certificate parsing and processing
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef X509V3_H
|
||||
#define X509V3_H
|
||||
|
||||
#include "asn1.h"
|
||||
|
||||
struct x509_algorithm_identifier {
|
||||
struct asn1_oid oid;
|
||||
};
|
||||
|
||||
struct x509_name_attr {
|
||||
enum x509_name_attr_type {
|
||||
X509_NAME_ATTR_NOT_USED,
|
||||
X509_NAME_ATTR_DC,
|
||||
X509_NAME_ATTR_CN,
|
||||
X509_NAME_ATTR_C,
|
||||
X509_NAME_ATTR_L,
|
||||
X509_NAME_ATTR_ST,
|
||||
X509_NAME_ATTR_O,
|
||||
X509_NAME_ATTR_OU
|
||||
} type;
|
||||
char *value;
|
||||
};
|
||||
|
||||
#define X509_MAX_NAME_ATTRIBUTES 20
|
||||
|
||||
struct x509_name {
|
||||
struct x509_name_attr attr[X509_MAX_NAME_ATTRIBUTES];
|
||||
size_t num_attr;
|
||||
char *email; /* emailAddress */
|
||||
|
||||
/* from alternative name extension */
|
||||
char *alt_email; /* rfc822Name */
|
||||
char *dns; /* dNSName */
|
||||
char *uri; /* uniformResourceIdentifier */
|
||||
u8 *ip; /* iPAddress */
|
||||
size_t ip_len; /* IPv4: 4, IPv6: 16 */
|
||||
struct asn1_oid rid; /* registeredID */
|
||||
};
|
||||
|
||||
struct x509_certificate {
|
||||
struct x509_certificate *next;
|
||||
enum { X509_CERT_V1 = 0, X509_CERT_V2 = 1, X509_CERT_V3 = 2 } version;
|
||||
unsigned long serial_number;
|
||||
struct x509_algorithm_identifier signature;
|
||||
struct x509_name issuer;
|
||||
struct x509_name subject;
|
||||
os_time_t not_before;
|
||||
os_time_t not_after;
|
||||
struct x509_algorithm_identifier public_key_alg;
|
||||
u8 *public_key;
|
||||
size_t public_key_len;
|
||||
struct x509_algorithm_identifier signature_alg;
|
||||
u8 *sign_value;
|
||||
size_t sign_value_len;
|
||||
|
||||
/* Extensions */
|
||||
unsigned int extensions_present;
|
||||
#define X509_EXT_BASIC_CONSTRAINTS (1 << 0)
|
||||
#define X509_EXT_PATH_LEN_CONSTRAINT (1 << 1)
|
||||
#define X509_EXT_KEY_USAGE (1 << 2)
|
||||
#define X509_EXT_SUBJECT_ALT_NAME (1 << 3)
|
||||
#define X509_EXT_ISSUER_ALT_NAME (1 << 4)
|
||||
|
||||
/* BasicConstraints */
|
||||
int ca; /* cA */
|
||||
unsigned long path_len_constraint; /* pathLenConstraint */
|
||||
|
||||
/* KeyUsage */
|
||||
unsigned long key_usage;
|
||||
#define X509_KEY_USAGE_DIGITAL_SIGNATURE (1 << 0)
|
||||
#define X509_KEY_USAGE_NON_REPUDIATION (1 << 1)
|
||||
#define X509_KEY_USAGE_KEY_ENCIPHERMENT (1 << 2)
|
||||
#define X509_KEY_USAGE_DATA_ENCIPHERMENT (1 << 3)
|
||||
#define X509_KEY_USAGE_KEY_AGREEMENT (1 << 4)
|
||||
#define X509_KEY_USAGE_KEY_CERT_SIGN (1 << 5)
|
||||
#define X509_KEY_USAGE_CRL_SIGN (1 << 6)
|
||||
#define X509_KEY_USAGE_ENCIPHER_ONLY (1 << 7)
|
||||
#define X509_KEY_USAGE_DECIPHER_ONLY (1 << 8)
|
||||
|
||||
/*
|
||||
* The DER format certificate follows struct x509_certificate. These
|
||||
* pointers point to that buffer.
|
||||
*/
|
||||
const u8 *cert_start;
|
||||
size_t cert_len;
|
||||
const u8 *tbs_cert_start;
|
||||
size_t tbs_cert_len;
|
||||
};
|
||||
|
||||
enum {
|
||||
X509_VALIDATE_OK,
|
||||
X509_VALIDATE_BAD_CERTIFICATE,
|
||||
X509_VALIDATE_UNSUPPORTED_CERTIFICATE,
|
||||
X509_VALIDATE_CERTIFICATE_REVOKED,
|
||||
X509_VALIDATE_CERTIFICATE_EXPIRED,
|
||||
X509_VALIDATE_CERTIFICATE_UNKNOWN,
|
||||
X509_VALIDATE_UNKNOWN_CA
|
||||
};
|
||||
|
||||
void x509_certificate_free(struct x509_certificate *cert);
|
||||
struct x509_certificate * x509_certificate_parse(const u8 *buf, size_t len);
|
||||
void x509_name_string(struct x509_name *name, char *buf, size_t len);
|
||||
int x509_name_compare(struct x509_name *a, struct x509_name *b);
|
||||
void x509_certificate_chain_free(struct x509_certificate *cert);
|
||||
int x509_certificate_check_signature(struct x509_certificate *issuer,
|
||||
struct x509_certificate *cert);
|
||||
int x509_certificate_chain_validate(struct x509_certificate *trusted,
|
||||
struct x509_certificate *chain,
|
||||
int *reason, int disable_time_checks);
|
||||
struct x509_certificate *
|
||||
x509_certificate_get_subject(struct x509_certificate *chain,
|
||||
struct x509_name *name);
|
||||
int x509_certificate_self_signed(struct x509_certificate *cert);
|
||||
|
||||
#endif /* X509V3_H */
|
Reference in New Issue
Block a user