sha.c \
sha.h \
sha256.c \
+ sha512.c \
validate.c \
ui.c \
ui.h
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
*
#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
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);
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
*
#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
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);
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__ */
hc_EVP_sha
hc_EVP_sha1
hc_EVP_sha256
+ hc_EVP_sha512
;! hc_EVP_cc_md2
;! hc_EVP_cc_md4
#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;
{NULL}
};
#endif
-#ifdef HAVE_SHA512
+
struct test sha512_tests[] = {
{ "abc",
{ 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b }},
{ NULL }
};
-#endif
static int
hash_test (struct hash_foo *hash, struct test *tests)
#ifdef HAVE_SHA384
+ hash_test(&sha384, sha384_tests)
#endif
-#ifdef HAVE_SHA512
- + hash_test(&sha512, sha512_tests)
-#endif
- ;
+ + hash_test(&sha512, sha512_tests);
}
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 */
hc_EVP_sha;
hc_EVP_sha1;
hc_EVP_sha256;
+ hc_EVP_sha512;
hc_EVP_cc_md2;
hc_EVP_cc_md4;
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;