mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-03 19:49:09 +08:00
feat(wpa2): add wpa2_enterprise to esp8266
This commit is contained in:
@ -112,7 +112,7 @@ int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
*/
|
||||
int fast_sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len,
|
||||
uint8_t *mac);
|
||||
|
||||
|
||||
/**
|
||||
* des_encrypt - Encrypt one block with DES
|
||||
* @clear: 8 octets (in)
|
||||
@ -189,6 +189,21 @@ struct crypto_hash;
|
||||
struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
|
||||
size_t key_len);
|
||||
|
||||
/**
|
||||
* fast_crypto_hash_init - Initialize hash/HMAC function
|
||||
* @alg: Hash algorithm
|
||||
* @key: Key for keyed hash (e.g., HMAC) or %NULL if not needed
|
||||
* @key_len: Length of the key in bytes
|
||||
* Returns: Pointer to hash context to use with other hash functions or %NULL
|
||||
* on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_hash * fast_crypto_hash_init(enum crypto_hash_alg alg, const uint8_t *key,
|
||||
size_t key_len);
|
||||
|
||||
/**
|
||||
* crypto_hash_update - Add data to hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
@ -201,6 +216,18 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
|
||||
*/
|
||||
void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
|
||||
|
||||
/**
|
||||
* fast_crypto_hash_update - Add data to hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
* @data: Data buffer to add
|
||||
* @len: Length of the buffer
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void fast_crypto_hash_update(struct crypto_hash *ctx, const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_hash_finish - Complete hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
@ -220,6 +247,25 @@ void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
|
||||
*/
|
||||
int crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
|
||||
|
||||
/**
|
||||
* fast_crypto_hash_finish - Complete hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
* @hash: Buffer for hash value or %NULL if caller is just freeing the hash
|
||||
* context
|
||||
* @len: Pointer to length of the buffer or %NULL if caller is just freeing the
|
||||
* hash context; on return, this is set to the actual length of the hash value
|
||||
* Returns: 0 on success, -1 if buffer is too small (len set to needed length),
|
||||
* or -2 on other failures (including failed crypto_hash_update() operations)
|
||||
*
|
||||
* This function calculates the hash value and frees the context buffer that
|
||||
* was used for hash calculation.
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int fast_crypto_hash_finish(struct crypto_hash *ctx, uint8_t *hash, size_t *len);
|
||||
|
||||
|
||||
enum crypto_cipher_alg {
|
||||
CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
|
||||
@ -245,6 +291,22 @@ struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
|
||||
const u8 *iv, const u8 *key,
|
||||
size_t key_len);
|
||||
|
||||
/**
|
||||
* fast_crypto_cipher_init - Initialize block/stream cipher function
|
||||
* @alg: Cipher algorithm
|
||||
* @iv: Initialization vector for block ciphers or %NULL for stream ciphers
|
||||
* @key: Cipher key
|
||||
* @key_len: Length of key in bytes
|
||||
* Returns: Pointer to cipher context to use with other cipher functions or
|
||||
* %NULL on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_cipher * fast_crypto_cipher_init(enum crypto_cipher_alg alg,
|
||||
const uint8_t *iv, const uint8_t *key,
|
||||
size_t key_len);
|
||||
/**
|
||||
* crypto_cipher_encrypt - Cipher encrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
@ -260,6 +322,21 @@ struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
|
||||
int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
|
||||
const u8 *plain, u8 *crypt, size_t len);
|
||||
|
||||
/**
|
||||
* fast_crypto_cipher_encrypt - Cipher encrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
* @plain: Plaintext to cipher
|
||||
* @crypt: Resulting ciphertext
|
||||
* @len: Length of the plaintext
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check fast_crypto_cipher_encrypt(struct crypto_cipher *ctx,
|
||||
const uint8_t *plain, uint8_t *crypt, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_cipher_decrypt - Cipher decrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
@ -275,6 +352,21 @@ int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
|
||||
int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
|
||||
const u8 *crypt, u8 *plain, size_t len);
|
||||
|
||||
/**
|
||||
* fast_crypto_cipher_decrypt - Cipher decrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
* @crypt: Ciphertext to decrypt
|
||||
* @plain: Resulting plaintext
|
||||
* @len: Length of the cipher text
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check fast_crypto_cipher_decrypt(struct crypto_cipher *ctx,
|
||||
const uint8_t *crypt, uint8_t *plain, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_cipher_decrypt - Free cipher context
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
@ -285,6 +377,15 @@ int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
|
||||
*/
|
||||
void crypto_cipher_deinit(struct crypto_cipher *ctx);
|
||||
|
||||
/**
|
||||
* fast_crypto_cipher_decrypt - Free cipher context
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void fast_crypto_cipher_deinit(struct crypto_cipher *ctx);
|
||||
|
||||
struct crypto_public_key;
|
||||
struct crypto_private_key;
|
||||
@ -505,4 +606,363 @@ int __must_check fast_crypto_mod_exp(const uint8_t *base, size_t base_len,
|
||||
int rc4_skip(const u8 *key, size_t keylen, size_t skip,
|
||||
u8 *data, size_t data_len);
|
||||
|
||||
|
||||
/**
|
||||
* crypto_get_random - Generate cryptographically strong pseudy-random bytes
|
||||
* @buf: Buffer for data
|
||||
* @len: Number of bytes to generate
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* If the PRNG does not have enough entropy to ensure unpredictable byte
|
||||
* sequence, this functions must return -1.
|
||||
*/
|
||||
int crypto_get_random(void *buf, size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* struct crypto_bignum - bignum
|
||||
*
|
||||
* Internal data structure for bignum implementation. The contents is specific
|
||||
* to the used crypto library.
|
||||
*/
|
||||
struct crypto_bignum;
|
||||
|
||||
/**
|
||||
* crypto_bignum_init - Allocate memory for bignum
|
||||
* Returns: Pointer to allocated bignum or %NULL on failure
|
||||
*/
|
||||
struct crypto_bignum * crypto_bignum_init(void);
|
||||
|
||||
/**
|
||||
* crypto_bignum_init_set - Allocate memory for bignum and set the value
|
||||
* @buf: Buffer with unsigned binary value
|
||||
* @len: Length of buf in octets
|
||||
* Returns: Pointer to allocated bignum or %NULL on failure
|
||||
*/
|
||||
struct crypto_bignum * crypto_bignum_init_set(const u8 *buf, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_bignum_deinit - Free bignum
|
||||
* @n: Bignum from crypto_bignum_init() or crypto_bignum_init_set()
|
||||
* @clear: Whether to clear the value from memory
|
||||
*/
|
||||
void crypto_bignum_deinit(struct crypto_bignum *n, int clear);
|
||||
|
||||
/**
|
||||
* crypto_bignum_to_bin - Set binary buffer to unsigned bignum
|
||||
* @a: Bignum
|
||||
* @buf: Buffer for the binary number
|
||||
* @len: Length of @buf in octets
|
||||
* @padlen: Length in octets to pad the result to or 0 to indicate no padding
|
||||
* Returns: Number of octets written on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_to_bin(const struct crypto_bignum *a,
|
||||
u8 *buf, size_t buflen, size_t padlen);
|
||||
|
||||
/**
|
||||
* crypto_bignum_add - c = a + b
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result of a + b
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_add(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_mod - c = a % b
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result of a % b
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_mod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_exptmod - Modular exponentiation: d = a^b (mod c)
|
||||
* @a: Bignum; base
|
||||
* @b: Bignum; exponent
|
||||
* @c: Bignum; modulus
|
||||
* @d: Bignum; used to store the result of a^b (mod c)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_exptmod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
const struct crypto_bignum *c,
|
||||
struct crypto_bignum *d);
|
||||
|
||||
/**
|
||||
* crypto_bignum_inverse - Inverse a bignum so that a * c = 1 (mod b)
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_inverse(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_sub - c = a - b
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result of a - b
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_sub(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_div - c = a / b
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result of a / b
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_div(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_mulmod - d = a * b (mod c)
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum
|
||||
* @d: Bignum; used to store the result of (a * b) % c
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
const struct crypto_bignum *c,
|
||||
struct crypto_bignum *d);
|
||||
|
||||
/**
|
||||
* crypto_bignum_cmp - Compare two bignums
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* Returns: -1 if a < b, 0 if a == b, or 1 if a > b
|
||||
*/
|
||||
int crypto_bignum_cmp(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b);
|
||||
|
||||
/**
|
||||
* crypto_bignum_bits - Get size of a bignum in bits
|
||||
* @a: Bignum
|
||||
* Returns: Number of bits in the bignum
|
||||
*/
|
||||
int crypto_bignum_bits(const struct crypto_bignum *a);
|
||||
|
||||
/**
|
||||
* crypto_bignum_is_zero - Is the given bignum zero
|
||||
* @a: Bignum
|
||||
* Returns: 1 if @a is zero or 0 if not
|
||||
*/
|
||||
int crypto_bignum_is_zero(const struct crypto_bignum *a);
|
||||
|
||||
/**
|
||||
* crypto_bignum_is_one - Is the given bignum one
|
||||
* @a: Bignum
|
||||
* Returns: 1 if @a is one or 0 if not
|
||||
*/
|
||||
int crypto_bignum_is_one(const struct crypto_bignum *a);
|
||||
|
||||
/**
|
||||
* crypto_bignum_legendre - Compute the Legendre symbol (a/p)
|
||||
* @a: Bignum
|
||||
* @p: Bignum
|
||||
* Returns: Legendre symbol -1,0,1 on success; -2 on calculation failure
|
||||
*/
|
||||
int crypto_bignum_legendre(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *p);
|
||||
|
||||
|
||||
/**
|
||||
* struct crypto_ec - Elliptic curve context
|
||||
*
|
||||
* Internal data structure for EC implementation. The contents is specific
|
||||
* to the used crypto library.
|
||||
*/
|
||||
struct crypto_ec;
|
||||
|
||||
/**
|
||||
* crypto_ec_init - Initialize elliptic curve context
|
||||
* @group: Identifying number for the ECC group (IANA "Group Description"
|
||||
* attribute registrty for RFC 2409)
|
||||
* Returns: Pointer to EC context or %NULL on failure
|
||||
*/
|
||||
struct crypto_ec * crypto_ec_init(int group);
|
||||
|
||||
/**
|
||||
* crypto_ec_deinit - Deinitialize elliptic curve context
|
||||
* @e: EC context from crypto_ec_init()
|
||||
*/
|
||||
void crypto_ec_deinit(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* crypto_ec_prime_len - Get length of the prime in octets
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* Returns: Length of the prime defining the group
|
||||
*/
|
||||
size_t crypto_ec_prime_len(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* crypto_ec_prime_len_bits - Get length of the prime in bits
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* Returns: Length of the prime defining the group in bits
|
||||
*/
|
||||
size_t crypto_ec_prime_len_bits(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* crypto_ec_get_prime - Get prime defining an EC group
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* Returns: Prime (bignum) defining the group
|
||||
*/
|
||||
const struct crypto_bignum * crypto_ec_get_prime(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* crypto_ec_get_order - Get order of an EC group
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* Returns: Order (bignum) of the group
|
||||
*/
|
||||
const struct crypto_bignum * crypto_ec_get_order(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* struct crypto_ec_point - Elliptic curve point
|
||||
*
|
||||
* Internal data structure for EC implementation to represent a point. The
|
||||
* contents is specific to the used crypto library.
|
||||
*/
|
||||
struct crypto_ec_point;
|
||||
|
||||
/**
|
||||
* crypto_ec_point_init - Initialize data for an EC point
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* Returns: Pointer to EC point data or %NULL on failure
|
||||
*/
|
||||
struct crypto_ec_point * crypto_ec_point_init(struct crypto_ec *e);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_deinit - Deinitialize EC point data
|
||||
* @p: EC point data from crypto_ec_point_init()
|
||||
* @clear: Whether to clear the EC point value from memory
|
||||
*/
|
||||
void crypto_ec_point_deinit(struct crypto_ec_point *p, int clear);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_to_bin - Write EC point value as binary data
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point data from crypto_ec_point_init()
|
||||
* @x: Buffer for writing the binary data for x coordinate or %NULL if not used
|
||||
* @y: Buffer for writing the binary data for y coordinate or %NULL if not used
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function can be used to write an EC point as binary data in a format
|
||||
* that has the x and y coordinates in big endian byte order fields padded to
|
||||
* the length of the prime defining the group.
|
||||
*/
|
||||
int crypto_ec_point_to_bin(struct crypto_ec *e,
|
||||
const struct crypto_ec_point *point, u8 *x, u8 *y);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_from_bin - Create EC point from binary data
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @val: Binary data to read the EC point from
|
||||
* Returns: Pointer to EC point data or %NULL on failure
|
||||
*
|
||||
* This function readers x and y coordinates of the EC point from the provided
|
||||
* buffer assuming the values are in big endian byte order with fields padded to
|
||||
* the length of the prime defining the group.
|
||||
*/
|
||||
struct crypto_ec_point * crypto_ec_point_from_bin(struct crypto_ec *e,
|
||||
const u8 *val);
|
||||
|
||||
/**
|
||||
* crypto_bignum_add - c = a + b
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @a: Bignum
|
||||
* @b: Bignum
|
||||
* @c: Bignum; used to store the result of a + b
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_ec_point_add(struct crypto_ec *e, const struct crypto_ec_point *a,
|
||||
const struct crypto_ec_point *b,
|
||||
struct crypto_ec_point *c);
|
||||
|
||||
/**
|
||||
* crypto_bignum_mul - res = b * p
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point
|
||||
* @b: Bignum
|
||||
* @res: EC point; used to store the result of b * p
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_ec_point_mul(struct crypto_ec *e, const struct crypto_ec_point *p,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_ec_point *res);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_invert - Compute inverse of an EC point
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point to invert (and result of the operation)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_ec_point_invert(struct crypto_ec *e, struct crypto_ec_point *p);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_solve_y_coord - Solve y coordinate for an x coordinate
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point to use for the returning the result
|
||||
* @x: x coordinate
|
||||
* @y_bit: y-bit (0 or 1) for selecting the y value to use
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int crypto_ec_point_solve_y_coord(struct crypto_ec *e,
|
||||
struct crypto_ec_point *p,
|
||||
const struct crypto_bignum *x, int y_bit);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_compute_y_sqr - Compute y^2 = x^3 + ax + b
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @x: x coordinate
|
||||
* Returns: y^2 on success, %NULL failure
|
||||
*/
|
||||
struct crypto_bignum *
|
||||
crypto_ec_point_compute_y_sqr(struct crypto_ec *e,
|
||||
const struct crypto_bignum *x);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_is_at_infinity - Check whether EC point is neutral element
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point
|
||||
* Returns: 1 if the specified EC point is the neutral element of the group or
|
||||
* 0 if not
|
||||
*/
|
||||
int crypto_ec_point_is_at_infinity(struct crypto_ec *e,
|
||||
const struct crypto_ec_point *p);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_is_on_curve - Check whether EC point is on curve
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @p: EC point
|
||||
* Returns: 1 if the specified EC point is on the curve or 0 if not
|
||||
*/
|
||||
int crypto_ec_point_is_on_curve(struct crypto_ec *e,
|
||||
const struct crypto_ec_point *p);
|
||||
|
||||
/**
|
||||
* crypto_ec_point_cmp - Compare two EC points
|
||||
* @e: EC context from crypto_ec_init()
|
||||
* @a: EC point
|
||||
* @b: EC point
|
||||
* Returns: 0 on equal, non-zero otherwise
|
||||
*/
|
||||
int crypto_ec_point_cmp(const struct crypto_ec *e,
|
||||
const struct crypto_ec_point *a,
|
||||
const struct crypto_ec_point *b);
|
||||
|
||||
|
||||
#endif /* CRYPTO_H */
|
||||
|
60
components/wpa_supplicant/include/crypto/ms_funcs.h
Normal file
60
components/wpa_supplicant/include/crypto/ms_funcs.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* WPA Supplicant / shared MSCHAPV2 helper functions
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MS_FUNCS_H
|
||||
#define MS_FUNCS_H
|
||||
|
||||
int generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *password, size_t password_len,
|
||||
u8 *response);
|
||||
|
||||
int generate_nt_response_pwhash(const u8 *auth_challenge,
|
||||
const u8 *peer_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *password_hash,
|
||||
u8 *response);
|
||||
int generate_authenticator_response(const u8 *password, size_t password_len,
|
||||
const u8 *peer_challenge,
|
||||
const u8 *auth_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *nt_response, u8 *response);
|
||||
int generate_authenticator_response_pwhash(
|
||||
const u8 *password_hash,
|
||||
const u8 *peer_challenge, const u8 *auth_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *nt_response, u8 *response);
|
||||
int nt_challenge_response(const u8 *challenge, const u8 *password,
|
||||
size_t password_len, u8 *response);
|
||||
|
||||
void challenge_response(const u8 *challenge, const u8 *password_hash,
|
||||
u8 *response);
|
||||
int nt_password_hash(const u8 *password, size_t password_len,
|
||||
u8 *password_hash);
|
||||
int hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash);
|
||||
int get_master_key(const u8 *password_hash_hash, const u8 *nt_response,
|
||||
u8 *master_key);
|
||||
int get_asymetric_start_key(const u8 *master_key, u8 *session_key,
|
||||
size_t session_key_len, int is_send,
|
||||
int is_server);
|
||||
int encrypt_pw_block_with_password_hash(
|
||||
const u8 *password, size_t password_len,
|
||||
const u8 *password_hash, u8 *pw_block);
|
||||
int __must_check encry_pw_block_with_password_hash(
|
||||
const u8 *password, size_t password_len,
|
||||
const u8 *password_hash, u8 *pw_block);
|
||||
int __must_check new_password_encrypted_with_old_nt_password_hash(
|
||||
const u8 *new_password, size_t new_password_len,
|
||||
const u8 *old_password, size_t old_password_len,
|
||||
u8 *encrypted_pw_block);
|
||||
void nt_password_hash_encrypted_with_block(const u8 *password_hash,
|
||||
const u8 *block, u8 *cypher);
|
||||
int old_nt_password_hash_encrypted_with_new_nt_password_hash(
|
||||
const u8 *new_password, size_t new_password_len,
|
||||
const u8 *old_password, size_t old_password_len,
|
||||
u8 *encrypted_password_hash);
|
||||
|
||||
#endif /* MS_FUNCS_H */
|
@ -309,6 +309,7 @@ TCHAR * wpa_strdup_tchar(const char *str);
|
||||
|
||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
||||
char * wpa_config_parse_string(const char *value, size_t *len);
|
||||
char * dup_binstr(const void *src, size_t len);
|
||||
|
||||
static inline int is_zero_ether_addr(const u8 *a)
|
||||
{
|
||||
|
@ -104,15 +104,15 @@ struct wpa_sm {
|
||||
uint8_t flags;
|
||||
|
||||
void (* sendto) (u8 *wpadata, u16 wpadatalen);
|
||||
void (*config_assoc_ie) (uint8 proto, u8 *assoc_buf, u32 assoc_wpa_ie_len);
|
||||
void (*install_ppkey) (enum wpa_alg alg, uint8 *addr, int key_idx, int set_tx,
|
||||
uint8 *seq, size_t seq_len, uint8 *key, size_t key_len, int key_entry_valid);
|
||||
int (*get_ppkey) (uint8 *ifx, int *alg, uint8 *addr, int *key_idx,
|
||||
uint8 *key, size_t key_len, int key_entry_valid);
|
||||
void (*wpa_deauthenticate)(uint8 reason_code);
|
||||
void (*config_assoc_ie) (uint8_t proto, u8 *assoc_buf, u32 assoc_wpa_ie_len);
|
||||
void (*install_ppkey) (enum wpa_alg alg, uint8_t *addr, int key_idx, int set_tx,
|
||||
uint8_t *seq, size_t seq_len, uint8_t *key, size_t key_len, int key_entry_valid);
|
||||
int (*get_ppkey) (uint8_t *ifx, int *alg, uint8_t *addr, int *key_idx,
|
||||
uint8_t *key, size_t key_len, int key_entry_valid);
|
||||
void (*wpa_deauthenticate)(uint8_t reason_code);
|
||||
void (*wpa_neg_complete)();
|
||||
struct wpa_gtk_data gd; //used for calllback save param
|
||||
uint16 key_info; //used for txcallback param
|
||||
uint16_t key_info; //used for txcallback param
|
||||
};
|
||||
|
||||
struct l2_ethhdr {
|
||||
@ -188,12 +188,12 @@ struct l2_ethhdr {
|
||||
|
||||
#define KEYENTRY_TABLE_MAP(key_entry_valid) ((key_entry_valid)%5)
|
||||
|
||||
void pp_michael_mic_failure(uint16 isunicast);
|
||||
void pp_michael_mic_failure(uint16_t isunicast);
|
||||
|
||||
void wpa_sm_set_state(enum wpa_states state);
|
||||
|
||||
int ppGetKey(uint8 *ifx, int *alg, uint8 *addr, int *key_idx,
|
||||
uint8 *key, size_t key_len, int key_entry_valid);
|
||||
int ppGetKey(uint8_t *ifx, int *alg, uint8_t *addr, int *key_idx,
|
||||
uint8_t *key, size_t key_len, int key_entry_valid);
|
||||
|
||||
#endif /* WPA_H */
|
||||
|
||||
|
54
components/wpa_supplicant/include/wpa2/eap_peer/eap.h
Normal file
54
components/wpa_supplicant/include/wpa2/eap_peer/eap.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* EAP peer state machine functions (RFC 4137)
|
||||
* Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_H
|
||||
#define EAP_H
|
||||
|
||||
#include "wpa/defs.h"
|
||||
#include "wpa2/eap_peer/eap_defs.h"
|
||||
|
||||
struct eap_sm;
|
||||
|
||||
struct eap_method_type {
|
||||
int vendor;
|
||||
EapType method;
|
||||
};
|
||||
|
||||
u8 *g_wpa_anonymous_identity;
|
||||
int g_wpa_anonymous_identity_len;
|
||||
u8 *g_wpa_username;
|
||||
int g_wpa_username_len;
|
||||
const u8 *g_wpa_client_cert;
|
||||
int g_wpa_client_cert_len;
|
||||
const u8 *g_wpa_private_key;
|
||||
int g_wpa_private_key_len;
|
||||
const u8 *g_wpa_private_key_passwd;
|
||||
int g_wpa_private_key_passwd_len;
|
||||
|
||||
const u8 *g_wpa_ca_cert;
|
||||
int g_wpa_ca_cert_len;
|
||||
|
||||
u8 *g_wpa_password;
|
||||
int g_wpa_password_len;
|
||||
|
||||
u8 *g_wpa_new_password;
|
||||
int g_wpa_new_password_len;
|
||||
|
||||
const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
|
||||
void eap_deinit_prev_method(struct eap_sm *sm, const char *txt);
|
||||
struct wpabuf * eap_sm_build_nak(struct eap_sm *sm, EapType type, u8 id);
|
||||
int eap_peer_blob_init(struct eap_sm *sm);
|
||||
void eap_peer_blob_deinit(struct eap_sm *sm);
|
||||
int eap_peer_config_init(
|
||||
struct eap_sm *sm, u8 *private_key_passwd,
|
||||
int private_key_passwd_len);
|
||||
void eap_peer_config_deinit(struct eap_sm *sm);
|
||||
void eap_sm_abort(struct eap_sm *sm);
|
||||
int eap_peer_register_methods(void);
|
||||
|
||||
#endif /* EAP_H */
|
23
components/wpa_supplicant/include/wpa2/eap_peer/eap_common.h
Normal file
23
components/wpa_supplicant/include/wpa2/eap_peer/eap_common.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* EAP common peer/server definitions
|
||||
* Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_COMMON_H
|
||||
#define EAP_COMMON_H
|
||||
|
||||
#include "wpa/wpabuf.h"
|
||||
|
||||
int eap_hdr_len_valid(const struct wpabuf *msg, size_t min_payload);
|
||||
const u8 * eap_hdr_validate(int vendor, EapType eap_type,
|
||||
const struct wpabuf *msg, size_t *plen);
|
||||
struct wpabuf * eap_msg_alloc(int vendor, EapType type, size_t payload_len,
|
||||
u8 code, u8 identifier);
|
||||
void eap_update_len(struct wpabuf *msg);
|
||||
u8 eap_get_id(const struct wpabuf *msg);
|
||||
EapType eap_get_type(const struct wpabuf *msg);
|
||||
|
||||
#endif /* EAP_COMMON_H */
|
249
components/wpa_supplicant/include/wpa2/eap_peer/eap_config.h
Normal file
249
components/wpa_supplicant/include/wpa2/eap_peer/eap_config.h
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* EAP peer configuration data
|
||||
* Copyright (c) 2003-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_CONFIG_H
|
||||
#define EAP_CONFIG_H
|
||||
|
||||
/**
|
||||
* struct eap_peer_config - EAP peer configuration/credentials
|
||||
*/
|
||||
struct eap_peer_config {
|
||||
/**
|
||||
* identity - EAP Identity
|
||||
*
|
||||
* This field is used to set the real user identity or NAI (for
|
||||
* EAP-PSK/PAX/SAKE/GPSK).
|
||||
*/
|
||||
u8 *identity;
|
||||
|
||||
/**
|
||||
* identity_len - EAP Identity length
|
||||
*/
|
||||
size_t identity_len;
|
||||
|
||||
u8 *anonymous_identity;
|
||||
|
||||
size_t anonymous_identity_len;
|
||||
|
||||
/**
|
||||
* password - Password string for EAP
|
||||
*
|
||||
* This field can include either the plaintext password (default
|
||||
* option) or a NtPasswordHash (16-byte MD4 hash of the unicode
|
||||
* presentation of the password) if flags field has
|
||||
* EAP_CONFIG_FLAGS_PASSWORD_NTHASH bit set to 1. NtPasswordHash can
|
||||
* only be used with authentication mechanism that use this hash as the
|
||||
* starting point for operation: MSCHAP and MSCHAPv2 (EAP-MSCHAPv2,
|
||||
* EAP-TTLS/MSCHAPv2, EAP-TTLS/MSCHAP, LEAP).
|
||||
*
|
||||
* In addition, this field is used to configure a pre-shared key for
|
||||
* EAP-PSK/PAX/SAKE/GPSK. The length of the PSK must be 16 for EAP-PSK
|
||||
* and EAP-PAX and 32 for EAP-SAKE. EAP-GPSK can use a variable length
|
||||
* PSK.
|
||||
*/
|
||||
u8 *password;
|
||||
|
||||
/**
|
||||
* password_len - Length of password field
|
||||
*/
|
||||
size_t password_len;
|
||||
|
||||
/**
|
||||
* ca_cert - File path to CA certificate file (PEM/DER)
|
||||
*
|
||||
* This file can have one or more trusted CA certificates. If ca_cert
|
||||
* and ca_path are not included, server certificate will not be
|
||||
* verified. This is insecure and a trusted CA certificate should
|
||||
* always be configured when using EAP-TLS/TTLS/PEAP. Full path to the
|
||||
* file should be used since working directory may change when
|
||||
* wpa_supplicant is run in the background.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*
|
||||
* Alternatively, this can be used to only perform matching of the
|
||||
* server certificate (SHA-256 hash of the DER encoded X.509
|
||||
* certificate). In this case, the possible CA certificates in the
|
||||
* server certificate chain are ignored and only the server certificate
|
||||
* is verified. This is configured with the following format:
|
||||
* hash:://server/sha256/cert_hash_in_hex
|
||||
* For example: "hash://server/sha256/
|
||||
* 5a1bc1296205e6fdbe3979728efe3920798885c1c4590b5f90f43222d239ca6a"
|
||||
*
|
||||
* On Windows, trusted CA certificates can be loaded from the system
|
||||
* certificate store by setting this to cert_store://name, e.g.,
|
||||
* ca_cert="cert_store://CA" or ca_cert="cert_store://ROOT".
|
||||
* Note that when running wpa_supplicant as an application, the user
|
||||
* certificate store (My user account) is used, whereas computer store
|
||||
* (Computer account) is used when running wpasvc as a service.
|
||||
*/
|
||||
u8 *ca_cert;
|
||||
|
||||
/**
|
||||
* ca_path - Directory path for CA certificate files (PEM)
|
||||
*
|
||||
* This path may contain multiple CA certificates in OpenSSL format.
|
||||
* Common use for this is to point to system trusted CA list which is
|
||||
* often installed into directory like /etc/ssl/certs. If configured,
|
||||
* these certificates are added to the list of trusted CAs. ca_cert
|
||||
* may also be included in that case, but it is not required.
|
||||
*/
|
||||
u8 *ca_path;
|
||||
|
||||
/**
|
||||
* client_cert - File path to client certificate file (PEM/DER)
|
||||
*
|
||||
* This field is used with EAP method that use TLS authentication.
|
||||
* Usually, this is only configured for EAP-TLS, even though this could
|
||||
* in theory be used with EAP-TTLS and EAP-PEAP, too. Full path to the
|
||||
* file should be used since working directory may change when
|
||||
* wpa_supplicant is run in the background.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*/
|
||||
u8 *client_cert;
|
||||
|
||||
/**
|
||||
* private_key - File path to client private key file (PEM/DER/PFX)
|
||||
*
|
||||
* When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be
|
||||
* commented out. Both the private key and certificate will be read
|
||||
* from the PKCS#12 file in this case. Full path to the file should be
|
||||
* used since working directory may change when wpa_supplicant is run
|
||||
* in the background.
|
||||
*
|
||||
* Windows certificate store can be used by leaving client_cert out and
|
||||
* configuring private_key in one of the following formats:
|
||||
*
|
||||
* cert://substring_to_match
|
||||
*
|
||||
* hash://certificate_thumbprint_in_hex
|
||||
*
|
||||
* For example: private_key="hash://63093aa9c47f56ae88334c7b65a4"
|
||||
*
|
||||
* Note that when running wpa_supplicant as an application, the user
|
||||
* certificate store (My user account) is used, whereas computer store
|
||||
* (Computer account) is used when running wpasvc as a service.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*/
|
||||
u8 *private_key;
|
||||
|
||||
/**
|
||||
* private_key_passwd - Password for private key file
|
||||
*
|
||||
* If left out, this will be asked through control interface.
|
||||
*/
|
||||
u8 *private_key_passwd;
|
||||
|
||||
/**
|
||||
* Phase 2
|
||||
*/
|
||||
u8 *ca_cert2;
|
||||
|
||||
u8 *ca_path2;
|
||||
|
||||
u8 *client_cert2;
|
||||
|
||||
u8 *private_key2;
|
||||
|
||||
u8 *private_key2_password;
|
||||
|
||||
/**
|
||||
* eap_methods - Allowed EAP methods
|
||||
*/
|
||||
struct eap_method_type *eap_methods;
|
||||
|
||||
|
||||
char *phase1;
|
||||
|
||||
char *phase2;
|
||||
|
||||
/**
|
||||
* pin - PIN for USIM, GSM SIM, and smartcards
|
||||
*
|
||||
* This field is used to configure PIN for SIM and smartcards for
|
||||
* EAP-SIM and EAP-AKA. In addition, this is used with EAP-TLS if a
|
||||
* smartcard is used for private key operations.
|
||||
*
|
||||
* If left out, this will be asked through control interface.
|
||||
*/
|
||||
char *pin;
|
||||
|
||||
int mschapv2_retry;
|
||||
u8 *new_password;
|
||||
size_t new_password_len;
|
||||
|
||||
/**
|
||||
* fragment_size - Maximum EAP fragment size in bytes (default 1398)
|
||||
*
|
||||
* This value limits the fragment size for EAP methods that support
|
||||
* fragmentation (e.g., EAP-TLS and EAP-PEAP). This value should be set
|
||||
* small enough to make the EAP messages fit in MTU of the network
|
||||
* interface used for EAPOL. The default value is suitable for most
|
||||
* cases.
|
||||
*/
|
||||
int fragment_size;
|
||||
|
||||
#define EAP_CONFIG_FLAGS_PASSWORD_NTHASH BIT(0)
|
||||
#define EAP_CONFIG_FLAGS_EXT_PASSWORD BIT(1)
|
||||
/**
|
||||
* flags - Network configuration flags (bitfield)
|
||||
*
|
||||
* This variable is used for internal flags to describe further details
|
||||
* for the network parameters.
|
||||
* bit 0 = password is represented as a 16-byte NtPasswordHash value
|
||||
* instead of plaintext password
|
||||
* bit 1 = password is stored in external storage; the value in the
|
||||
* password field is the name of that external entry
|
||||
*/
|
||||
u32 flags;
|
||||
|
||||
/**
|
||||
* ocsp - Whether to use/require OCSP to check server certificate
|
||||
*
|
||||
* 0 = do not use OCSP stapling (TLS certificate status extension)
|
||||
* 1 = try to use OCSP stapling, but not require response
|
||||
* 2 = require valid OCSP stapling response
|
||||
*/
|
||||
int ocsp;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct wpa_config_blob - Named configuration blob
|
||||
*
|
||||
* This data structure is used to provide storage for binary objects to store
|
||||
* abstract information like certificates and private keys inlined with the
|
||||
* configuration data.
|
||||
*/
|
||||
struct wpa_config_blob {
|
||||
/**
|
||||
* name - Blob name
|
||||
*/
|
||||
char *name;
|
||||
|
||||
/**
|
||||
* data - Pointer to binary data
|
||||
*/
|
||||
const u8 *data;
|
||||
|
||||
/**
|
||||
* len - Length of binary data
|
||||
*/
|
||||
size_t len;
|
||||
|
||||
/**
|
||||
* next - Pointer to next blob in the configuration
|
||||
*/
|
||||
struct wpa_config_blob *next;
|
||||
};
|
||||
|
||||
#endif /* EAP_CONFIG_H */
|
92
components/wpa_supplicant/include/wpa2/eap_peer/eap_defs.h
Normal file
92
components/wpa_supplicant/include/wpa2/eap_peer/eap_defs.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* EAP server/peer: Shared EAP definitions
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_DEFS_H
|
||||
#define EAP_DEFS_H
|
||||
|
||||
/* RFC 3748 - Extensible Authentication Protocol (EAP) */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct eap_hdr {
|
||||
u8 code;
|
||||
u8 identifier;
|
||||
be16 length; /* including code and identifier; network byte order */
|
||||
/* followed by length-4 octets of data */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
enum { EAP_CODE_REQUEST = 1, EAP_CODE_RESPONSE = 2, EAP_CODE_SUCCESS = 3,
|
||||
EAP_CODE_FAILURE = 4 };
|
||||
|
||||
/* EAP Request and Response data begins with one octet Type. Success and
|
||||
* Failure do not have additional data. */
|
||||
|
||||
/*
|
||||
* EAP Method Types as allocated by IANA:
|
||||
* http://www.iana.org/assignments/eap-numbers
|
||||
*/
|
||||
typedef enum {
|
||||
EAP_TYPE_NONE = 0,
|
||||
EAP_TYPE_IDENTITY = 1 /* RFC 3748 */,
|
||||
EAP_TYPE_NOTIFICATION = 2 /* RFC 3748 */,
|
||||
EAP_TYPE_NAK = 3 /* Response only, RFC 3748 */,
|
||||
EAP_TYPE_MD5 = 4, /* RFC 3748 */
|
||||
EAP_TYPE_OTP = 5 /* RFC 3748 */,
|
||||
EAP_TYPE_GTC = 6, /* RFC 3748 */
|
||||
EAP_TYPE_TLS = 13 /* RFC 2716 */,
|
||||
EAP_TYPE_LEAP = 17 /* Cisco proprietary */,
|
||||
EAP_TYPE_SIM = 18 /* RFC 4186 */,
|
||||
EAP_TYPE_TTLS = 21 /* RFC 5281 */,
|
||||
EAP_TYPE_AKA = 23 /* RFC 4187 */,
|
||||
EAP_TYPE_PEAP = 25 /* draft-josefsson-pppext-eap-tls-eap-06.txt */,
|
||||
EAP_TYPE_MSCHAPV2 = 26 /* draft-kamath-pppext-eap-mschapv2-00.txt */,
|
||||
EAP_TYPE_TLV = 33 /* draft-josefsson-pppext-eap-tls-eap-07.txt */,
|
||||
EAP_TYPE_TNC = 38 /* TNC IF-T v1.0-r3; note: tentative assignment;
|
||||
* type 38 has previously been allocated for
|
||||
* EAP-HTTP Digest, (funk.com) */,
|
||||
EAP_TYPE_FAST = 43 /* RFC 4851 */,
|
||||
EAP_TYPE_PAX = 46 /* RFC 4746 */,
|
||||
EAP_TYPE_PSK = 47 /* RFC 4764 */,
|
||||
EAP_TYPE_SAKE = 48 /* RFC 4763 */,
|
||||
EAP_TYPE_IKEV2 = 49 /* RFC 5106 */,
|
||||
EAP_TYPE_AKA_PRIME = 50 /* RFC 5448 */,
|
||||
EAP_TYPE_GPSK = 51 /* RFC 5433 */,
|
||||
EAP_TYPE_PWD = 52 /* RFC 5931 */,
|
||||
EAP_TYPE_EKE = 53 /* RFC 6124 */,
|
||||
EAP_TYPE_EXPANDED = 254 /* RFC 3748 */
|
||||
} EapType;
|
||||
|
||||
|
||||
/* SMI Network Management Private Enterprise Code for vendor specific types */
|
||||
enum {
|
||||
EAP_VENDOR_IETF = 0,
|
||||
EAP_VENDOR_MICROSOFT = 0x000137 /* Microsoft */,
|
||||
EAP_VENDOR_WFA = 0x00372A /* Wi-Fi Alliance */,
|
||||
EAP_VENDOR_HOSTAP = 39068 /* hostapd/wpa_supplicant project */
|
||||
};
|
||||
|
||||
struct eap_expand {
|
||||
u8 vendor_id[3];
|
||||
be32 vendor_type;
|
||||
u8 opcode;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define EAP_VENDOR_UNAUTH_TLS EAP_VENDOR_HOSTAP
|
||||
#define EAP_VENDOR_TYPE_UNAUTH_TLS 1
|
||||
|
||||
#define EAP_MSK_LEN 64
|
||||
#define EAP_EMSK_LEN 64
|
||||
|
||||
#endif /* EAP_DEFS_H */
|
145
components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h
Normal file
145
components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* EAP peer state machines internal structures (RFC 4137)
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_I_H
|
||||
#define EAP_I_H
|
||||
|
||||
#include "wpa/wpabuf.h"
|
||||
#include "eap.h"
|
||||
#include "eap_common.h"
|
||||
#include "eap_config.h"
|
||||
#include "esp_wpa2.h"
|
||||
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
/* RFC 4137 - EAP Peer state machine */
|
||||
|
||||
typedef enum {
|
||||
DECISION_FAIL, DECISION_COND_SUCC, DECISION_UNCOND_SUCC
|
||||
} EapDecision;
|
||||
|
||||
typedef enum {
|
||||
METHOD_NONE, METHOD_INIT, METHOD_CONT, METHOD_MAY_CONT, METHOD_DONE
|
||||
} EapMethodState;
|
||||
|
||||
/**
|
||||
* struct eap_method_ret - EAP return values from struct eap_method::process()
|
||||
*
|
||||
* These structure contains OUT variables for the interface between peer state
|
||||
* machine and methods (RFC 4137, Sect. 4.2). eapRespData will be returned as
|
||||
* the return value of struct eap_method::process() so it is not included in
|
||||
* this structure.
|
||||
*/
|
||||
struct eap_method_ret {
|
||||
/**
|
||||
* ignore - Whether method decided to drop the current packed (OUT)
|
||||
*/
|
||||
Boolean ignore;
|
||||
|
||||
/**
|
||||
* methodState - Method-specific state (IN/OUT)
|
||||
*/
|
||||
EapMethodState methodState;
|
||||
|
||||
/**
|
||||
* decision - Authentication decision (OUT)
|
||||
*/
|
||||
EapDecision decision;
|
||||
|
||||
/**
|
||||
* allowNotifications - Whether method allows notifications (OUT)
|
||||
*/
|
||||
Boolean allowNotifications;
|
||||
};
|
||||
|
||||
struct eap_sm;
|
||||
|
||||
struct eap_method {
|
||||
/**
|
||||
* vendor -EAP Vendor-ID
|
||||
*/
|
||||
int vendor;
|
||||
|
||||
/**
|
||||
* method - EAP type number
|
||||
*/
|
||||
EapType method;
|
||||
|
||||
/**
|
||||
* name - Name of the method (e.g., "TLS")
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
struct eap_method *next;
|
||||
|
||||
void * (*init)(struct eap_sm *sm);
|
||||
void (*deinit)(struct eap_sm *sm, void *priv);
|
||||
struct wpabuf * (*process)(struct eap_sm *sm, void *priv,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData);
|
||||
bool (*isKeyAvailable)(struct eap_sm *sm, void *priv);
|
||||
u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
int (*get_status)(struct eap_sm *sm, void *priv, char *buf,
|
||||
size_t buflen, int verbose);
|
||||
const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
void (*free)(struct eap_method *method);
|
||||
bool (*has_reauth_data)(struct eap_sm *sm, void *priv);
|
||||
void (*deinit_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
void * (*init_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
};
|
||||
|
||||
#define CLIENT_CERT_NAME "CLC"
|
||||
#define CA_CERT_NAME "CAC"
|
||||
#define PRIVATE_KEY_NAME "PVK"
|
||||
#define BLOB_NAME_LEN 3
|
||||
#define BLOB_NUM 3
|
||||
|
||||
/**
|
||||
* struct eap_sm - EAP state machine data
|
||||
*/
|
||||
struct eap_sm {
|
||||
void *eap_method_priv;
|
||||
|
||||
void *ssl_ctx;
|
||||
|
||||
unsigned int workaround;
|
||||
/////////////////////////////////////////////////
|
||||
struct pbuf *outbuf;
|
||||
struct wpa_config_blob blob[BLOB_NUM];
|
||||
struct eap_peer_config config;
|
||||
u8 current_identifier;
|
||||
u8 ownaddr[ETH_ALEN];
|
||||
#ifdef USE_WPA2_TASK
|
||||
#define SIG_WPA2_NUM 2
|
||||
u8 wpa2_sig_cnt[SIG_WPA2_NUM];
|
||||
#endif
|
||||
u8 finish_state;
|
||||
|
||||
int init_phase2;
|
||||
bool peap_done;
|
||||
|
||||
u8 *eapKeyData;
|
||||
size_t eapKeyDataLen;
|
||||
struct wpabuf *lastRespData;
|
||||
const struct eap_method *m;
|
||||
};
|
||||
|
||||
//wpa2_crypto_funcs_t wpa2_crypto_funcs;
|
||||
|
||||
const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash);
|
||||
const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len);
|
||||
struct eap_peer_config * eap_get_config(struct eap_sm *sm);
|
||||
const struct wpa_config_blob * eap_get_config_blob(struct eap_sm *sm, const char *name);
|
||||
bool wifi_sta_get_enterprise_disable_time_check(void);
|
||||
|
||||
struct wpabuf * eap_sm_build_identity_resp(struct eap_sm *sm, u8 id, int encrypted);
|
||||
|
||||
#endif /* EAP_I_H */
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* EAP peer: Method registration
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_METHODS_H
|
||||
#define EAP_METHODS_H
|
||||
|
||||
#include "eap_defs.h"
|
||||
#include "eap_config.h"
|
||||
|
||||
const struct eap_method * eap_peer_get_eap_method(int vendor, EapType method);
|
||||
const struct eap_method * eap_peer_get_methods(size_t *count);
|
||||
|
||||
u32 eap_get_phase2_type(const char *name, int *vendor);
|
||||
struct eap_method_type * eap_get_phase2_types(struct eap_peer_config *config,
|
||||
size_t *count);
|
||||
|
||||
struct eap_method * eap_peer_method_alloc(int verdor, EapType method,
|
||||
const char *name);
|
||||
|
||||
void eap_peer_method_free(struct eap_method *method);
|
||||
int eap_peer_method_register(struct eap_method *method);
|
||||
|
||||
void eap_peer_unregister_methods(void);
|
||||
|
||||
//int eap_peer_md5_register(void);
|
||||
int eap_peer_tls_register(void);
|
||||
int eap_peer_peap_register(void);
|
||||
int eap_peer_ttls_register(void);
|
||||
int eap_peer_mschapv2_register(void);
|
||||
|
||||
void eap_peer_unregister_methods(void);
|
||||
int eap_peer_register_methods(void);
|
||||
|
||||
#endif /* EAP_METHODS_H */
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* EAP-PEAP common routines
|
||||
* Copyright (c) 2008-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_PEAP_COMMON_H
|
||||
#define EAP_PEAP_COMMON_H
|
||||
|
||||
int peap_prfplus(int version, const u8 *key, size_t key_len,
|
||||
const char *label, const u8 *seed, size_t seed_len,
|
||||
u8 *buf, size_t buf_len);
|
||||
|
||||
#endif /* EAP_PEAP_COMMON_H */
|
25
components/wpa_supplicant/include/wpa2/eap_peer/eap_tls.h
Normal file
25
components/wpa_supplicant/include/wpa2/eap_peer/eap_tls.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
|
||||
* Copyright (c) 2004-2009, 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLS_H
|
||||
#define EAP_TLS_H
|
||||
|
||||
#include "eap_i.h"
|
||||
#include "eap_common.h"
|
||||
#include "eap.h"
|
||||
#include "wpa/wpabuf.h"
|
||||
|
||||
void * eap_tls_init(struct eap_sm *sm);
|
||||
void eap_tls_deinit(struct eap_sm *sm, void *priv);
|
||||
struct wpabuf * eap_tls_process(struct eap_sm *sm, void *priv,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData);
|
||||
|
||||
u8 * eap_tls_getKey(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
#endif /* EAP_TLS_H */
|
131
components/wpa_supplicant/include/wpa2/eap_peer/eap_tls_common.h
Normal file
131
components/wpa_supplicant/include/wpa2/eap_peer/eap_tls_common.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
|
||||
* Copyright (c) 2004-2009, 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLS_COMMON_H
|
||||
#define EAP_TLS_COMMON_H
|
||||
|
||||
/**
|
||||
* struct eap_ssl_data - TLS data for EAP methods
|
||||
*/
|
||||
struct eap_ssl_data {
|
||||
/**
|
||||
* conn - TLS connection context data from tls_connection_init()
|
||||
*/
|
||||
struct tls_connection *conn;
|
||||
|
||||
/**
|
||||
* tls_out - TLS message to be sent out in fragments
|
||||
*/
|
||||
struct wpabuf *tls_out;
|
||||
|
||||
/**
|
||||
* tls_out_pos - The current position in the outgoing TLS message
|
||||
*/
|
||||
size_t tls_out_pos;
|
||||
|
||||
/**
|
||||
* tls_out_limit - Maximum fragment size for outgoing TLS messages
|
||||
*/
|
||||
size_t tls_out_limit;
|
||||
|
||||
/**
|
||||
* tls_in - Received TLS message buffer for re-assembly
|
||||
*/
|
||||
struct wpabuf *tls_in;
|
||||
|
||||
/**
|
||||
* tls_in_left - Number of remaining bytes in the incoming TLS message
|
||||
*/
|
||||
size_t tls_in_left;
|
||||
|
||||
/**
|
||||
* tls_in_total - Total number of bytes in the incoming TLS message
|
||||
*/
|
||||
size_t tls_in_total;
|
||||
|
||||
/**
|
||||
* phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
|
||||
*/
|
||||
int phase2;
|
||||
|
||||
/**
|
||||
* include_tls_length - Whether the TLS length field is included even
|
||||
* if the TLS data is not fragmented
|
||||
*/
|
||||
int include_tls_length;
|
||||
|
||||
/**
|
||||
* eap - EAP state machine allocated with eap_peer_sm_init()
|
||||
*/
|
||||
struct eap_sm *eap;
|
||||
|
||||
/**
|
||||
* ssl_ctx - TLS library context to use for the connection
|
||||
*/
|
||||
void *ssl_ctx;
|
||||
|
||||
/**
|
||||
* eap_type - EAP method used in Phase 1 (EAP_TYPE_TLS/PEAP/TTLS/FAST)
|
||||
*/
|
||||
u8 eap_type;
|
||||
};
|
||||
|
||||
|
||||
/* EAP TLS Flags */
|
||||
#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
|
||||
#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
|
||||
#define EAP_TLS_FLAGS_START 0x20
|
||||
#define EAP_TLS_VERSION_MASK 0x07
|
||||
|
||||
/* could be up to 128 bytes, but only the first 64 bytes are used */
|
||||
#define EAP_TLS_KEY_LEN 64
|
||||
|
||||
/* dummy type used as a flag for UNAUTH-TLS */
|
||||
#define EAP_UNAUTH_TLS_TYPE 255
|
||||
|
||||
|
||||
int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
struct eap_peer_config *config, u8 eap_type);
|
||||
void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
|
||||
u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
const char *label, size_t len);
|
||||
u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
|
||||
struct eap_ssl_data *data, u8 eap_type,
|
||||
size_t *len);
|
||||
int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
EapType eap_type, int peap_version,
|
||||
u8 id, const u8 *in_data, size_t in_len,
|
||||
struct wpabuf **out_data);
|
||||
struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type,
|
||||
int peap_version);
|
||||
int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data);
|
||||
int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
char *buf, size_t buflen, int verbose);
|
||||
const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
|
||||
struct eap_ssl_data *data,
|
||||
EapType eap_type,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData,
|
||||
size_t *len, u8 *flags);
|
||||
void eap_peer_tls_reset_input(struct eap_ssl_data *data);
|
||||
void eap_peer_tls_reset_output(struct eap_ssl_data *data);
|
||||
int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **in_decrypted);
|
||||
int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
EapType eap_type, int peap_version, u8 id,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **out_data);
|
||||
int eap_peer_select_phase2_methods(struct eap_peer_config *config,
|
||||
const char *prefix,
|
||||
struct eap_method_type **types,
|
||||
size_t *num_types);
|
||||
int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
|
||||
struct eap_hdr *hdr, struct wpabuf **resp);
|
||||
|
||||
#endif /* EAP_TLS_COMMON_H */
|
112
components/wpa_supplicant/include/wpa2/eap_peer/eap_tlv_common.h
Normal file
112
components/wpa_supplicant/include/wpa2/eap_peer/eap_tlv_common.h
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* EAP-TLV definitions (draft-josefsson-pppext-eap-tls-eap-10.txt)
|
||||
* Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLV_COMMON_H
|
||||
#define EAP_TLV_COMMON_H
|
||||
|
||||
/* EAP-TLV TLVs (draft-josefsson-ppext-eap-tls-eap-10.txt) */
|
||||
#define EAP_TLV_RESULT_TLV 3 /* Acknowledged Result */
|
||||
#define EAP_TLV_NAK_TLV 4
|
||||
#define EAP_TLV_ERROR_CODE_TLV 5
|
||||
#define EAP_TLV_CONNECTION_BINDING_TLV 6
|
||||
#define EAP_TLV_VENDOR_SPECIFIC_TLV 7
|
||||
#define EAP_TLV_URI_TLV 8
|
||||
#define EAP_TLV_EAP_PAYLOAD_TLV 9
|
||||
#define EAP_TLV_INTERMEDIATE_RESULT_TLV 10
|
||||
#define EAP_TLV_PAC_TLV 11 /* RFC 5422, Section 4.2 */
|
||||
#define EAP_TLV_CRYPTO_BINDING_TLV 12
|
||||
#define EAP_TLV_CALLING_STATION_ID_TLV 13
|
||||
#define EAP_TLV_CALLED_STATION_ID_TLV 14
|
||||
#define EAP_TLV_NAS_PORT_TYPE_TLV 15
|
||||
#define EAP_TLV_SERVER_IDENTIFIER_TLV 16
|
||||
#define EAP_TLV_IDENTITY_TYPE_TLV 17
|
||||
#define EAP_TLV_SERVER_TRUSTED_ROOT_TLV 18
|
||||
#define EAP_TLV_REQUEST_ACTION_TLV 19
|
||||
#define EAP_TLV_PKCS7_TLV 20
|
||||
|
||||
#define EAP_TLV_RESULT_SUCCESS 1
|
||||
#define EAP_TLV_RESULT_FAILURE 2
|
||||
|
||||
#define EAP_TLV_TYPE_MANDATORY 0x8000
|
||||
#define EAP_TLV_TYPE_MASK 0x3fff
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct eap_tlv_hdr {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_nak_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be32 vendor_id;
|
||||
be16 nak_type;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_result_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 status;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.7 - Intermediate-Result TLV */
|
||||
struct eap_tlv_intermediate_result_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 status;
|
||||
/* Followed by optional TLVs */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.8 - Crypto-Binding TLV */
|
||||
struct eap_tlv_crypto_binding_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
u8 reserved;
|
||||
u8 version;
|
||||
u8 received_version;
|
||||
u8 subtype;
|
||||
u8 nonce[32];
|
||||
u8 compound_mac[20];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_pac_ack_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 pac_type;
|
||||
be16 pac_len;
|
||||
be16 result;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.9 - Request-Action TLV */
|
||||
struct eap_tlv_request_action_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 action;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 5422, Section 4.2.6 - PAC-Type TLV */
|
||||
struct eap_tlv_pac_type_tlv {
|
||||
be16 tlv_type; /* PAC_TYPE_PAC_TYPE */
|
||||
be16 length;
|
||||
be16 pac_type;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define EAP_TLV_CRYPTO_BINDING_SUBTYPE_REQUEST 0
|
||||
#define EAP_TLV_CRYPTO_BINDING_SUBTYPE_RESPONSE 1
|
||||
|
||||
#define EAP_TLV_ACTION_PROCESS_TLV 1
|
||||
#define EAP_TLV_ACTION_NEGOTIATE_EAP 2
|
||||
|
||||
#endif /* EAP_TLV_COMMON_H */
|
65
components/wpa_supplicant/include/wpa2/eap_peer/eap_ttls.h
Normal file
65
components/wpa_supplicant/include/wpa2/eap_peer/eap_ttls.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* EAP server/peer: EAP-TTLS (RFC 5281)
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TTLS_H
|
||||
#define EAP_TTLS_H
|
||||
|
||||
struct ttls_avp {
|
||||
be32 avp_code;
|
||||
be32 avp_length; /* 8-bit flags, 24-bit length;
|
||||
* length includes AVP header */
|
||||
/* optional 32-bit Vendor-ID */
|
||||
/* Data */
|
||||
};
|
||||
|
||||
struct ttls_avp_vendor {
|
||||
be32 avp_code;
|
||||
be32 avp_length; /* 8-bit flags, 24-bit length;
|
||||
* length includes AVP header */
|
||||
be32 vendor_id;
|
||||
/* Data */
|
||||
};
|
||||
|
||||
#define AVP_FLAGS_VENDOR 0x80
|
||||
#define AVP_FLAGS_MANDATORY 0x40
|
||||
|
||||
#define AVP_PAD(start, pos) \
|
||||
do { \
|
||||
int __pad; \
|
||||
__pad = (4 - (((pos) - (start)) & 3)) & 3; \
|
||||
os_memset((pos), 0, __pad); \
|
||||
pos += __pad; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* RFC 2865 */
|
||||
#define RADIUS_ATTR_USER_NAME 1
|
||||
#define RADIUS_ATTR_USER_PASSWORD 2
|
||||
#define RADIUS_ATTR_CHAP_PASSWORD 3
|
||||
#define RADIUS_ATTR_REPLY_MESSAGE 18
|
||||
#define RADIUS_ATTR_CHAP_CHALLENGE 60
|
||||
#define RADIUS_ATTR_EAP_MESSAGE 79
|
||||
|
||||
/* RFC 2548 */
|
||||
#define RADIUS_VENDOR_ID_MICROSOFT 311
|
||||
#define RADIUS_ATTR_MS_CHAP_RESPONSE 1
|
||||
#define RADIUS_ATTR_MS_CHAP_ERROR 2
|
||||
#define RADIUS_ATTR_MS_CHAP_NT_ENC_PW 6
|
||||
#define RADIUS_ATTR_MS_CHAP_CHALLENGE 11
|
||||
#define RADIUS_ATTR_MS_CHAP2_RESPONSE 25
|
||||
#define RADIUS_ATTR_MS_CHAP2_SUCCESS 26
|
||||
#define RADIUS_ATTR_MS_CHAP2_CPW 27
|
||||
|
||||
#define EAP_TTLS_MSCHAPV2_CHALLENGE_LEN 16
|
||||
#define EAP_TTLS_MSCHAPV2_RESPONSE_LEN 50
|
||||
#define EAP_TTLS_MSCHAP_CHALLENGE_LEN 8
|
||||
#define EAP_TTLS_MSCHAP_RESPONSE_LEN 50
|
||||
#define EAP_TTLS_CHAP_CHALLENGE_LEN 16
|
||||
#define EAP_TTLS_CHAP_PASSWORD_LEN 16
|
||||
|
||||
#endif /* EAP_TTLS_H */
|
24
components/wpa_supplicant/include/wpa2/eap_peer/mschapv2.h
Normal file
24
components/wpa_supplicant/include/wpa2/eap_peer/mschapv2.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* MSCHAPV2
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MSCHAPV2_H
|
||||
#define MSCHAPV2_H
|
||||
|
||||
#define MSCHAPV2_CHAL_LEN 16
|
||||
#define MSCHAPV2_NT_RESPONSE_LEN 24
|
||||
#define MSCHAPV2_AUTH_RESPONSE_LEN 20
|
||||
#define MSCHAPV2_MASTER_KEY_LEN 16
|
||||
|
||||
const u8 * mschapv2_remove_domain(const u8 *username, size_t *len);
|
||||
int mschapv2_derive_response(const u8 *username, size_t username_len,
|
||||
const u8 *password, size_t password_len,
|
||||
int pwhash,
|
||||
const u8 *auth_challenge,
|
||||
const u8 *peer_challenge,
|
||||
u8 *nt_response, u8 *auth_response,
|
||||
u8 *master_key);
|
||||
int mschapv2_verify_auth_response(const u8 *auth_response,
|
||||
const u8 *buf, size_t buf_len);
|
||||
#endif /* MSCHAPV2_H */
|
66
components/wpa_supplicant/include/wpa2/tls/asn1.h
Normal file
66
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/bignum.h
Normal file
38
components/wpa_supplicant/include/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 */
|
3441
components/wpa_supplicant/include/wpa2/tls/libtommath.h
Normal file
3441
components/wpa_supplicant/include/wpa2/tls/libtommath.h
Normal file
File diff suppressed because it is too large
Load Diff
22
components/wpa_supplicant/include/wpa2/tls/pkcs1.h
Normal file
22
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/pkcs5.h
Normal file
16
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/pkcs8.h
Normal file
16
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/rsa.h
Normal file
23
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tls.h
Normal file
537
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_client.h
Normal file
54
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_client_i.h
Normal file
84
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_common.h
Normal file
261
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_cred.h
Normal file
40
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_record.h
Normal file
71
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_server.h
Normal file
48
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/tlsv1_server_i.h
Normal file
71
components/wpa_supplicant/include/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
components/wpa_supplicant/include/wpa2/tls/x509v3.h
Normal file
123
components/wpa_supplicant/include/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 */
|
17
components/wpa_supplicant/include/wpa2/utils/base64.h
Normal file
17
components/wpa_supplicant/include/wpa2/utils/base64.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Base64 encoding/decoding (RFC1341)
|
||||
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef BASE64_H
|
||||
#define BASE64_H
|
||||
|
||||
unsigned char * base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
unsigned char * base64_decode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
|
||||
#endif /* BASE64_H */
|
33
components/wpa_supplicant/include/wpa2/utils/ext_password.h
Normal file
33
components/wpa_supplicant/include/wpa2/utils/ext_password.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* External password backend
|
||||
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EXT_PASSWORD_H
|
||||
#define EXT_PASSWORD_H
|
||||
|
||||
struct ext_password_data;
|
||||
|
||||
#ifdef CONFIG_EXT_PASSWORD
|
||||
|
||||
struct ext_password_data * ext_password_init(const char *backend,
|
||||
const char *params);
|
||||
void ext_password_deinit(struct ext_password_data *data);
|
||||
|
||||
struct wpabuf * ext_password_get(struct ext_password_data *data,
|
||||
const char *name);
|
||||
void ext_password_free(struct wpabuf *pw);
|
||||
|
||||
#else /* CONFIG_EXT_PASSWORD */
|
||||
|
||||
#define ext_password_init(b, p)
|
||||
#define ext_password_deinit(d)
|
||||
#define ext_password_get(d, n)
|
||||
#define ext_password_free(p)
|
||||
|
||||
#endif /* CONFIG_EXT_PASSWORD */
|
||||
|
||||
#endif /* EXT_PASSWORD_H */
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* External password backend - internal definitions
|
||||
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EXT_PASSWORD_I_H
|
||||
#define EXT_PASSWORD_I_H
|
||||
|
||||
#include "ext_password.h"
|
||||
|
||||
struct ext_password_backend {
|
||||
const char *name;
|
||||
void * (*init)(const char *params);
|
||||
void (*deinit)(void *ctx);
|
||||
struct wpabuf * (*get)(void *ctx, const char *name);
|
||||
};
|
||||
|
||||
struct wpabuf * ext_password_alloc(size_t len);
|
||||
|
||||
#endif /* EXT_PASSWORD_I_H */
|
Reference in New Issue
Block a user