mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
935275bb59
commit
b97ceb66e9
8 changed files with 77 additions and 1 deletions
|
@ -1,4 +1,8 @@
|
|||
Wed Feb 11 11:09:21 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Wed Feb 11 11:09:52 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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.
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
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__)
|
||||
|
|
12
ext/digest/md5/md5cc.h
Normal file
12
ext/digest/md5/md5cc.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#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
|
|
@ -4,6 +4,8 @@
|
|||
#include "digest.h"
|
||||
#if defined(MD5_USE__OPENSSL)
|
||||
#include "md5ossl.h"
|
||||
#elif defined(MD5_USE_COMMONDIGEST)
|
||||
#include "md5cc.h"
|
||||
#else
|
||||
#include "md5.h"
|
||||
#endif
|
||||
|
|
14
ext/digest/sha1/sha1cc.h
Normal file
14
ext/digest/sha1/sha1cc.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#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
|
|
@ -4,6 +4,8 @@
|
|||
#include "digest.h"
|
||||
#if defined(SHA1_USE_OPENSSL)
|
||||
#include "sha1ossl.h"
|
||||
#elif defined(SHA1_USE_COMMONDIGEST)
|
||||
#include "sha1cc.h"
|
||||
#else
|
||||
#include "sha1.h"
|
||||
#endif
|
||||
|
|
31
ext/digest/sha2/sha2cc.h
Normal file
31
ext/digest/sha2/sha2cc.h
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue