6 #include <crypto/cryptodev.h>
7 #include <openssl/aes.h>
8 #include <openssl/engine.h>
9 #include <openssl/hmac.h>
10 #include <openssl/evp.h>
12 #include "threshold.h"
14 void sha_hash(void* text
, int size
, void* digest
)
20 SHA_Update(&ctx
, text
, size
);
22 SHA_Final(digest
, &ctx
);
25 void aes_sha_combo(void* ctx
, void* plaintext
, void* ciphertext
, int size
, void* tag
)
30 unsigned int rlen
= 20;
33 HMAC_Init_ex(&hctx
, iv
, 16, EVP_sha1(), NULL
);
35 HMAC_Update(&hctx
, plaintext
, size
);
37 HMAC_Final(&hctx
, tag
, &rlen
);
38 HMAC_CTX_cleanup(&hctx
);
40 AES_cbc_encrypt(plaintext
, ciphertext
, size
, key
, iv
, 1);
43 int get_sha1_threshold()
45 return hash_test(CRYPTO_SHA1
, sha_hash
);
48 int get_aes_sha1_threshold()
53 ENGINE_load_builtin_engines();
54 ENGINE_register_all_complete();
56 memset(ukey
, 0xaf, sizeof(ukey
));
57 AES_set_encrypt_key(ukey
, 16*8, &key
);
59 return aead_test(CRYPTO_AES_CBC
, CRYPTO_SHA1
, ukey
, 16, &key
, aes_sha_combo
);