00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CRYPTO_H
00028 #define CRYPTO_H
00029
00038 int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00039
00048 int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
00049
00050 #ifdef CONFIG_FIPS
00051
00059 int md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
00060 const size_t *len, u8 *mac);
00061 #else
00062 #define md5_vector_non_fips_allow md5_vector
00063 #endif
00064
00065
00074 int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00075 u8 *mac);
00076
00089 int __must_check fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x,
00090 size_t xlen);
00091
00100 int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
00101 u8 *mac);
00102
00109 void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
00110
00117 void * aes_encrypt_init(const u8 *key, size_t len);
00118
00125 void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
00126
00131 void aes_encrypt_deinit(void *ctx);
00132
00139 void * aes_decrypt_init(const u8 *key, size_t len);
00140
00147 void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
00148
00153 void aes_decrypt_deinit(void *ctx);
00154
00155
00156 enum crypto_hash_alg {
00157 CRYPTO_HASH_ALG_MD5, CRYPTO_HASH_ALG_SHA1,
00158 CRYPTO_HASH_ALG_HMAC_MD5, CRYPTO_HASH_ALG_HMAC_SHA1
00159 };
00160
00161 struct crypto_hash;
00162
00175 struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
00176 size_t key_len);
00177
00188 void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
00189
00207 int crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
00208
00209
00210 enum crypto_cipher_alg {
00211 CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
00212 CRYPTO_CIPHER_ALG_DES, CRYPTO_CIPHER_ALG_RC2, CRYPTO_CIPHER_ALG_RC4
00213 };
00214
00215 struct crypto_cipher;
00216
00230 struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
00231 const u8 *iv, const u8 *key,
00232 size_t key_len);
00233
00246 int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
00247 const u8 *plain, u8 *crypt, size_t len);
00248
00261 int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
00262 const u8 *crypt, u8 *plain, size_t len);
00263
00272 void crypto_cipher_deinit(struct crypto_cipher *ctx);
00273
00274
00275 struct crypto_public_key;
00276 struct crypto_private_key;
00277
00292 struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
00293
00305 struct crypto_private_key * crypto_private_key_import(const u8 *key,
00306 size_t len,
00307 const char *passwd);
00308
00323 struct crypto_public_key * crypto_public_key_from_cert(const u8 *buf,
00324 size_t len);
00325
00339 int __must_check crypto_public_key_encrypt_pkcs1_v15(
00340 struct crypto_public_key *key, const u8 *in, size_t inlen,
00341 u8 *out, size_t *outlen);
00342
00356 int __must_check crypto_private_key_decrypt_pkcs1_v15(
00357 struct crypto_private_key *key, const u8 *in, size_t inlen,
00358 u8 *out, size_t *outlen);
00359
00373 int __must_check crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
00374 const u8 *in, size_t inlen,
00375 u8 *out, size_t *outlen);
00376
00385 void crypto_public_key_free(struct crypto_public_key *key);
00386
00395 void crypto_private_key_free(struct crypto_private_key *key);
00396
00406 int __must_check crypto_public_key_decrypt_pkcs1(
00407 struct crypto_public_key *key, const u8 *crypt, size_t crypt_len,
00408 u8 *plain, size_t *plain_len);
00409
00417 int __must_check crypto_global_init(void);
00418
00426 void crypto_global_deinit(void);
00427
00448 int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
00449 const u8 *power, size_t power_len,
00450 const u8 *modulus, size_t modulus_len,
00451 u8 *result, size_t *result_len);
00452
00466 int rc4_skip(const u8 *key, size_t keylen, size_t skip,
00467 u8 *data, size_t data_len);
00468
00469 #endif