From 4f9cc8feeab1aab322ced6c3fb00ec547ac3f99b Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Fri, 4 Dec 2015 23:56:12 +1100 Subject: [PATCH] add CommonCrypto support for SHA-384 and SHA-512 --- lib/hcrypto/evp-cc.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ lib/hcrypto/evp-cc.h | 4 ++++ 2 files changed, 54 insertions(+) diff --git a/lib/hcrypto/evp-cc.c b/lib/hcrypto/evp-cc.c index 6d1772682..7a5cf9184 100644 --- a/lib/hcrypto/evp-cc.c +++ b/lib/hcrypto/evp-cc.c @@ -710,6 +710,56 @@ EVP_cc_sha256(void) #endif } +/** + * The CommonCrypto sha384 provider + * + * @ingroup hcrypto_evp + */ + +const EVP_MD * +EVP_cc_sha384(void) +{ +#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H + static const struct hc_evp_md sha384 = { + CC_SHA384_DIGEST_LENGTH, + CC_SHA384_BLOCK_BYTES, + sizeof(CC_SHA512_CTX), + (hc_evp_md_init)CC_SHA384_Init, + (hc_evp_md_update)CC_SHA384_Update, + (hc_evp_md_final)CC_SHA384_Final, + (hc_evp_md_cleanup)NULL + }; + return &sha384; +#else + return NULL; +#endif +} + +/** + * The CommonCrypto sha512 provider + * + * @ingroup hcrypto_evp + */ + +const EVP_MD * +EVP_cc_sha512(void) +{ +#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H + static const struct hc_evp_md sha512 = { + CC_SHA512_DIGEST_LENGTH, + CC_SHA512_BLOCK_BYTES, + sizeof(CC_SHA512_CTX), + (hc_evp_md_init)CC_SHA512_Init, + (hc_evp_md_update)CC_SHA512_Update, + (hc_evp_md_final)CC_SHA512_Final, + (hc_evp_md_cleanup)NULL + }; + return &sha512; +#else + return NULL; +#endif +} + /** * The Camellia-128 cipher type - CommonCrypto * diff --git a/lib/hcrypto/evp-cc.h b/lib/hcrypto/evp-cc.h index 9249bb226..4d131de01 100644 --- a/lib/hcrypto/evp-cc.h +++ b/lib/hcrypto/evp-cc.h @@ -42,6 +42,8 @@ #define EVP_cc_md5 hc_EVP_cc_md5 #define EVP_cc_sha1 hc_EVP_cc_sha1 #define EVP_cc_sha256 hc_EVP_cc_sha256 +#define EVP_cc_sha384 hc_EVP_cc_sha384 +#define EVP_cc_sha512 hc_EVP_cc_sha512 #define EVP_cc_des_cbc hc_EVP_cc_des_cbc #define EVP_cc_des_ede3_cbc hc_EVP_cc_des_ede3_cbc #define EVP_cc_aes_128_cbc hc_EVP_cc_aes_128_cbc @@ -70,6 +72,8 @@ const EVP_MD * EVP_cc_md4(void); const EVP_MD * EVP_cc_md5(void); const EVP_MD * EVP_cc_sha1(void); const EVP_MD * EVP_cc_sha256(void); +const EVP_MD * EVP_cc_sha384(void); +const EVP_MD * EVP_cc_sha512(void); const EVP_CIPHER * EVP_cc_rc2_cbc(void); const EVP_CIPHER * EVP_cc_rc2_40_cbc(void);