diff options
| author | Andreas Schneider <asn@cryptomilk.org> | 2013-10-18 23:21:52 +0200 |
|---|---|---|
| committer | Andreas Schneider <asn@cryptomilk.org> | 2013-10-18 23:50:06 +0200 |
| commit | 5b7f07b484c47497b371b97578c0581b4e96fce4 (patch) | |
| tree | a839238b241c914778af64788ba9fcfe511ec187 /src | |
| parent | ec5278e34dd8271c696fe5f54ebc114dc132fe8c (diff) | |
wrapper: Add more evp functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcrypto.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c index 44b0fb36..bb1d96ad 100644 --- a/src/libcrypto.c +++ b/src/libcrypto.c @@ -123,6 +123,30 @@ void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned EVP_DigestUpdate(&md, digest, len); EVP_DigestFinal(&md, hash, hlen); } + +EVPCTX evp_init(int nid) +{ + const EVP_MD *evp_md = nid_to_evpmd(nid); + + EVPCTX ctx = malloc(sizeof(EVP_MD_CTX)); + if (ctx == NULL) { + return NULL; + } + + EVP_DigestInit(ctx, evp_md); + + return ctx; +} + +void evp_update(EVPCTX ctx, const void *data, unsigned long len) +{ + EVP_DigestUpdate(ctx, data, len); +} + +void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen) +{ + EVP_DigestFinal(ctx, md, mdlen); +} #endif SHA256CTX sha256_init(void){ |
