8 static unsigned long tom_encrypt(void *key, int keylen, void *iv,
9 void *pt, void *ct, int tlen)
14 if ((index = register_cipher(&aes_desc)) == -1)
15 return CRYPT_INVALID_CIPHER;
16 if ((err = cbc_start(index, iv, key, keylen, 0, &cbc)) != CRYPT_OK)
18 err= cbc_encrypt(pt, ct, tlen, &cbc);
23 static unsigned long tom_decrypt(void *key, int keylen, void *iv,
24 void *ct, void *pt, int tlen)
29 if ((index = register_cipher(&aes_desc)) == -1)
30 return CRYPT_INVALID_CIPHER;
31 if ((err = cbc_start(index, iv, key, keylen, 0, &cbc)) != CRYPT_OK)
33 err= cbc_decrypt(ct, pt, tlen, &cbc);
38 static unsigned long tom_hash(void *pt, int tlen, void *tag, int *taglen)
41 unsigned long ltaglen = *taglen;
43 if ((index = register_hash(&sha1_desc)) == -1)
44 return CRYPT_INVALID_HASH;
45 rc = hash_memory(index, pt, tlen, tag, <aglen);
50 static unsigned long tom_hmac(void *key, int keylen,
51 void *pt, int tlen, void *tag, int *taglen)
54 unsigned long ltaglen = *taglen;
56 if ((index = register_hash(&sha1_desc)) == -1)
57 return CRYPT_INVALID_HASH;
58 rc = hmac_memory(index, key, keylen, pt, tlen, tag, <aglen);
63 static const char *tom_errstr(unsigned long err)
65 return error_to_string((int)err);
68 struct crypto_interface tom_crypto_if = {
70 .encrypt = tom_encrypt,
71 .decrypt = tom_decrypt,