Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb
- index dbef087..5da1cc7 100644
- --- a/ext/digest/md5/extconf.rb
- +++ b/ext/digest/md5/extconf.rb
- @@ -17,7 +17,7 @@ if !with_config("bundled-md5") &&
- OpenSSL.check_func("MD5_Transform", "openssl/md5.h")
- $objs << "md5ossl.#{$OBJEXT}"
- else
- - $objs << "md5.#{$OBJEXT}"
- + $objs << "md5cc.#{$OBJEXT}"
- end
- have_header("sys/cdefs.h")
- diff --git a/ext/digest/md5/md5cc.c b/ext/digest/md5/md5cc.c
- new file mode 100644
- index 0000000..1f09e69
- --- /dev/null
- +++ b/ext/digest/md5/md5cc.c
- @@ -0,0 +1,7 @@
- +#include "md5cc.h"
- +
- +void
- +MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
- +{
- + CC_MD5_Final(digest, pctx);
- +}
- diff --git a/ext/digest/md5/md5cc.h b/ext/digest/md5/md5cc.h
- new file mode 100644
- index 0000000..1b83599
- --- /dev/null
- +++ b/ext/digest/md5/md5cc.h
- @@ -0,0 +1,18 @@
- +#ifndef MD5CC_H_INCLUDED
- +#define MD5CC_H_INCLUDED
- +
- +#include <stddef.h>
- +#include <CommonCrypto/CommonDigest.h>
- +
- +#define MD5_CTX CC_MD5_CTX
- +
- +#define MD5_DIGEST_LENGTH CC_MD5_DIGEST_LENGTH
- +#define MD5_BLOCK_LENGTH CC_MD5_BLOCK_BYTES
- +
- +#define MD5_Init CC_MD5_Init
- +#define MD5_Update CC_MD5_Update
- +#define MD5_Finish CC_MD5_Finish
- +
- +void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
- +
- +#endif
- diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
- index 3cf0c1a..b2f595b 100644
- --- a/ext/digest/md5/md5init.c
- +++ b/ext/digest/md5/md5init.c
- @@ -5,7 +5,7 @@
- #if defined(HAVE_OPENSSL_MD5_H)
- #include "md5ossl.h"
- #else
- -#include "md5.h"
- +#include "md5cc.h"
- #endif
- static const rb_digest_metadata_t md5 = {
- diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb
- index c230270..3bd0bff 100644
- --- a/ext/digest/sha1/extconf.rb
- +++ b/ext/digest/sha1/extconf.rb
- @@ -17,7 +17,7 @@ if !with_config("bundled-sha1") &&
- OpenSSL.check_func("SHA1_Transform", "openssl/sha.h")
- $objs << "sha1ossl.#{$OBJEXT}"
- else
- - $objs << "sha1.#{$OBJEXT}"
- + $objs << "sha1cc.#{$OBJEXT}"
- end
- have_header("sys/cdefs.h")
- diff --git a/ext/digest/sha1/sha1cc.c b/ext/digest/sha1/sha1cc.c
- new file mode 100644
- index 0000000..644f6ec
- --- /dev/null
- +++ b/ext/digest/sha1/sha1cc.c
- @@ -0,0 +1,20 @@
- +#include "defs.h"
- +#include "sha1cc.h"
- +
- +void
- +SHA1_Update(SHA1_CTX *ctx, const uint8_t *data, size_t len)
- +{
- + uint8_t *ptr = data;
- + size_t i;
- +
- + for (i = 0, ptr = data; i < (len / SHA1_STRIDE_SIZE); i++, ptr += SHA1_STRIDE_SIZE) {
- + CC_SHA1_Update(ctx, ptr, SHA1_STRIDE_SIZE);
- + }
- + CC_SHA1_Update(ctx, ptr, len % SHA1_STRIDE_SIZE);
- +}
- +
- +void
- +SHA1_Finish(SHA1_CTX *ctx, char *buf)
- +{
- + CC_SHA1_Final((unsigned char *)buf, ctx);
- +}
- diff --git a/ext/digest/sha1/sha1cc.h b/ext/digest/sha1/sha1cc.h
- new file mode 100644
- index 0000000..67e2876
- --- /dev/null
- +++ b/ext/digest/sha1/sha1cc.h
- @@ -0,0 +1,20 @@
- +#ifndef SHA1CC_H_INCLUDED
- +#define SHA1CC_H_INCLUDED
- +
- +#include <CommonCrypto/CommonDigest.h>
- +
- +#define SHA1_CTX CC_SHA1_CTX
- +
- +#define SHA1_BLOCK_LENGTH CC_SHA1_BLOCK_BYTES
- +#define SHA1_DIGEST_LENGTH CC_SHA1_DIGEST_LENGTH
- +
- +#define SHA1_Init CC_SHA1_Init
- +#define SHA1_Update CC_SHA1_Update_Block
- +#define SHA1_Finish CC_SHA1_Finish
- +
- +#define SHA1_STRIDE_SIZE 16384
- +
- +void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len);
- +void SHA1_Finish(SHA1_CTX *ctx, char *buf);
- +
- +#endif
- diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c
- index 56ae0fa..57b8dfa 100644
- --- a/ext/digest/sha1/sha1init.c
- +++ b/ext/digest/sha1/sha1init.c
- @@ -5,7 +5,7 @@
- #if defined(HAVE_OPENSSL_SHA_H)
- #include "sha1ossl.h"
- #else
- -#include "sha1.h"
- +#include "sha1cc.h"
- #endif
- static const rb_digest_metadata_t sha1 = {
- diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
- index e272cba..b7471d8 100644
- --- a/ext/openssl/extconf.rb
- +++ b/ext/openssl/extconf.rb
- @@ -58,9 +58,6 @@ end
- unless have_header("openssl/conf_api.h")
- raise "OpenSSL 0.9.6 or later required."
- end
- -unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
- - raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
- -end
- Logging::message "=== Checking for OpenSSL features... ===\n"
- have_func("ERR_peek_last_error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement