8 extern struct crypto_interface ossl_crypto_if;
9 extern struct crypto_interface tom_crypto_if;
10 extern struct crypto_interface gnu_crypto_if;
12 static struct crypto_interface *ifs[] = {
24 #define MAX_IF (sizeof(ifs)/sizeof(struct crypto_interface *)-2)
28 int select_crypto_if(const int ifno)
30 if (ifno < 0 || ifno > MAX_IF) return -1;
35 const char *crypto_init(const int ifno)
37 if (ifno < 0 || ifno > MAX_IF) return (const char *)0;
38 return ifs[ifno]->init();
43 unsigned long encrypt(const void *key, const int keylen, const void *pt, void *ct, const int tlen)
45 unsigned char iv[16] = INITIV;
48 return ifs[which]->encrypt(key, keylen, iv, pt, ct, tlen);
51 unsigned long decrypt(const void *key, const int keylen, const void *ct, void *pt, const int tlen)
53 unsigned char iv[16] = INITIV;
56 return ifs[which]->decrypt(key, keylen, iv, ct, pt, tlen);
59 unsigned long hash(const void *pt, const int tlen, void *tag, int *taglen)
61 assert(*taglen == 20);
62 return ifs[which]->hash(pt, tlen, tag, taglen);
65 unsigned long hmac(const void *key, const int keylen, const void *pt, const int tlen, void *tag, int *taglen)
67 assert(*taglen == 20);
68 return ifs[which]->hmac(key, keylen, pt, tlen, tag, taglen);
71 const char *crypto_errstr(const unsigned long err)
73 return ifs[which]->errstr(err);