X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=crypto.c;h=c2d6c1471f349dfee3ba981e0997c5a809f296c0;hp=b524f8ad24d3631f02fe8b980d625afe9dcb0c64;hb=ec614a7e3bc846cf9d3477303901759609c8f12f;hpb=8c8a47cd542e60381773fe23f2075aa5b896be4f diff --git a/crypto.c b/crypto.c index b524f8a..c2d6c14 100644 --- a/crypto.c +++ b/crypto.c @@ -28,22 +28,26 @@ int select_crypto_if(int ifno) return 0; } -const char *if_name(int ifno) +const char *crypto_init(int ifno) { - if (ifno < 0 || ifno > MAX_IF) return "invalid index"; - return ifs[ifno]->name; + if (ifno < 0 || ifno > MAX_IF) return (const char *)0; + return ifs[ifno]->init(); } -static unsigned char iv[16] = {0}; +#define INITIV {0} unsigned long encrypt(void *key, int keylen, void *pt, void *ct, int tlen) { + unsigned char iv[16] = INITIV; + assert(keylen == 16); return ifs[which]->encrypt(key, keylen, iv, pt, ct, tlen); } unsigned long decrypt(void *key, int keylen, void *ct, void *pt, int tlen) { + unsigned char iv[16] = INITIV; + assert(keylen == 16); return ifs[which]->decrypt(key, keylen, iv, ct, pt, tlen); }