SHA512 support
This commit is contained in:
@@ -154,6 +154,7 @@ libhcrypto_la_SOURCES = \
|
||||
sha.c \
|
||||
sha.h \
|
||||
sha256.c \
|
||||
sha512.c \
|
||||
validate.c \
|
||||
ui.c \
|
||||
ui.h
|
||||
|
@@ -289,6 +289,29 @@ EVP_hcrypto_sha256(void)
|
||||
return &sha256;
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA256 - hcrypto
|
||||
*
|
||||
* @return the message digest type.
|
||||
*
|
||||
* @ingroup hcrypto_evp
|
||||
*/
|
||||
|
||||
const EVP_MD *
|
||||
EVP_hcrypto_sha512(void)
|
||||
{
|
||||
static const struct hc_evp_md sha512 = {
|
||||
64,
|
||||
128,
|
||||
sizeof(SHA512_CTX),
|
||||
(hc_evp_md_init)SHA512_Init,
|
||||
(hc_evp_md_update)SHA512_Update,
|
||||
(hc_evp_md_final)SHA512_Final,
|
||||
NULL
|
||||
};
|
||||
return &sha512;
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA1 - hcrypto
|
||||
*
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#define EVP_hcrypto_md5 hc_EVP_hcrypto_md5
|
||||
#define EVP_hcrypto_sha1 hc_EVP_hcrypto_sha1
|
||||
#define EVP_hcrypto_sha256 hc_EVP_hcrypto_sha256
|
||||
#define EVP_hcrypto_sha512 hc_EVP_hcrypto_sha512
|
||||
#define EVP_hcrypto_des_cbc hc_EVP_hcrypto_des_cbc
|
||||
#define EVP_hcrypto_des_ede3_cbc hc_EVP_hcrypto_des_ede3_cbc
|
||||
#define EVP_hcrypto_aes_128_cbc hc_EVP_hcrypto_aes_128_cbc
|
||||
@@ -70,6 +71,7 @@ const EVP_MD * EVP_hcrypto_md4(void);
|
||||
const EVP_MD * EVP_hcrypto_md5(void);
|
||||
const EVP_MD * EVP_hcrypto_sha1(void);
|
||||
const EVP_MD * EVP_hcrypto_sha256(void);
|
||||
const EVP_MD * EVP_hcrypto_sha512(void);
|
||||
|
||||
const EVP_CIPHER * EVP_hcrypto_rc4(void);
|
||||
const EVP_CIPHER * EVP_hcrypto_rc4_40(void);
|
||||
|
@@ -360,6 +360,13 @@ EVP_sha256(void)
|
||||
return EVP_DEF_OP(HCRYPTO_DEF_PROVIDER, sha256);
|
||||
}
|
||||
|
||||
const EVP_MD *
|
||||
EVP_sha512(void)
|
||||
{
|
||||
hcrypto_validate();
|
||||
return EVP_DEF_OP(HCRYPTO_DEF_PROVIDER, sha512);
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA1
|
||||
*
|
||||
|
@@ -96,6 +96,7 @@
|
||||
#define EVP_sha hc_EVP_sha
|
||||
#define EVP_sha1 hc_EVP_sha1
|
||||
#define EVP_sha256 hc_EVP_sha256
|
||||
#define EVP_sha512 hc_EVP_sha512
|
||||
#define PKCS5_PBKDF2_HMAC_SHA1 hc_PKCS5_PBKDF2_HMAC_SHA1
|
||||
#define EVP_BytesToKey hc_EVP_BytesToKey
|
||||
#define EVP_get_cipherbyname hc_EVP_get_cipherbyname
|
||||
@@ -225,6 +226,7 @@ HC_DEPRECATED_CRYPTO const EVP_MD *EVP_md5(void);
|
||||
const EVP_MD *EVP_sha(void);
|
||||
const EVP_MD *EVP_sha1(void);
|
||||
const EVP_MD *EVP_sha256(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
|
||||
const EVP_CIPHER * EVP_aes_128_cbc(void);
|
||||
const EVP_CIPHER * EVP_aes_192_cbc(void);
|
||||
|
@@ -66,4 +66,10 @@ cshift (uint32_t x, unsigned int n)
|
||||
return CRAYFIX((x << n) | (x >> (32 - n)));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
cshift64 (uint64_t x, unsigned int n)
|
||||
{
|
||||
return ((uint64_t)x << (uint64_t)n) | ((uint64_t)x >> ((uint64_t)64 - (uint64_t)n));
|
||||
}
|
||||
|
||||
#endif /* __hash_h__ */
|
||||
|
@@ -160,6 +160,7 @@ EXPORTS
|
||||
hc_EVP_sha
|
||||
hc_EVP_sha1
|
||||
hc_EVP_sha256
|
||||
hc_EVP_sha512
|
||||
|
||||
;! hc_EVP_cc_md2
|
||||
;! hc_EVP_cc_md4
|
||||
|
@@ -104,23 +104,22 @@ struct hash_foo sha256 = {
|
||||
#ifdef HAVE_SHA384
|
||||
struct hash_foo sha384 = {
|
||||
"SHA-384",
|
||||
sizeof(struct sha512),
|
||||
sizeof(SHA384_CTX),
|
||||
48,
|
||||
(void (*)(void*))SHA384_Init,
|
||||
(void (*)(void*,const void*, size_t))SHA384_Update,
|
||||
(void (*)(void*, void*))SHA384_Final
|
||||
};
|
||||
#endif
|
||||
#ifdef HAVE_SHA512
|
||||
struct hash_foo sha512 = {
|
||||
"SHA-512",
|
||||
sizeof(struct sha512),
|
||||
sizeof(SHA512_CTX),
|
||||
64,
|
||||
(void (*)(void*))SHA512_Init,
|
||||
(void (*)(void*,const void*, size_t))SHA512_Update,
|
||||
(void (*)(void*, void*))SHA512_Final
|
||||
(void (*)(void*, void*))SHA512_Final,
|
||||
EVP_sha512
|
||||
};
|
||||
#endif
|
||||
|
||||
struct test {
|
||||
char *str;
|
||||
@@ -235,7 +234,7 @@ struct test sha384_tests[] = {
|
||||
{NULL}
|
||||
};
|
||||
#endif
|
||||
#ifdef HAVE_SHA512
|
||||
|
||||
struct test sha512_tests[] = {
|
||||
{ "abc",
|
||||
{ 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
|
||||
@@ -267,7 +266,6 @@ struct test sha512_tests[] = {
|
||||
0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b }},
|
||||
{ NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
static int
|
||||
hash_test (struct hash_foo *hash, struct test *tests)
|
||||
@@ -351,8 +349,5 @@ main (void)
|
||||
#ifdef HAVE_SHA384
|
||||
+ hash_test(&sha384, sha384_tests)
|
||||
#endif
|
||||
#ifdef HAVE_SHA512
|
||||
+ hash_test(&sha512, sha512_tests)
|
||||
#endif
|
||||
;
|
||||
+ hash_test(&sha512, sha512_tests);
|
||||
}
|
||||
|
@@ -80,4 +80,22 @@ void SHA256_Init (SHA256_CTX *);
|
||||
void SHA256_Update (SHA256_CTX *, const void *, size_t);
|
||||
void SHA256_Final (void *, SHA256_CTX *);
|
||||
|
||||
/*
|
||||
* SHA-2 512
|
||||
*/
|
||||
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
struct hc_sha512state {
|
||||
uint64_t sz[2];
|
||||
uint64_t counter[8];
|
||||
unsigned char save[128];
|
||||
};
|
||||
|
||||
typedef struct hc_sha512state SHA512_CTX;
|
||||
|
||||
void SHA512_Init (SHA512_CTX *);
|
||||
void SHA512_Update (SHA512_CTX *, const void *, size_t);
|
||||
void SHA512_Final (void *, SHA512_CTX *);
|
||||
|
||||
#endif /* HEIM_SHA_H */
|
||||
|
@@ -167,6 +167,7 @@ HEIMDAL_CRYPTO_1.0 {
|
||||
hc_EVP_sha;
|
||||
hc_EVP_sha1;
|
||||
hc_EVP_sha256;
|
||||
hc_EVP_sha512;
|
||||
|
||||
hc_EVP_cc_md2;
|
||||
hc_EVP_cc_md4;
|
||||
@@ -186,6 +187,7 @@ HEIMDAL_CRYPTO_1.0 {
|
||||
hc_EVP_hcrypto_md5;
|
||||
hc_EVP_hcrypto_sha1;
|
||||
hc_EVP_hcrypto_sha256;
|
||||
hc_EVP_hcrypto_sha512;
|
||||
hc_EVP_hcrypto_des_ede3_cbc;
|
||||
hc_EVP_hcrypto_aes_128_cbc;
|
||||
hc_EVP_hcrypto_aes_192_cbc;
|
||||
|
Reference in New Issue
Block a user