ruby-changes:37484
From: nobu <ko1@a...>
Date: Wed, 11 Feb 2015 11:10:01 +0900 (JST)
Subject: [ruby-changes:37484] nobu:r49565 (trunk): digest: CommonDigest
nobu 2015-02-11 11:09:55 +0900 (Wed, 11 Feb 2015) New Revision: 49565 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49565 Log: digest: CommonDigest * ext/digest/digest_conf.rb (digest_conf): check for CommonDigest. * ext/digest/*/*cc.h: for Apple CommonCrypto/CommonDigest.h. Added files: trunk/ext/digest/md5/md5cc.h trunk/ext/digest/sha1/sha1cc.h trunk/ext/digest/sha2/sha2cc.h Modified files: trunk/ChangeLog trunk/ext/digest/digest_conf.rb trunk/ext/digest/md5/md5init.c trunk/ext/digest/sha1/sha1init.c trunk/ext/digest/sha2/sha2init.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49564) +++ ChangeLog (revision 49565) @@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Wed Feb 11 11:09:21 2015 Nobuyoshi Nakada <nobu@r...> +Wed Feb 11 11:09:52 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/digest/digest_conf.rb (digest_conf): check for CommonDigest. + + * ext/digest/*/*cc.h: for Apple CommonCrypto/CommonDigest.h. * ext/digest/digest.h (DEFINE_FINISH_FUNC_FROM_FINAL): macro for finish functions, by inverting arguments order. Index: ext/digest/md5/md5cc.h =================================================================== --- ext/digest/md5/md5cc.h (revision 0) +++ ext/digest/md5/md5cc.h (revision 49565) @@ -0,0 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/md5/md5cc.h#L1 +#define COMMON_DIGEST_FOR_OPENSSL 1 +#include <CommonCrypto/CommonDigest.h> + +#define MD5_BLOCK_LENGTH CC_MD5_BLOCK_BYTES + +static DEFINE_UPDATE_FUNC_FOR_UINT(MD5); +static DEFINE_FINISH_FUNC_FROM_FINAL(MD5); + +#undef MD5_Update +#undef MD5_Finish +#define MD5_Update rb_digest_MD5_update +#define MD5_Finish rb_digest_MD5_finish Property changes on: ext/digest/md5/md5cc.h ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/digest/md5/md5init.c =================================================================== --- ext/digest/md5/md5init.c (revision 49564) +++ ext/digest/md5/md5init.c (revision 49565) @@ -4,6 +4,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/md5/md5init.c#L4 #include "digest.h" #if defined(MD5_USE__OPENSSL) #include "md5ossl.h" +#elif defined(MD5_USE_COMMONDIGEST) +#include "md5cc.h" #else #include "md5.h" #endif Index: ext/digest/digest_conf.rb =================================================================== --- ext/digest/digest_conf.rb (revision 49564) +++ ext/digest/digest_conf.rb (revision 49565) @@ -1,5 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/digest_conf.rb#L1 def digest_conf(name, hdr = name, funcs = nil) unless with_config("bundled-#{name}") + cc = with_config("common-digest") + if cc == true or /\b#{name}\b/ =~ cc + if File.exist?("#$srcdir/#{name}cc.h") and + have_header("CommonCrypto/CommonDigest.h") + $defs << "-D#{name.upcase}_USE_COMMONDIGEST" + return :commondigest + end + end + dir_config("openssl") pkg_config("openssl") require File.expand_path('../../openssl/deprecation', __FILE__) Index: ext/digest/sha1/sha1init.c =================================================================== --- ext/digest/sha1/sha1init.c (revision 49564) +++ ext/digest/sha1/sha1init.c (revision 49565) @@ -4,6 +4,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha1/sha1init.c#L4 #include "digest.h" #if defined(SHA1_USE_OPENSSL) #include "sha1ossl.h" +#elif defined(SHA1_USE_COMMONDIGEST) +#include "sha1cc.h" #else #include "sha1.h" #endif Index: ext/digest/sha1/sha1cc.h =================================================================== --- ext/digest/sha1/sha1cc.h (revision 0) +++ ext/digest/sha1/sha1cc.h (revision 49565) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha1/sha1cc.h#L1 +#define COMMON_DIGEST_FOR_OPENSSL 1 +#include <CommonCrypto/CommonDigest.h> + +#define SHA1_BLOCK_LENGTH CC_SHA1_BLOCK_BYTES +#define SHA1_DIGEST_LENGTH CC_SHA1_DIGEST_LENGTH +#define SHA1_CTX CC_SHA1_CTX + +static DEFINE_UPDATE_FUNC_FOR_UINT(SHA1); +static DEFINE_FINISH_FUNC_FROM_FINAL(SHA1); + +#undef SHA1_Update +#undef SHA1_Finish +#define SHA1_Update rb_digest_SHA1_update +#define SHA1_Finish rb_digest_SHA1_finish Property changes on: ext/digest/sha1/sha1cc.h ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/digest/sha2/sha2init.c =================================================================== --- ext/digest/sha2/sha2init.c (revision 49564) +++ ext/digest/sha2/sha2init.c (revision 49565) @@ -4,6 +4,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/sha2init.c#L4 #include "digest.h" #if defined(SHA2_USE_OPENSSL) #include "sha2ossl.h" +#elif defined(SHA2_USE_COMMONDIGEST) +#include "sha2cc.h" #else #include "sha2.h" #endif Index: ext/digest/sha2/sha2cc.h =================================================================== --- ext/digest/sha2/sha2cc.h (revision 0) +++ ext/digest/sha2/sha2cc.h (revision 49565) @@ -0,0 +1,31 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/sha2cc.h#L1 +#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 Property changes on: ext/digest/sha2/sha2cc.h ___________________________________________________________________ Added: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/