diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-11 02:09:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-11 02:09:55 +0000 |
commit | b97ceb66e97f2a36e5602f74a593c61292cbd33b (patch) | |
tree | bd3085b343ba5abd5b40338007e880c5fde64176 /ext/digest/sha2 | |
parent | 935275bb5952b59b65c6a038a4b825aea95562ae (diff) | |
download | ruby-b97ceb66e97f2a36e5602f74a593c61292cbd33b.tar.gz |
digest: CommonDigest
* ext/digest/digest_conf.rb (digest_conf): check for CommonDigest.
* ext/digest/*/*cc.h: for Apple CommonCrypto/CommonDigest.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/sha2')
-rw-r--r-- | ext/digest/sha2/sha2cc.h | 31 | ||||
-rw-r--r-- | ext/digest/sha2/sha2init.c | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/digest/sha2/sha2cc.h b/ext/digest/sha2/sha2cc.h new file mode 100644 index 0000000000..49d463088f --- /dev/null +++ b/ext/digest/sha2/sha2cc.h @@ -0,0 +1,31 @@ +#define COMMON_DIGEST_FOR_OPENSSL 1 +#include <CommonCrypto/CommonDigest.h> + +#define SHA256_BLOCK_LENGTH CC_SHA256_BLOCK_BYTES +#define SHA384_BLOCK_LENGTH CC_SHA384_BLOCK_BYTES +#define SHA512_BLOCK_LENGTH CC_SHA512_BLOCK_BYTES + +#define SHA384_CTX CC_SHA512_CTX + +static DEFINE_UPDATE_FUNC_FOR_UINT(SHA256); +static DEFINE_FINISH_FUNC_FROM_FINAL(SHA256); +static DEFINE_UPDATE_FUNC_FOR_UINT(SHA384); +static DEFINE_FINISH_FUNC_FROM_FINAL(SHA384); +static DEFINE_UPDATE_FUNC_FOR_UINT(SHA512); +static DEFINE_FINISH_FUNC_FROM_FINAL(SHA512); + + +#undef SHA256_Update +#undef SHA256_Finish +#define SHA256_Update rb_digest_SHA256_update +#define SHA256_Finish rb_digest_SHA256_finish + +#undef SHA384_Update +#undef SHA384_Finish +#define SHA384_Update rb_digest_SHA384_update +#define SHA384_Finish rb_digest_SHA384_finish + +#undef SHA512_Update +#undef SHA512_Finish +#define SHA512_Update rb_digest_SHA512_update +#define SHA512_Finish rb_digest_SHA512_finish diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c index 7b39bda649..09ccee5ac4 100644 --- a/ext/digest/sha2/sha2init.c +++ b/ext/digest/sha2/sha2init.c @@ -4,6 +4,8 @@ #include "digest.h" #if defined(SHA2_USE_OPENSSL) #include "sha2ossl.h" +#elif defined(SHA2_USE_COMMONDIGEST) +#include "sha2cc.h" #else #include "sha2.h" #endif |