X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=ossl_crypto.c;h=61c6504cf0e0688c3193793dc28f50f5797cad3f;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=582620961e80e33514b39ab76648be761fd55368;hpb=aaa54fb1a4ec04a0f59e47170feb8173514f5ff5 diff --git a/ossl_crypto.c b/ossl_crypto.c index e69de29..61c6504 100644 --- a/ossl_crypto.c +++ b/ossl_crypto.c @@ -0,0 +1,53 @@ +#include +#include + +#include "crypto_if.h" + +static int ossl_encrypt(void *pt, int ptlen, void *key, int keylen, + void *ct, int *ctlen) +{ + EVP_CIPHER_CTX ctx; + unsigned char iv[16] = {0}; + int outlen1, outlen2; + + EVP_EncryptInit(&ctx, EVP_aes_256_cbc(), key, iv); + EVP_EncryptUpdate(&ctx, ct, &outlen1, pt, ptlen); + EVP_EncryptFinal(&ctx, ct + outlen1, &outlen2); + if (outlen1 + outlen2 > *ctlen) return -1; + *ctlen = outlen1 + outlen2; + + return 0; +} + +static int ossl_decrypt() +{ + return 0; +} + +static int ossl_hash() +{ + return 0; +} + +static int ossl_hmac() +{ + return 0; +} + +// result = HMAC(EVP_sha256(), key, 999, data, 888, NULL, NULL); +// EVP_MD * + +// HMAC_CTX hctx; +// HMAC_CTX_init(&hctx); +// if (HMAC_Init(&hctx, key, keylen, EVP_sha1())) success; +// if (HMAC_Update(&hctx, data, datalen)) success; +// if (HMAC_Final(&hctx, &digest, &digestlen)) success +// HMAC_CTX_cleanup(&hctx); + +struct crypto_interface ossl_crypto_if = { + .name = "openssl", + .encrypt = ossl_encrypt, + .decrypt = ossl_decrypt, + .hash = ossl_hash, + .hmac = ossl_hmac, +};