aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGOTOU Yuuzou <gotoyuzo@notwork.org>2003-07-16 07:03:00 +0000
committerGOTOU Yuuzou <gotoyuzo@notwork.org>2003-07-16 07:03:00 +0000
commit49bdc6251d640754717429a951a9835bf853127f (patch)
tree563fa579b59257875b62fcd9a410a81327bf90a6
parent215f3939393cd9c6733a01de96e524bc5df57e20 (diff)
downloadruby-openssl-history-49bdc6251d640754717429a951a9835bf853127f.tar.gz
*** empty log message ***
-rw-r--r--ChangeLog8
-rw-r--r--extconf.rb19
-rw-r--r--lib/net/https.rb6
-rw-r--r--ossl.h1
-rw-r--r--ossl_bn.c57
-rw-r--r--ossl_cipher.c28
-rw-r--r--ossl_x509store.c1
7 files changed, 77 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e07b83..519ea4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed, 16 Jul 2003 15:43:52 +0900 -- GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * extconf.rb: check CRYPTO_malloc for libcrypto.
+ * ossl.h: include <openssl/bn.h>.
+ * ossl_bn.c: use BN_CTX_new instead of BN_CTX_init.
+ * ossl_cipher.c: NIDs of AES were changed.
+ * ossl_x509store.c: alias add_cert add_trusted.
+ * lib/net/https.rb: follow HTTPResponse.read_new's incompatiplity.
+
Tue, 15 Jul 2003 04:48:33 +0900 -- GOTOU Yuuzou <gotoyuzo@notwork.org>
* ossl-0.1.4 released
diff --git a/extconf.rb b/extconf.rb
index fd1b944..f54b5c8 100644
--- a/extconf.rb
+++ b/extconf.rb
@@ -22,15 +22,16 @@ dir_config("openssl")
have_func("strptime", "time.h")
-if with_config("debug") or enable_config("debug") # '--enable-debug' or '--with-debug=yes'
- $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
- $CPPFLAGS += " " + "-Wall" unless $CPPFLAGS.split.include? "-Wall"
+if with_config("debug") or enable_config("debug")
+ # '--enable-debug' or '--with-debug=yes'
+ $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+ $CPPFLAGS += " " + "-Wall" unless $CPPFLAGS.split.include? "-Wall"
end
-if have_header("openssl/ssl.h")
- have_header("openssl/e_os.h")
- if have_library(CRYPTOLIB, "OpenSSL_add_all_algorithms") and have_library(SSLLIB, "SSLv23_method")
- create_makefile("openssl")
- end
+result = have_header("openssl/ssl.h")
+result &= have_library(CRYPTOLIB, "CRYPTO_malloc")
+result &= have_library(SSLLIB, "SSLv23_method")
+if result
+ have_header("openssl/e_os.h")
+ create_makefile("openssl")
end
-
diff --git a/lib/net/https.rb b/lib/net/https.rb
index 67b8561..c8e70d3 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -112,7 +112,11 @@ module Net
@socket.writeline(
sprintf('CONNECT %s:%s HTTP/%s', @address, @port, "1.0"))
@socket.writeline ''
- resp = HTTPResponse.read_new(@socket)
+ begin
+ resp = HTTPResponse.read_new(@socket) # ruby 1.8
+ rescue ArgumentError
+ resp = HTTPResponse.read_new(@socket, nil) # ruby 1.6
+ end
if resp.code != '200'
raise resp.message
end
diff --git a/ossl.h b/ossl.h
index 6485046..81df245 100644
--- a/ossl.h
+++ b/ossl.h
@@ -19,6 +19,7 @@ extern "C" {
# define OpenFile WINAPI_OpenFile
#endif
#include <errno.h>
+#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/asn1_mac.h>
#include <openssl/x509v3.h>
diff --git a/ossl_bn.c b/ossl_bn.c
index 2398bf8..fa2bca9 100644
--- a/ossl_bn.c
+++ b/ossl_bn.c
@@ -201,7 +201,7 @@ BIGNUM_BOOL1(is_odd);
{ \
BIGNUM *bn = NULL; \
BIGNUM *result = NULL; \
- BN_CTX ctx; \
+ BN_CTX *ctx; \
VALUE obj; \
\
GetBN(self, bn); \
@@ -209,11 +209,13 @@ BIGNUM_BOOL1(is_odd);
if (!(result = BN_new())) { \
OSSL_Raise(eBNError, ""); \
} \
- BN_CTX_init(&ctx); \
- if (BN_##func(result, bn, &ctx) != 1) { \
+ ctx = BN_CTX_new(); \
+ if (BN_##func(result, bn, ctx) != 1) { \
+ BN_CTX_free(ctx); \
BN_free(result); \
OSSL_Raise(eBNError, ""); \
} \
+ BN_CTX_free(ctx); \
\
WrapBN(obj, result); \
\
@@ -255,7 +257,7 @@ BIGNUM_2(sub);
{ \
BIGNUM *bn1 = NULL, *bn2 = NULL; \
BIGNUM *result = NULL; \
- BN_CTX ctx; \
+ BN_CTX *ctx; \
VALUE obj; \
\
GetBN(self, bn1); \
@@ -266,11 +268,13 @@ BIGNUM_2(sub);
if (!(result = BN_new())) { \
OSSL_Raise(eBNError, ""); \
} \
- BN_CTX_init(&ctx); \
- if (BN_##func(result, bn1, bn2, &ctx) != 1) { \
+ ctx = BN_CTX_new(); \
+ if (BN_##func(result, bn1, bn2, ctx) != 1) { \
+ BN_CTX_free(ctx); \
BN_free(result); \
OSSL_Raise(eBNError, ""); \
} \
+ BN_CTX_free(ctx); \
\
WrapBN(obj, result); \
\
@@ -286,7 +290,7 @@ ossl_bn_div(VALUE self, VALUE other)
{
BIGNUM *bn1 = NULL, *bn2 = NULL;
BIGNUM *r1 = NULL, *r2 = NULL;
- BN_CTX ctx;
+ BN_CTX *ctx;
VALUE obj1, obj2;
GetBN(self, bn1);
@@ -302,12 +306,14 @@ ossl_bn_div(VALUE self, VALUE other)
OSSL_Raise(eBNError, "");
}
- BN_CTX_init(&ctx);
- if (BN_div(r1, r2, bn1, bn2, &ctx) != 1) {
+ ctx = BN_CTX_new();
+ if (BN_div(r1, r2, bn1, bn2, ctx) != 1) {
+ BN_CTX_free(ctx);
BN_free(r1);
BN_free(r2);
OSSL_Raise(eBNError, "");
}
+ BN_CTX_free(ctx);
WrapBN(obj1, r1);
WrapBN(obj2, r2);
@@ -320,7 +326,7 @@ ossl_bn_mod_inverse(VALUE self, VALUE other)
{
BIGNUM *bn1 = NULL, *bn2 = NULL;
BIGNUM *result = NULL;
- BN_CTX ctx;
+ BN_CTX *ctx;
VALUE obj;
GetBN(self, bn1);
@@ -331,11 +337,13 @@ ossl_bn_mod_inverse(VALUE self, VALUE other)
if (!(result = BN_new())) {
OSSL_Raise(eBNError, "");
}
- BN_CTX_init(&ctx);
- if (!BN_mod_inverse(result, bn1, bn2, &ctx)) {
+ ctx = BN_CTX_new();
+ if (!BN_mod_inverse(result, bn1, bn2, ctx)) {
+ BN_CTX_free(ctx);
BN_free(result);
OSSL_Raise(eBNError, "");
}
+ BN_CTX_free(ctx);
WrapBN(obj, result);
@@ -348,7 +356,7 @@ ossl_bn_mod_inverse(VALUE self, VALUE other)
{ \
BIGNUM *bn1 = NULL, *bn2 = NULL, *bn3 = NULL; \
BIGNUM *result = NULL; \
- BN_CTX ctx; \
+ BN_CTX *ctx; \
VALUE obj; \
\
GetBN(self, bn1); \
@@ -361,11 +369,13 @@ ossl_bn_mod_inverse(VALUE self, VALUE other)
if (!(result = BN_new())) { \
OSSL_Raise(eBNError, ""); \
} \
- BN_CTX_init(&ctx); \
- if (BN_##func(result, bn1, bn2, bn3, &ctx) != 1) { \
+ ctx = BN_CTX_new(); \
+ if (BN_##func(result, bn1, bn2, bn3, ctx) != 1) { \
+ BN_CTX_free(ctx); \
BN_free(result); \
OSSL_Raise(eBNError, ""); \
} \
+ BN_CTX_free(ctx); \
\
WrapBN(obj, result); \
\
@@ -592,9 +602,10 @@ static VALUE
ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
{
BIGNUM *bn = NULL;
- BN_CTX ctx;
+ BN_CTX *ctx;
VALUE vchecks;
int checks = BN_prime_checks;
+ int ret;
rb_scan_args(argc, argv, "01", &vchecks);
@@ -603,8 +614,9 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
if (!NIL_P(vchecks))
checks = NUM2INT(vchecks);
- BN_CTX_init(&ctx);
- switch (BN_is_prime(bn, checks, NULL, &ctx, NULL)) {
+ ret = BN_is_prime(bn, checks, NULL, ctx, NULL);
+ BN_CTX_free(ctx);
+ switch (ret){
case 1:
return Qtrue;
case 0:
@@ -621,9 +633,10 @@ static VALUE
ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
{
BIGNUM *bn = NULL;
- BN_CTX ctx;
+ BN_CTX *ctx;
VALUE vchecks, vtrivdiv;
int checks = BN_prime_checks, do_trial_division = 1;
+ int ret;
rb_scan_args(argc, argv, "02", &vchecks, &vtrivdiv);
@@ -636,8 +649,10 @@ ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
if (vtrivdiv == Qfalse)
do_trial_division = 0;
- BN_CTX_init(&ctx);
- switch (BN_is_prime_fasttest(bn, checks, NULL, &ctx, NULL, do_trial_division)) {
+ ctx = BN_CTX_new();
+ ret = BN_is_prime_fasttest(bn, checks, NULL, ctx, NULL, do_trial_division);
+ BN_CTX_free(ctx);
+ switch (ret) {
case 1:
return Qtrue;
case 0:
diff --git a/ossl_cipher.c b/ossl_cipher.c
index f908257..6baa1c6 100644
--- a/ossl_cipher.c
+++ b/ossl_cipher.c
@@ -264,12 +264,16 @@ ossl_des_initialize(int argc, VALUE *argv, VALUE self)
case ECB:
nid = NID_des_ecb;
break;
+#if defined(NID_des_ede)
case EDE:
nid = NID_des_ede;
break;
+#endif
+#if defined(NID_des_ede3)
case EDE3:
nid = NID_des_ede3;
break;
+#endif
case CFB:
nid = NID_des_cfb64;
break;
@@ -541,46 +545,46 @@ ossl_aes_initialize(int argc, VALUE *argv, VALUE self)
switch (spec) {
case BIT128+ECB:
- nid = NID_aes128_ecb;
+ nid = NID_aes_128_ecb;
break;
/*
case BIT128+CFB:
- nid = NID_aes128_cfb;
+ nid = NID_aes_128_cfb;
break;
case BIT128+OFB:
- nid = NID_aes128_ofb;
+ nid = NID_aes_128_ofb;
break;
*/
case BIT128+CBC:
- nid = NID_aes128_cbc;
+ nid = NID_aes_128_cbc;
break;
case BIT192+ECB:
- nid = NID_aes192_ecb;
+ nid = NID_aes_192_ecb;
break;
/*
case BIT192+CFB:
- nid = NID_aes192_cfb;
+ nid = NID_aes_192_cfb;
break;
case BIT192+OFB:
- nid = NID_aes192_ofb;
+ nid = NID_aes_192_ofb;
break;
*/
case BIT192+CBC:
- nid = NID_aes192_cbc;
+ nid = NID_aes_192_cbc;
break;
case BIT256+ECB:
- nid = NID_aes256_ecb;
+ nid = NID_aes_256_ecb;
break;
/*
case BIT256+CFB:
- nid = NID_aes256_cfb;
+ nid = NID_aes_256_cfb;
break;
case BIT256+OFB:
- nid = NID_aes256_ofb;
+ nid = NID_aes_256_ofb;
break;
*/
case BIT256+CBC:
- nid = NID_aes256_cbc;
+ nid = NID_aes_256_cbc;
break;
default:
rb_raise(rb_eTypeError, "unsupported combination of modes");
diff --git a/ossl_x509store.c b/ossl_x509store.c
index 8dcb143..0a47407 100644
--- a/ossl_x509store.c
+++ b/ossl_x509store.c
@@ -476,6 +476,7 @@ Init_ossl_x509store(VALUE module)
rb_define_method(cX509Store, "verify_callback=", ossl_x509store_set_verify_cb, 1);
rb_define_method(cX509Store, "add_trusted", ossl_x509store_add_trusted, 1);
+ rb_define_alias(cX509Store, "add_cert", "add_trusted");
rb_define_method(cX509Store, "add_crl", ossl_x509store_add_crl, 1);
rb_define_method(cX509Store, "verify", ossl_x509store_verify, 1);