SHA384
This commit is contained in:
@@ -290,7 +290,30 @@ EVP_hcrypto_sha256(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA256 - hcrypto
|
||||
* The message digest SHA384 - hcrypto
|
||||
*
|
||||
* @return the message digest type.
|
||||
*
|
||||
* @ingroup hcrypto_evp
|
||||
*/
|
||||
|
||||
const EVP_MD *
|
||||
EVP_hcrypto_sha384(void)
|
||||
{
|
||||
static const struct hc_evp_md sha384 = {
|
||||
48,
|
||||
128,
|
||||
sizeof(SHA384_CTX),
|
||||
(hc_evp_md_init)SHA384_Init,
|
||||
(hc_evp_md_update)SHA384_Update,
|
||||
(hc_evp_md_final)SHA384_Final,
|
||||
NULL
|
||||
};
|
||||
return &sha384;
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA512 - hcrypto
|
||||
*
|
||||
* @return the message digest type.
|
||||
*
|
||||
|
@@ -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_sha384 hc_EVP_hcrypto_sha384
|
||||
#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
|
||||
@@ -71,6 +72,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_sha384(void);
|
||||
const EVP_MD * EVP_hcrypto_sha512(void);
|
||||
|
||||
const EVP_CIPHER * EVP_hcrypto_rc4(void);
|
||||
|
@@ -360,6 +360,29 @@ EVP_sha256(void)
|
||||
return EVP_DEF_OP(HCRYPTO_DEF_PROVIDER, sha256);
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA384
|
||||
*
|
||||
* @return the message digest type.
|
||||
*
|
||||
* @ingroup hcrypto_evp
|
||||
*/
|
||||
|
||||
const EVP_MD *
|
||||
EVP_sha384(void)
|
||||
{
|
||||
hcrypto_validate();
|
||||
return EVP_DEF_OP(HCRYPTO_DEF_PROVIDER, sha384);
|
||||
}
|
||||
|
||||
/**
|
||||
* The message digest SHA512
|
||||
*
|
||||
* @return the message digest type.
|
||||
*
|
||||
* @ingroup hcrypto_evp
|
||||
*/
|
||||
|
||||
const EVP_MD *
|
||||
EVP_sha512(void)
|
||||
{
|
||||
|
@@ -96,6 +96,7 @@
|
||||
#define EVP_sha hc_EVP_sha
|
||||
#define EVP_sha1 hc_EVP_sha1
|
||||
#define EVP_sha256 hc_EVP_sha256
|
||||
#define EVP_sha384 hc_EVP_sha384
|
||||
#define EVP_sha512 hc_EVP_sha512
|
||||
#define PKCS5_PBKDF2_HMAC_SHA1 hc_PKCS5_PBKDF2_HMAC_SHA1
|
||||
#define EVP_BytesToKey hc_EVP_BytesToKey
|
||||
@@ -226,6 +227,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_sha384(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
|
||||
const EVP_CIPHER * EVP_aes_128_cbc(void);
|
||||
|
@@ -160,6 +160,7 @@ EXPORTS
|
||||
hc_EVP_sha
|
||||
hc_EVP_sha1
|
||||
hc_EVP_sha256
|
||||
hc_EVP_sha384
|
||||
hc_EVP_sha512
|
||||
|
||||
;! hc_EVP_cc_md2
|
||||
|
@@ -101,16 +101,15 @@ struct hash_foo sha256 = {
|
||||
(void (*)(void*, void*))SHA256_Final,
|
||||
EVP_sha256
|
||||
};
|
||||
#ifdef HAVE_SHA384
|
||||
struct hash_foo sha384 = {
|
||||
"SHA-384",
|
||||
sizeof(SHA384_CTX),
|
||||
48,
|
||||
(void (*)(void*))SHA384_Init,
|
||||
(void (*)(void*,const void*, size_t))SHA384_Update,
|
||||
(void (*)(void*, void*))SHA384_Final
|
||||
(void (*)(void*, void*))SHA384_Final,
|
||||
EVP_sha384
|
||||
};
|
||||
#endif
|
||||
struct hash_foo sha512 = {
|
||||
"SHA-512",
|
||||
sizeof(SHA512_CTX),
|
||||
@@ -207,7 +206,6 @@ struct test sha256_tests[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
#ifdef HAVE_SHA384
|
||||
struct test sha384_tests[] = {
|
||||
{ "abc",
|
||||
{ 0xcb,0x00,0x75,0x3f,0x45,0xa3,0x5e,0x8b,
|
||||
@@ -233,7 +231,6 @@ struct test sha384_tests[] = {
|
||||
0xae,0x97,0xdd,0xd8,0x7f,0x3d,0x89,0x85}},
|
||||
{NULL}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct test sha512_tests[] = {
|
||||
{ "abc",
|
||||
@@ -344,10 +341,8 @@ main (void)
|
||||
hash_test(&md2, md2_tests) +
|
||||
hash_test(&md4, md4_tests) +
|
||||
hash_test(&md5, md5_tests) +
|
||||
hash_test(&sha1, sha1_tests)
|
||||
+ hash_test(&sha256, sha256_tests)
|
||||
#ifdef HAVE_SHA384
|
||||
+ hash_test(&sha384, sha384_tests)
|
||||
#endif
|
||||
+ hash_test(&sha512, sha512_tests);
|
||||
hash_test(&sha1, sha1_tests) +
|
||||
hash_test(&sha256, sha256_tests) +
|
||||
hash_test(&sha384, sha384_tests) +
|
||||
hash_test(&sha512, sha512_tests);
|
||||
}
|
||||
|
@@ -98,4 +98,12 @@ void SHA512_Init (SHA512_CTX *);
|
||||
void SHA512_Update (SHA512_CTX *, const void *, size_t);
|
||||
void SHA512_Final (void *, SHA512_CTX *);
|
||||
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
|
||||
typedef struct hc_sha512state SHA384_CTX;
|
||||
|
||||
void SHA384_Init (SHA384_CTX *);
|
||||
void SHA384_Update (SHA384_CTX *, const void *, size_t);
|
||||
void SHA384_Final (void *, SHA384_CTX *);
|
||||
|
||||
#endif /* HEIM_SHA_H */
|
||||
|
@@ -242,3 +242,33 @@ SHA512_Final (void *res, SHA512_CTX *m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SHA384_Init(SHA384_CTX *m)
|
||||
{
|
||||
m->sz[0] = 0;
|
||||
m->sz[1] = 0;
|
||||
A = 0xcbbb9d5dc1059ed8;
|
||||
B = 0x629a292a367cd507;
|
||||
C = 0x9159015a3070dd17;
|
||||
D = 0x152fecd8f70e5939;
|
||||
E = 0x67332667ffc00b31;
|
||||
F = 0x8eb44a8768581511;
|
||||
G = 0xdb0c2e0d64f98fa7;
|
||||
H = 0x47b5481dbefa4fa4;
|
||||
}
|
||||
|
||||
void
|
||||
SHA384_Update (SHA384_CTX *m, const void *v, size_t len)
|
||||
{
|
||||
SHA512_Update(m, v, len);
|
||||
}
|
||||
|
||||
void
|
||||
SHA384_Final (void *res, SHA384_CTX *m)
|
||||
{
|
||||
unsigned char data[SHA512_DIGEST_LENGTH];
|
||||
SHA512_Final(data, m);
|
||||
memcpy(res, data, SHA384_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
|
@@ -167,6 +167,7 @@ HEIMDAL_CRYPTO_1.0 {
|
||||
hc_EVP_sha;
|
||||
hc_EVP_sha1;
|
||||
hc_EVP_sha256;
|
||||
hc_EVP_sha384;
|
||||
hc_EVP_sha512;
|
||||
|
||||
hc_EVP_cc_md2;
|
||||
@@ -187,6 +188,7 @@ HEIMDAL_CRYPTO_1.0 {
|
||||
hc_EVP_hcrypto_md5;
|
||||
hc_EVP_hcrypto_sha1;
|
||||
hc_EVP_hcrypto_sha256;
|
||||
hc_EVP_hcrypto_sha384;
|
||||
hc_EVP_hcrypto_sha512;
|
||||
hc_EVP_hcrypto_des_ede3_cbc;
|
||||
hc_EVP_hcrypto_aes_128_cbc;
|
||||
|
Reference in New Issue
Block a user