PHY ids for Broadcom 5755/5787
[dragonfly/vkernel-mp.git] / contrib / hostapd-0.4.9 / crypto.h
blobe664861afe717fc027216139dc98662203537287
1 /*
2 * WPA Supplicant / wrapper functions for crypto libraries
3 * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
14 * This file defines the cryptographic functions that need to be implemented
15 * for wpa_supplicant and hostapd. When TLS is not used, internal
16 * implementation of MD5, SHA1, and AES is used and no external libraries are
17 * required. When TLS is enabled (e.g., by enabling EAP-TLS or EAP-PEAP), the
18 * crypto library used by the TLS implementation is expected to be used for
19 * non-TLS needs, too, in order to save space by not implementing these
20 * functions twice.
22 * Wrapper code for using each crypto library is in its own file (crypto*.c)
23 * and one of these files is build and linked in to provide the functions
24 * defined here.
27 #ifndef CRYPTO_H
28 #define CRYPTO_H
30 /**
31 * md4_vector - MD4 hash for data vector
32 * @num_elem: Number of elements in the data vector
33 * @addr: Pointers to the data areas
34 * @len: Lengths of the data blocks
35 * @mac: Buffer for the hash
37 void md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
39 /**
40 * md5_vector - MD5 hash for data vector
41 * @num_elem: Number of elements in the data vector
42 * @addr: Pointers to the data areas
43 * @len: Lengths of the data blocks
44 * @mac: Buffer for the hash
46 void md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
48 /**
49 * sha1_vector - SHA-1 hash for data vector
50 * @num_elem: Number of elements in the data vector
51 * @addr: Pointers to the data areas
52 * @len: Lengths of the data blocks
53 * @mac: Buffer for the hash
55 void sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
56 u8 *mac);
58 /**
59 * sha1_transform - Perform one SHA-1 transform step
60 * @state: SHA-1 state
61 * @data: Input data for the SHA-1 transform
63 * This function is used to implement random number generation specified in
64 * NIST FIPS Publication 186-2 for EAP-SIM. This PRF uses a function that is
65 * similar to SHA-1, but has different message padding and as such, access to
66 * just part of the SHA-1 is needed.
68 void sha1_transform(u8 *state, const u8 data[64]);
70 /**
71 * des_encrypt - Encrypt one block with DES
72 * @clear: 8 octets (in)
73 * @key: 7 octets (in) (no parity bits included)
74 * @cypher: 8 octets (out)
76 void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
78 /**
79 * aes_encrypt_init - Initialize AES for encryption
80 * @key: Encryption key
81 * @len: Key length in bytes (usually 16, i.e., 128 bits)
82 * Returns: Pointer to context data or %NULL on failure
84 void * aes_encrypt_init(const u8 *key, size_t len);
86 /**
87 * aes_encrypt - Encrypt one AES block
88 * @ctx: Context pointer from aes_encrypt_init()
89 * @plain: Plaintext data to be encrypted (16 bytes)
90 * @crypt: Buffer for the encrypted data (16 bytes)
92 void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
94 /**
95 * aes_encrypt_deinit - Deinitialize AES encryption
96 * @ctx: Context pointer from aes_encrypt_init()
98 void aes_encrypt_deinit(void *ctx);
101 * aes_decrypt_init - Initialize AES for decryption
102 * @key: Decryption key
103 * @len: Key length in bytes (usually 16, i.e., 128 bits)
104 * Returns: Pointer to context data or %NULL on failure
106 void * aes_decrypt_init(const u8 *key, size_t len);
109 * aes_decrypt - Decrypt one AES block
110 * @ctx: Context pointer from aes_encrypt_init()
111 * @crypt: Encrypted data (16 bytes)
112 * @plain: Buffer for the decrypted data (16 bytes)
114 void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
117 * aes_decrypt_deinit - Deinitialize AES decryption
118 * @ctx: Context pointer from aes_encrypt_init()
120 void aes_decrypt_deinit(void *ctx);
123 #endif /* CRYPTO_H */