00001
00028 #ifndef CRYPTO_H
00029 #define CRYPTO_H
00030
00040 int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00041
00051 int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00052
00053 #ifdef CONFIG_FIPS
00054
00063 int md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
00064 const size_t *len, u8 *mac);
00065 #else
00066 #define md5_vector_non_fips_allow md5_vector
00067 #endif
00068
00069
00079 int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00080 u8 *mac);
00081
00095 int __must_check fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x,
00096 size_t xlen);
00097
00107 int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00108 u8 *mac);
00109
00117 void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
00118
00126 void * aes_encrypt_init(const u8 *key, size_t len);
00127
00135 void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
00136
00142 void aes_encrypt_deinit(void *ctx);
00143
00151 void * aes_decrypt_init(const u8 *key, size_t len);
00152
00160 void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
00161
00167 void aes_decrypt_deinit(void *ctx);
00168
00169
00170 enum crypto_hash_alg {
00171 CRYPTO_HASH_ALG_MD5, CRYPTO_HASH_ALG_SHA1,
00172 CRYPTO_HASH_ALG_HMAC_MD5, CRYPTO_HASH_ALG_HMAC_SHA1
00173 };
00174
00175 struct crypto_hash;
00176
00190 struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
00191 size_t key_len);
00192
00204 void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
00205
00224 int crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
00225
00226
00227 enum crypto_cipher_alg {
00228 CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
00229 CRYPTO_CIPHER_ALG_DES, CRYPTO_CIPHER_ALG_RC2, CRYPTO_CIPHER_ALG_RC4
00230 };
00231
00232 struct crypto_cipher;
00233
00248 struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
00249 const u8 *iv, const u8 *key,
00250 size_t key_len);
00251
00265 int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
00266 const u8 *plain, u8 *crypt, size_t len);
00267
00281 int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
00282 const u8 *crypt, u8 *plain, size_t len);
00283
00293 void crypto_cipher_deinit(struct crypto_cipher *ctx);
00294
00295
00296 struct crypto_public_key;
00297 struct crypto_private_key;
00298
00314 struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
00315
00328 struct crypto_private_key * crypto_private_key_import(const u8 *key,
00329 size_t len,
00330 const char *passwd);
00331
00347 struct crypto_public_key * crypto_public_key_from_cert(const u8 *buf,
00348 size_t len);
00349
00364 int __must_check crypto_public_key_encrypt_pkcs1_v15(
00365 struct crypto_public_key *key, const u8 *in, size_t inlen,
00366 u8 *out, size_t *outlen);
00367
00382 int __must_check crypto_private_key_decrypt_pkcs1_v15(
00383 struct crypto_private_key *key, const u8 *in, size_t inlen,
00384 u8 *out, size_t *outlen);
00385
00400 int __must_check crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
00401 const u8 *in, size_t inlen,
00402 u8 *out, size_t *outlen);
00403
00413 void crypto_public_key_free(struct crypto_public_key *key);
00414
00424 void crypto_private_key_free(struct crypto_private_key *key);
00425
00436 int __must_check crypto_public_key_decrypt_pkcs1(
00437 struct crypto_public_key *key, const u8 *crypt, size_t crypt_len,
00438 u8 *plain, size_t *plain_len);
00439
00448 int __must_check crypto_global_init(void);
00449
00458 void crypto_global_deinit(void);
00459
00481 int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
00482 const u8 *power, size_t power_len,
00483 const u8 *modulus, size_t modulus_len,
00484 u8 *result, size_t *result_len);
00485
00500 int rc4_skip(const u8 *key, size_t keylen, size_t skip,
00501 u8 *data, size_t data_len);
00502
00503 #endif
00504