5 extern struct crypto_interface ossl_crypto_if;
6 extern struct crypto_interface tom_crypto_if;
8 static struct crypto_interface *ifs[] = {
17 #define MAX_IF (sizeof(ifs)/sizeof(struct crypto_interface *)-2)
21 int select_crypto_if(int ifno)
23 if (ifno < 0 || ifno > MAX_IF) return -1;
28 static unsigned char iv[16] = {0};
30 unsigned long encrypt(void *key, int keylen, void *pt, void *ct, int tlen)
33 return ifs[which]->encrypt(key, keylen, iv, pt, ct, tlen);
36 unsigned long decrypt(void *key, int keylen, void *ct, void *pt, int tlen)
39 return ifs[which]->decrypt(key, keylen, iv, ct, pt, tlen);
42 unsigned long hash(void *pt, int tlen, void *tag, int *taglen)
44 assert(*taglen == 20);
45 return ifs[which]->hash(pt, tlen, tag, taglen);
48 unsigned long hmac(void *key, int keylen, void *pt, int tlen, void *tag, int *taglen)
51 assert(*taglen == 20);
52 return ifs[which]->hmac(key, keylen, pt, tlen, tag, taglen);
55 const char *crypto_errstr(unsigned long err)
57 return ifs[which]->errstr(err);