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();
39 unsigned long encrypt(void *key, int keylen, void *pt, void *ct, int tlen)
41 unsigned char iv[16] = INITIV;
44 return ifs[which]->encrypt(key, keylen, iv, pt, ct, tlen);
47 unsigned long decrypt(void *key, int keylen, void *ct, void *pt, int tlen)
49 unsigned char iv[16] = INITIV;
52 return ifs[which]->decrypt(key, keylen, iv, ct, pt, tlen);
55 unsigned long hash(void *pt, int tlen, void *tag, int *taglen)
57 assert(*taglen == 20);
58 return ifs[which]->hash(pt, tlen, tag, taglen);
61 unsigned long hmac(void *key, int keylen, void *pt, int tlen, void *tag, int *taglen)
63 assert(*taglen == 20);
64 return ifs[which]->hmac(key, keylen, pt, tlen, tag, taglen);
67 const char *crypto_errstr(unsigned long err)
69 return ifs[which]->errstr(err);