crypto: Add sha256
parent
b2ad06ae3c
commit
103fbe996e
|
@ -22,6 +22,7 @@ enum crypto_hash_type {
|
||||||
CRYPTO_HASH_INVALID = 0,
|
CRYPTO_HASH_INVALID = 0,
|
||||||
CRYPTO_HASH_MD5,
|
CRYPTO_HASH_MD5,
|
||||||
CRYPTO_HASH_SHA1,
|
CRYPTO_HASH_SHA1,
|
||||||
|
CRYPTO_HASH_SHA256,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct crypto_data_entry {
|
struct crypto_data_entry {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <nettle/eax.h>
|
#include <nettle/eax.h>
|
||||||
#include <nettle/md5.h>
|
#include <nettle/md5.h>
|
||||||
#include <nettle/sha1.h>
|
#include <nettle/sha1.h>
|
||||||
|
#include <nettle/sha.h>
|
||||||
#include <nettle/rsa.h>
|
#include <nettle/rsa.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -66,6 +67,7 @@ struct crypto_hash {
|
||||||
union {
|
union {
|
||||||
struct md5_ctx md5;
|
struct md5_ctx md5;
|
||||||
struct sha1_ctx sha1;
|
struct sha1_ctx sha1;
|
||||||
|
struct sha256_ctx sha256;
|
||||||
} ctx;
|
} ctx;
|
||||||
|
|
||||||
void (*update)(void* ctx, size_t len, const uint8_t* src);
|
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->update = (void*)nettle_sha1_update;
|
||||||
self->digest = (void*)nettle_sha1_digest;
|
self->digest = (void*)nettle_sha1_digest;
|
||||||
break;
|
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;
|
return self;
|
||||||
|
|
Loading…
Reference in New Issue