From c5541a4c03b89fcbcb0dd1bfab8460b1287cc6cb Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 20 Aug 2012 12:31:28 +0200 Subject: crypto: Add sha224 for rsa sign/verify --- lib/crypto/c_src/crypto.c | 13 +++++++++++++ lib/crypto/doc/src/crypto.xml | 4 ++-- lib/crypto/src/crypto.erl | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c index d9ae8a87a3..9a1a6f6c55 100644 --- a/lib/crypto/c_src/crypto.c +++ b/lib/crypto/c_src/crypto.c @@ -1564,6 +1564,12 @@ static void sha1_digest(unsigned char* in, unsigned int in_len, unsigned char* o { SHA1(in, in_len, out); } +#ifdef HAVE_SHA224 +static void sha224_digest(unsigned char* in, unsigned int in_len, unsigned char* out) +{ + SHA224(in, in_len, out); +} +#endif #ifdef HAVE_SHA256 static void sha256_digest(unsigned char* in, unsigned int in_len, unsigned char* out) { @@ -1595,6 +1601,13 @@ struct digest_type_t digest_types[] = { {"md5", MD5_DIGEST_LENGTH, NID_md5, md5_digest}, {"sha", SHA_DIGEST_LENGTH, NID_sha1, sha1_digest}, + {"sha224", +#ifdef HAVE_SHA224 + SHA224_LEN, NID_sha224, sha224_digest +#else + 0 +#endif + }, {"sha256", #ifdef HAVE_SHA256 SHA256_LEN, NID_sha256, sha256_digest diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml index 0d78dbc426..48e35f8093 100644 --- a/lib/crypto/doc/src/crypto.xml +++ b/lib/crypto/doc/src/crypto.xml @@ -932,7 +932,7 @@ Mpint() = >]]> the calculation faster. P1,P2 are first and second prime factors. E1,E2 are first and second exponents. C is the CRT coefficient. Terminology is taken from RFC 3447. - DigestType = md5 | sha | sha256 | sha384 | sha512 + DigestType = md5 | sha | sha224 | sha256 | sha384 | sha512 The default DigestType is sha. Mpint = binary() Signature = binary() @@ -957,7 +957,7 @@ Mpint() = >]]> Key = [E, N] E, N = Mpint Where E is the public exponent and N is public modulus. - DigestType = md5 | sha | sha256 | sha384 | sha512 + DigestType = md5 | sha | sha224 | sha256 | sha384 | sha512 The default DigestType is sha. Mpint = binary() diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index 63043888b9..0089e79a4f 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -105,7 +105,7 @@ aes_ctr_stream_init, aes_ctr_stream_encrypt, aes_ctr_stream_decrypt, info_lib]). --type rsa_digest_type() :: 'md5' | 'sha' | 'sha256' | 'sha384' | 'sha512'. +-type rsa_digest_type() :: 'md5' | 'sha' | 'sha224' | 'sha256' | 'sha384' | 'sha512'. -type dss_digest_type() :: 'none' | 'sha'. -type data_or_digest() :: binary() | {digest, binary()}. -type crypto_integer() :: binary() | integer(). -- cgit v1.2.3