X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=tom_crypto.c;h=cdb02d05aee3f46b71f01f0e3f2dd2728fc3431d;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=5a0ef35c9d77bedabd249fb7f47d94a6f54b5082;hpb=582620961e80e33514b39ab76648be761fd55368;ds=sidebyside diff --git a/tom_crypto.c b/tom_crypto.c index e69de29..cdb02d0 100644 --- a/tom_crypto.c +++ b/tom_crypto.c @@ -0,0 +1,47 @@ +#include + +#include "crypto_if.h" + +static int tom_encrypt(void *pt, int ptlen, void *key, int keylen, + void *ct, int *ctlen) +{ + symmentric_cbc cbc; + unsigned char iv[16] = {0}; + int index, err; + + if ((index = register_cipher(&aes_desc)) == -1) return -1; + // if ((index = find_cipher("aes")) == -1) return -1; + cipher = cipher_descriptor[index]; + if ((err = cbc_start(index, iv, key, keylen, 0, &cbc)) != CRYPT_OK) + return err; + if ((err = cbc_encrypt(pt, ct, ptlen, &cbc)) != CRYPT_OK) + return err; + if ((err = cbc_done(&cbc)) != CRYPT_OK) + return err; + if ((err = unregister_cipher(&aes_desc)) != CRYPT_OK) + return err; + return 0; +} + +static int tom_decrypt() +{ + return 0; +} + +static int tom_hash() +{ + return 0; +} + +static int tom_hmac() +{ + return 0; +} + +struct crypto_interface tom_crypto_if = { + .name = "tomcrypt", + .encrypt = tom_encrypt, + .decrypt = tom_decrypt, + .hash = tom_hash, + .hmac = tom_hmac, +};