SHA384
authorLove Hornquist Astrand <lha@h5l.org>
Fri, 1 Oct 2010 01:22:00 +0000 (18:22 -0700)
committerLove Hornquist Astrand <lha@h5l.org>
Fri, 1 Oct 2010 01:22:00 +0000 (18:22 -0700)
lib/hcrypto/evp-hcrypto.c
lib/hcrypto/evp-hcrypto.h
lib/hcrypto/evp.c
lib/hcrypto/evp.h
lib/hcrypto/libhcrypto-exports.def
lib/hcrypto/mdtest.c
lib/hcrypto/sha.h
lib/hcrypto/sha512.c
lib/hcrypto/version-script.map

index 7075c0fdd4e9e6712b5df82c6f9b0370de3b77ab..bf37b42edcaca83b52d4a64859e71c690053a30e 100644 (file)
@@ -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.
  *
index df82c227b320d318977d28a960e35125b10249ad..b7876c67c8a3b1e808b2ca9c8383edbcb7b3d80a 100644 (file)
@@ -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);
index e28691598fcbed4c5107c409ff1051f38e95bef6..7bd066fd5dccb8e446c22e6b404aa67a5a55166a 100644 (file)
@@ -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)
 {
index b60d5586f47eab0d87c644694b22ec69dd41af99..c56eedec45b29956a679e81f54e0bcc863437658 100644 (file)
@@ -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);
index 8fa083442982b0af73c1cdb0b299dfcbfb9f16b3..f2b5beedd3647b22ad1a22a9aea8d7427b1dcae8 100644 (file)
@@ -160,6 +160,7 @@ EXPORTS
        hc_EVP_sha
        hc_EVP_sha1
        hc_EVP_sha256
+       hc_EVP_sha384
        hc_EVP_sha512
 
 ;!     hc_EVP_cc_md2
index 9f474c712ff8b448c11f2ceaa39404f38e18a290..fd90ee73a2afad0bad20f1afed9ac1bc29c76272 100644 (file)
@@ -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);
 }
index cefe7dca0253f34a90cccc4df189b8d7c3fc2a3e..a1f5a993189ce98ae69af077695dfe8b96dcdf50 100644 (file)
@@ -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 */
index 66c86d16dcd75e9e5bf4be43b80bafa2a56412bf..18447b6c67ad7e45fa3e7bc43efba7c8956a2b99 100644 (file)
@@ -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);
+}
+
index 2c6afc45122c6ad9d248c3c0fc8bc46092866b27..0cde14fe61ae4b3a36cbf57f649248605277b374 100644 (file)
@@ -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;