X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=crypto.c;h=c2d6c1471f349dfee3ba981e0997c5a809f296c0;hp=282a713d494517afef007f57212df40691b264ca;hb=ecefc4912f36f9153e63e7e0ee90d8ef69898fed;hpb=740b870a7a4d1936991d856f5427e4c10c2c849a diff --git a/crypto.c b/crypto.c index 282a713..c2d6c14 100644 --- a/crypto.c +++ b/crypto.c @@ -1,3 +1,6 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include "crypto.h" #include "crypto_if.h" @@ -25,16 +28,26 @@ int select_crypto_if(int ifno) return 0; } -static unsigned char iv[16] = {0}; +const char *crypto_init(int ifno) +{ + if (ifno < 0 || ifno > MAX_IF) return (const char *)0; + return ifs[ifno]->init(); +} + +#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); } @@ -47,7 +60,6 @@ unsigned long hash(void *pt, int tlen, void *tag, int *taglen) unsigned long hmac(void *key, int keylen, void *pt, int tlen, void *tag, int *taglen) { - assert(keylen == 20); assert(*taglen == 20); return ifs[which]->hmac(key, keylen, pt, tlen, tag, taglen); }