8 extern struct crypto_interface ossl_crypto_if;
9 extern struct crypto_interface tom_crypto_if;
11 static struct crypto_interface *ifs[] = {
20 #define MAX_IF (sizeof(ifs)/sizeof(struct crypto_interface *)-2)
24 int select_crypto_if(int ifno)
26 if (ifno < 0 || ifno > MAX_IF) return -1;
31 const char *crypto_init(int ifno)
33 if (ifno < 0 || ifno > MAX_IF) return (const char *)0;
34 return ifs[ifno]->init();
37 static unsigned char iv[16] = {0};
39 unsigned long encrypt(void *key, int keylen, void *pt, void *ct, int tlen)
42 return ifs[which]->encrypt(key, keylen, iv, pt, ct, tlen);
45 unsigned long decrypt(void *key, int keylen, void *ct, void *pt, int tlen)
48 return ifs[which]->decrypt(key, keylen, iv, ct, pt, tlen);
51 unsigned long hash(void *pt, int tlen, void *tag, int *taglen)
53 assert(*taglen == 20);
54 return ifs[which]->hash(pt, tlen, tag, taglen);
57 unsigned long hmac(void *key, int keylen, void *pt, int tlen, void *tag, int *taglen)
59 assert(*taglen == 20);
60 return ifs[which]->hmac(key, keylen, pt, tlen, tag, taglen);
63 const char *crypto_errstr(unsigned long err)
65 return ifs[which]->errstr(err);