wpa_supplicant / hostapd 2.0

crypto.h

Go to the documentation of this file.
00001 
00022 #ifndef CRYPTO_H
00023 #define CRYPTO_H
00024 
00034 int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00035 
00045 int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00046 
00047 #ifdef CONFIG_FIPS
00048 
00057 int md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
00058                               const size_t *len, u8 *mac);
00059 #else /* CONFIG_FIPS */
00060 #define md5_vector_non_fips_allow md5_vector
00061 #endif /* CONFIG_FIPS */
00062 
00063 
00073 int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00074                 u8 *mac);
00075 
00089 int __must_check fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x,
00090                                size_t xlen);
00091 
00101 int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00102                   u8 *mac);
00103 
00111 void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
00112 
00120 void * aes_encrypt_init(const u8 *key, size_t len);
00121 
00129 void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
00130 
00136 void aes_encrypt_deinit(void *ctx);
00137 
00145 void * aes_decrypt_init(const u8 *key, size_t len);
00146 
00154 void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
00155 
00161 void aes_decrypt_deinit(void *ctx);
00162 
00163 
00164 enum crypto_hash_alg {
00165         CRYPTO_HASH_ALG_MD5, CRYPTO_HASH_ALG_SHA1,
00166         CRYPTO_HASH_ALG_HMAC_MD5, CRYPTO_HASH_ALG_HMAC_SHA1,
00167         CRYPTO_HASH_ALG_SHA256, CRYPTO_HASH_ALG_HMAC_SHA256
00168 };
00169 
00170 struct crypto_hash;
00171 
00185 struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
00186                                       size_t key_len);
00187 
00199 void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
00200 
00219 int crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
00220 
00221 
00222 enum crypto_cipher_alg {
00223         CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
00224         CRYPTO_CIPHER_ALG_DES, CRYPTO_CIPHER_ALG_RC2, CRYPTO_CIPHER_ALG_RC4
00225 };
00226 
00227 struct crypto_cipher;
00228 
00243 struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
00244                                           const u8 *iv, const u8 *key,
00245                                           size_t key_len);
00246 
00260 int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
00261                                        const u8 *plain, u8 *crypt, size_t len);
00262 
00276 int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
00277                                        const u8 *crypt, u8 *plain, size_t len);
00278 
00288 void crypto_cipher_deinit(struct crypto_cipher *ctx);
00289 
00290 
00291 struct crypto_public_key;
00292 struct crypto_private_key;
00293 
00309 struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
00310 
00323 struct crypto_private_key * crypto_private_key_import(const u8 *key,
00324                                                       size_t len,
00325                                                       const char *passwd);
00326 
00342 struct crypto_public_key * crypto_public_key_from_cert(const u8 *buf,
00343                                                        size_t len);
00344 
00359 int __must_check crypto_public_key_encrypt_pkcs1_v15(
00360         struct crypto_public_key *key, const u8 *in, size_t inlen,
00361         u8 *out, size_t *outlen);
00362 
00377 int __must_check crypto_private_key_decrypt_pkcs1_v15(
00378         struct crypto_private_key *key, const u8 *in, size_t inlen,
00379         u8 *out, size_t *outlen);
00380 
00395 int __must_check crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
00396                                                const u8 *in, size_t inlen,
00397                                                u8 *out, size_t *outlen);
00398 
00408 void crypto_public_key_free(struct crypto_public_key *key);
00409 
00419 void crypto_private_key_free(struct crypto_private_key *key);
00420 
00431 int __must_check crypto_public_key_decrypt_pkcs1(
00432         struct crypto_public_key *key, const u8 *crypt, size_t crypt_len,
00433         u8 *plain, size_t *plain_len);
00434 
00443 int __must_check crypto_global_init(void);
00444 
00453 void crypto_global_deinit(void);
00454 
00476 int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
00477                                 const u8 *power, size_t power_len,
00478                                 const u8 *modulus, size_t modulus_len,
00479                                 u8 *result, size_t *result_len);
00480 
00495 int rc4_skip(const u8 *key, size_t keylen, size_t skip,
00496              u8 *data, size_t data_len);
00497 
00498 #endif /* CRYPTO_H */
00499 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines