diff --git a/include/crypto.h b/include/crypto.h index ae89de2..023e398 100644 --- a/include/crypto.h +++ b/include/crypto.h @@ -22,6 +22,7 @@ enum crypto_hash_type { CRYPTO_HASH_INVALID = 0, CRYPTO_HASH_MD5, CRYPTO_HASH_SHA1, + CRYPTO_HASH_SHA256, }; struct crypto_data_entry { diff --git a/src/crypto-nettle.c b/src/crypto-nettle.c index 656d102..4b8a755 100644 --- a/src/crypto-nettle.c +++ b/src/crypto-nettle.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ struct crypto_hash { union { struct md5_ctx md5; struct sha1_ctx sha1; + struct sha256_ctx sha256; } ctx; void (*update)(void* ctx, size_t len, const uint8_t* src); @@ -499,6 +501,11 @@ struct crypto_hash* crypto_hash_new(enum crypto_hash_type type) self->update = (void*)nettle_sha1_update; self->digest = (void*)nettle_sha1_digest; break; + case CRYPTO_HASH_SHA256: + sha256_init(&self->ctx.sha256); + self->update = (void*)nettle_sha256_update; + self->digest = (void*)nettle_sha256_digest; + break; } return self;