rubysl-openssl 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/ext/rubysl/openssl/extconf.rb +7 -4
- data/ext/rubysl/openssl/openssl_missing.c +2 -2
- data/ext/rubysl/openssl/ossl.c +91 -25
- data/ext/rubysl/openssl/ossl.h +3 -4
- data/ext/rubysl/openssl/ossl_asn1.c +52 -6
- data/ext/rubysl/openssl/ossl_bio.c +1 -1
- data/ext/rubysl/openssl/ossl_bn.c +37 -2
- data/ext/rubysl/openssl/ossl_cipher.c +1 -1
- data/ext/rubysl/openssl/ossl_config.c +9 -0
- data/ext/rubysl/openssl/ossl_digest.c +2 -0
- data/ext/rubysl/openssl/ossl_engine.c +158 -0
- data/ext/rubysl/openssl/ossl_hmac.c +97 -3
- data/ext/rubysl/openssl/ossl_ocsp.c +3 -3
- data/ext/rubysl/openssl/ossl_pkcs7.c +2 -2
- data/ext/rubysl/openssl/ossl_pkey.c +6 -3
- data/ext/rubysl/openssl/ossl_pkey_dh.c +4 -3
- data/ext/rubysl/openssl/ossl_pkey_dsa.c +2 -0
- data/ext/rubysl/openssl/ossl_pkey_ec.c +4 -2
- data/ext/rubysl/openssl/ossl_pkey_rsa.c +3 -2
- data/ext/rubysl/openssl/ossl_ssl.c +62 -22
- data/ext/rubysl/openssl/ossl_x509attr.c +2 -2
- data/ext/rubysl/openssl/ossl_x509cert.c +3 -3
- data/ext/rubysl/openssl/ossl_x509crl.c +4 -4
- data/ext/rubysl/openssl/ossl_x509name.c +1 -1
- data/ext/rubysl/openssl/ossl_x509req.c +2 -2
- data/ext/rubysl/openssl/ossl_x509revoked.c +2 -2
- data/ext/rubysl/openssl/ossl_x509store.c +4 -4
- data/lib/openssl/bn.rb +4 -1
- data/lib/openssl/buffering.rb +28 -20
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/config.rb +164 -5
- data/lib/openssl/digest.rb +13 -14
- data/lib/openssl/ssl.rb +58 -11
- data/lib/rubysl/openssl/version.rb +1 -1
- metadata +61 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b3988369f86f1fbb46045c54d623c57099d55c5
|
4
|
+
data.tar.gz: 35112e17b1e09c08fb9418716efae287097b3356
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc8425d85daf0d3605f1c6cac3015556df849c79d206efa71d629dbaa351473ac6c86c4bc5b17e250c50c7e62d42fab21114b38617ffcafe044a2708a3af12b2
|
7
|
+
data.tar.gz: 25dcc1ecb2117d1427d79c6f01d256e0a70e21c48a454a7ae3adfc517ec781a48384ecf27cb8423f0a912c7ef3df1b2e64b13d3ecd43572a28a11dbb8dba4c11
|
@@ -31,9 +31,6 @@ if with_config("debug") or enable_config("debug")
|
|
31
31
|
$defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
|
32
32
|
end
|
33
33
|
|
34
|
-
# Nothing we can do about these problems.
|
35
|
-
$CPPFLAGS += " -Wno-deprecated-declarations -Wno-pointer-sign"
|
36
|
-
|
37
34
|
Logging::message "=== Checking for system dependent stuff... ===\n"
|
38
35
|
have_library("nsl", "t_open")
|
39
36
|
have_library("socket", "socket")
|
@@ -61,6 +58,9 @@ end
|
|
61
58
|
unless have_header("openssl/conf_api.h")
|
62
59
|
raise "OpenSSL 0.9.6 or later required."
|
63
60
|
end
|
61
|
+
unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
|
62
|
+
raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
|
63
|
+
end
|
64
64
|
|
65
65
|
Logging::message "=== Checking for OpenSSL features... ===\n"
|
66
66
|
have_func("ERR_peek_last_error")
|
@@ -144,6 +144,7 @@ if checking_for('OpenSSL version is 0.9.7 or later') {
|
|
144
144
|
}
|
145
145
|
have_header("openssl/ocsp.h")
|
146
146
|
end
|
147
|
+
have_struct_member("CRYPTO_THREADID", "ptr", "openssl/crypto.h")
|
147
148
|
have_struct_member("EVP_CIPHER_CTX", "flags", "openssl/evp.h")
|
148
149
|
have_struct_member("EVP_CIPHER_CTX", "engine", "openssl/evp.h")
|
149
150
|
have_struct_member("X509_ATTRIBUTE", "single", "openssl/x509.h")
|
@@ -153,5 +154,7 @@ have_macro("EVP_CTRL_GCM_GET_TAG", ['openssl/evp.h']) && $defs.push("-DHAVE_AUTH
|
|
153
154
|
Logging::message "=== Checking done. ===\n"
|
154
155
|
|
155
156
|
create_header
|
156
|
-
create_makefile("openssl/openssl")
|
157
|
+
create_makefile("openssl/openssl") {|conf|
|
158
|
+
conf << "THREAD_MODEL = #{CONFIG["THREAD_MODEL"]}\n"
|
159
|
+
}
|
157
160
|
Logging::message "Done.\n"
|
@@ -10,7 +10,7 @@
|
|
10
10
|
*/
|
11
11
|
#include RUBY_EXTCONF_H
|
12
12
|
|
13
|
-
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(
|
13
|
+
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
|
14
14
|
# include <openssl/engine.h>
|
15
15
|
#endif
|
16
16
|
#include <openssl/x509_vfy.h>
|
@@ -122,7 +122,7 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in)
|
|
122
122
|
{
|
123
123
|
memcpy(out, in, sizeof(EVP_CIPHER_CTX));
|
124
124
|
|
125
|
-
#if defined(HAVE_ENGINE_ADD) && defined(
|
125
|
+
#if defined(HAVE_ENGINE_ADD) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
|
126
126
|
if (in->engine) ENGINE_add(out->engine);
|
127
127
|
if (in->cipher_data) {
|
128
128
|
out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
|
data/ext/rubysl/openssl/ossl.c
CHANGED
@@ -293,10 +293,9 @@ ossl_to_der_if_possible(VALUE obj)
|
|
293
293
|
static VALUE
|
294
294
|
ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
295
295
|
{
|
296
|
-
|
296
|
+
VALUE str = Qnil;
|
297
297
|
const char *msg;
|
298
298
|
long e;
|
299
|
-
int len = 0;
|
300
299
|
|
301
300
|
#ifdef HAVE_ERR_PEEK_LAST_ERROR
|
302
301
|
e = ERR_peek_last_error();
|
@@ -304,14 +303,20 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
|
304
303
|
e = ERR_peek_error();
|
305
304
|
#endif
|
306
305
|
if (fmt) {
|
307
|
-
|
306
|
+
str = rb_sprintf(fmt, args);
|
308
307
|
}
|
309
|
-
if (
|
308
|
+
if (e) {
|
310
309
|
if (dOSSL == Qtrue) /* FULL INFO */
|
311
310
|
msg = ERR_error_string(e, NULL);
|
312
311
|
else
|
313
312
|
msg = ERR_reason_error_string(e);
|
314
|
-
|
313
|
+
if (NIL_P(str)) {
|
314
|
+
if (msg) str = rb_str_new_cstr(msg);
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
|
318
|
+
rb_str_cat2(str, msg ? msg : "(null)");
|
319
|
+
}
|
315
320
|
}
|
316
321
|
if (dOSSL == Qtrue){ /* show all errors on the stack */
|
317
322
|
while ((e = ERR_get_error()) != 0){
|
@@ -320,8 +325,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
|
320
325
|
}
|
321
326
|
ERR_clear_error();
|
322
327
|
|
323
|
-
if(
|
324
|
-
return
|
328
|
+
if (NIL_P(str)) str = rb_str_new(0, 0);
|
329
|
+
return rb_exc_new3(exc, str);
|
325
330
|
}
|
326
331
|
|
327
332
|
void
|
@@ -461,33 +466,89 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
|
|
461
466
|
/**
|
462
467
|
* Stores locks needed for OpenSSL thread safety
|
463
468
|
*/
|
464
|
-
|
469
|
+
#include "ruby/thread_native.h"
|
470
|
+
static rb_nativethread_lock_t *ossl_locks;
|
471
|
+
|
472
|
+
static void
|
473
|
+
ossl_lock_unlock(int mode, rb_nativethread_lock_t *lock)
|
474
|
+
{
|
475
|
+
if (mode & CRYPTO_LOCK) {
|
476
|
+
rb_nativethread_lock_lock(lock);
|
477
|
+
} else {
|
478
|
+
rb_nativethread_lock_unlock(lock);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
|
482
|
+
static void
|
483
|
+
ossl_lock_callback(int mode, int type, const char *file, int line)
|
484
|
+
{
|
485
|
+
ossl_lock_unlock(mode, &ossl_locks[type]);
|
486
|
+
}
|
487
|
+
|
488
|
+
struct CRYPTO_dynlock_value {
|
489
|
+
rb_nativethread_lock_t lock;
|
490
|
+
};
|
491
|
+
|
492
|
+
static struct CRYPTO_dynlock_value *
|
493
|
+
ossl_dyn_create_callback(const char *file, int line)
|
494
|
+
{
|
495
|
+
struct CRYPTO_dynlock_value *dynlock = (struct CRYPTO_dynlock_value *)OPENSSL_malloc((int)sizeof(struct CRYPTO_dynlock_value));
|
496
|
+
rb_nativethread_lock_initialize(&dynlock->lock);
|
497
|
+
return dynlock;
|
498
|
+
}
|
499
|
+
|
500
|
+
static void
|
501
|
+
ossl_dyn_lock_callback(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
|
502
|
+
{
|
503
|
+
ossl_lock_unlock(mode, &l->lock);
|
504
|
+
}
|
465
505
|
|
466
|
-
static void
|
506
|
+
static void
|
507
|
+
ossl_dyn_destroy_callback(struct CRYPTO_dynlock_value *l, const char *file, int line)
|
467
508
|
{
|
468
|
-
|
469
|
-
|
470
|
-
} else {
|
471
|
-
rb_mutex_unlock(ossl_locks[type]);
|
472
|
-
}
|
509
|
+
rb_nativethread_lock_destroy(&l->lock);
|
510
|
+
OPENSSL_free(l);
|
473
511
|
}
|
474
512
|
|
513
|
+
#ifdef HAVE_CRYPTO_THREADID_PTR
|
514
|
+
static void ossl_threadid_func(CRYPTO_THREADID *id)
|
515
|
+
{
|
516
|
+
/* register native thread id */
|
517
|
+
CRYPTO_THREADID_set_pointer(id, (void *)rb_nativethread_self());
|
518
|
+
}
|
519
|
+
#else
|
475
520
|
static unsigned long ossl_thread_id(void)
|
476
521
|
{
|
477
|
-
|
522
|
+
/* before OpenSSL 1.0, this is 'unsigned long' */
|
523
|
+
return (unsigned long)rb_nativethread_self();
|
478
524
|
}
|
525
|
+
#endif
|
479
526
|
|
480
527
|
static void Init_ossl_locks(void)
|
481
528
|
{
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
529
|
+
int i;
|
530
|
+
int num_locks = CRYPTO_num_locks();
|
531
|
+
|
532
|
+
if ((unsigned)num_locks >= INT_MAX / (int)sizeof(VALUE)) {
|
533
|
+
rb_raise(rb_eRuntimeError, "CRYPTO_num_locks() is too big: %d", num_locks);
|
534
|
+
}
|
535
|
+
ossl_locks = (rb_nativethread_lock_t *) OPENSSL_malloc(num_locks * (int)sizeof(rb_nativethread_lock_t));
|
536
|
+
if (!ossl_locks) {
|
537
|
+
rb_raise(rb_eNoMemError, "CRYPTO_num_locks() is too big: %d", num_locks);
|
538
|
+
}
|
539
|
+
for (i = 0; i < num_locks; i++) {
|
540
|
+
rb_nativethread_lock_initialize(&ossl_locks[i]);
|
541
|
+
}
|
542
|
+
|
543
|
+
#ifdef HAVE_CRYPTO_THREADID_PTR
|
544
|
+
CRYPTO_THREADID_set_callback(ossl_threadid_func);
|
545
|
+
#else
|
546
|
+
CRYPTO_set_id_callback(ossl_thread_id);
|
547
|
+
#endif
|
548
|
+
CRYPTO_set_locking_callback(ossl_lock_callback);
|
549
|
+
CRYPTO_set_dynlock_create_callback(ossl_dyn_create_callback);
|
550
|
+
CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback);
|
551
|
+
CRYPTO_set_dynlock_destroy_callback(ossl_dyn_destroy_callback);
|
491
552
|
}
|
492
553
|
|
493
554
|
/*
|
@@ -788,7 +849,7 @@ static void Init_ossl_locks(void)
|
|
788
849
|
* cipher = OpenSSL::Cipher::Cipher.new 'AES-128-CBC'
|
789
850
|
*
|
790
851
|
* open 'ca_key.pem', 'w', 0400 do |io|
|
791
|
-
* io.write
|
852
|
+
* io.write ca_key.export(cipher, pass_phrase)
|
792
853
|
* end
|
793
854
|
*
|
794
855
|
* === CA Certificate
|
@@ -1021,6 +1082,11 @@ Init_openssl()
|
|
1021
1082
|
*/
|
1022
1083
|
rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
|
1023
1084
|
|
1085
|
+
/*
|
1086
|
+
* Version of OpenSSL the ruby OpenSSL extension is running with
|
1087
|
+
*/
|
1088
|
+
rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
|
1089
|
+
|
1024
1090
|
/*
|
1025
1091
|
* Version number of OpenSSL the ruby OpenSSL extension was built with
|
1026
1092
|
* (base 16)
|
data/ext/rubysl/openssl/ossl.h
CHANGED
@@ -28,7 +28,6 @@ extern "C" {
|
|
28
28
|
#if defined(RFILE) /*&& !defined(OSSL_DEBUG)*/
|
29
29
|
# undef RFILE
|
30
30
|
#endif
|
31
|
-
#define RSTRING_NOT_MODIFIED 1
|
32
31
|
#include <ruby.h>
|
33
32
|
#include <ruby/io.h>
|
34
33
|
#include <ruby/thread.h>
|
@@ -67,7 +66,7 @@ extern "C" {
|
|
67
66
|
#include <openssl/conf_api.h>
|
68
67
|
#undef X509_NAME
|
69
68
|
#undef PKCS7_SIGNER_INFO
|
70
|
-
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(
|
69
|
+
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
|
71
70
|
# define OSSL_ENGINE_ENABLED
|
72
71
|
# include <openssl/engine.h>
|
73
72
|
#endif
|
@@ -97,14 +96,14 @@ extern VALUE eOSSLError;
|
|
97
96
|
#define OSSL_Check_Kind(obj, klass) do {\
|
98
97
|
if (!rb_obj_is_kind_of((obj), (klass))) {\
|
99
98
|
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
|
100
|
-
rb_obj_classname(obj),
|
99
|
+
rb_obj_classname(obj), RSTRING_PTR(rb_class_name(klass)));\
|
101
100
|
}\
|
102
101
|
} while (0)
|
103
102
|
|
104
103
|
#define OSSL_Check_Instance(obj, klass) do {\
|
105
104
|
if (!rb_obj_is_instance_of((obj), (klass))) {\
|
106
105
|
ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
|
107
|
-
rb_obj_classname(obj),
|
106
|
+
rb_obj_classname(obj), RSTRING_PTR(rb_class_name(klass)));\
|
108
107
|
}\
|
109
108
|
} while (0)
|
110
109
|
|
@@ -33,15 +33,22 @@ asn1time_to_time(ASN1_TIME *time)
|
|
33
33
|
{
|
34
34
|
struct tm tm;
|
35
35
|
VALUE argv[6];
|
36
|
+
int count;
|
36
37
|
|
37
38
|
if (!time || !time->data) return Qnil;
|
38
39
|
memset(&tm, 0, sizeof(struct tm));
|
39
40
|
|
40
41
|
switch (time->type) {
|
41
42
|
case V_ASN1_UTCTIME:
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
|
44
|
+
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
|
45
|
+
&tm.tm_sec);
|
46
|
+
|
47
|
+
if (count == 5) {
|
48
|
+
tm.tm_sec = 0;
|
49
|
+
} else if (count != 6) {
|
50
|
+
ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
|
51
|
+
time->data);
|
45
52
|
}
|
46
53
|
if (tm.tm_year < 69) {
|
47
54
|
tm.tm_year += 2000;
|
@@ -618,7 +625,7 @@ ossl_asn1_default_tag(VALUE obj)
|
|
618
625
|
tmp_class = rb_class_superclass(tmp_class);
|
619
626
|
}
|
620
627
|
ossl_raise(eASN1Error, "universal tag for %s not found",
|
621
|
-
|
628
|
+
rb_obj_class(obj));
|
622
629
|
|
623
630
|
return -1; /* dummy */
|
624
631
|
}
|
@@ -726,7 +733,7 @@ ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
|
|
726
733
|
}
|
727
734
|
|
728
735
|
static VALUE
|
729
|
-
join_der_i(
|
736
|
+
join_der_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, str))
|
730
737
|
{
|
731
738
|
i = ossl_to_der_if_possible(i);
|
732
739
|
StringValue(i);
|
@@ -1143,7 +1150,7 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
|
|
1143
1150
|
}
|
1144
1151
|
if(!SYMBOL_P(tag_class))
|
1145
1152
|
ossl_raise(eASN1Error, "invalid tag class");
|
1146
|
-
if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
|
1153
|
+
if(!NIL_P(tagging) && SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
|
1147
1154
|
ossl_raise(eASN1Error, "tag number for Universal too large");
|
1148
1155
|
}
|
1149
1156
|
else{
|
@@ -1351,6 +1358,17 @@ ossl_asn1cons_each(VALUE self)
|
|
1351
1358
|
return self;
|
1352
1359
|
}
|
1353
1360
|
|
1361
|
+
/*
|
1362
|
+
* call-seq:
|
1363
|
+
* ObjectId.register(object_id, short_name, long_name)
|
1364
|
+
*
|
1365
|
+
* This adds a new ObjectId to the internal tables. Where +object_id+ is the
|
1366
|
+
* numerical form, +short_name+ is the short name, and +long_name+ is the long
|
1367
|
+
* name.
|
1368
|
+
*
|
1369
|
+
* Returns +true+ if successful. Raises an ASN1Error otherwise.
|
1370
|
+
*
|
1371
|
+
*/
|
1354
1372
|
static VALUE
|
1355
1373
|
ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
|
1356
1374
|
{
|
@@ -1364,6 +1382,14 @@ ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
|
|
1364
1382
|
return Qtrue;
|
1365
1383
|
}
|
1366
1384
|
|
1385
|
+
/* Document-method: OpenSSL::ASN1::ObjectId#sn
|
1386
|
+
*
|
1387
|
+
* The short name of the ObjectId, as defined in +openssl/objects.h+.
|
1388
|
+
*/
|
1389
|
+
/* Document-method: OpenSSL::ASN1::ObjectId#short_name
|
1390
|
+
*
|
1391
|
+
* #short_name is an alias to #sn
|
1392
|
+
*/
|
1367
1393
|
static VALUE
|
1368
1394
|
ossl_asn1obj_get_sn(VALUE self)
|
1369
1395
|
{
|
@@ -1377,6 +1403,14 @@ ossl_asn1obj_get_sn(VALUE self)
|
|
1377
1403
|
return ret;
|
1378
1404
|
}
|
1379
1405
|
|
1406
|
+
/* Document-method: OpenSSL::ASN1::ObjectId#ln
|
1407
|
+
*
|
1408
|
+
* The long name of the ObjectId, as defined in +openssl/objects.h+.
|
1409
|
+
*/
|
1410
|
+
/* Document-method: OpenSSL::ASN1::ObjectId.long_name
|
1411
|
+
*
|
1412
|
+
* #long_name is an alias to #ln
|
1413
|
+
*/
|
1380
1414
|
static VALUE
|
1381
1415
|
ossl_asn1obj_get_ln(VALUE self)
|
1382
1416
|
{
|
@@ -1390,6 +1424,10 @@ ossl_asn1obj_get_ln(VALUE self)
|
|
1390
1424
|
return ret;
|
1391
1425
|
}
|
1392
1426
|
|
1427
|
+
/* Document-method: OpenSSL::ASN1::ObjectId#oid
|
1428
|
+
*
|
1429
|
+
* The object identifier as a String.
|
1430
|
+
*/
|
1393
1431
|
static VALUE
|
1394
1432
|
ossl_asn1obj_get_oid(VALUE self)
|
1395
1433
|
{
|
@@ -1771,6 +1809,10 @@ Init_ossl_asn1()
|
|
1771
1809
|
*
|
1772
1810
|
* == OpenSSL::ASN1::ObjectId
|
1773
1811
|
*
|
1812
|
+
* While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId, it is
|
1813
|
+
* not typically allocated this way, but rather that are received from
|
1814
|
+
* parsed ASN1 encodings.
|
1815
|
+
*
|
1774
1816
|
* === Additional attributes
|
1775
1817
|
* * +sn+: the short name as defined in <openssl/objects.h>.
|
1776
1818
|
* * +ln+: the long name as defined in <openssl/objects.h>.
|
@@ -1910,6 +1952,10 @@ do{\
|
|
1910
1952
|
OSSL_ASN1_DEFINE_CLASS(EndOfContent, Data);
|
1911
1953
|
|
1912
1954
|
|
1955
|
+
/* Document-class: OpenSSL::ASN1::ObjectId
|
1956
|
+
*
|
1957
|
+
* Represents the primitive object id for OpenSSL::ASN1
|
1958
|
+
*/
|
1913
1959
|
#if 0
|
1914
1960
|
cASN1ObjectId = rb_define_class_under(mASN1, "ObjectId", cASN1Primitive); /* let rdoc know */
|
1915
1961
|
#endif
|
@@ -106,6 +106,7 @@ ossl_bn_alloc(VALUE klass)
|
|
106
106
|
* call-seq:
|
107
107
|
* BN.new => aBN
|
108
108
|
* BN.new(bn) => aBN
|
109
|
+
* BN.new(integer) => aBN
|
109
110
|
* BN.new(string) => aBN
|
110
111
|
* BN.new(string, 0 | 2 | 10 | 16) => aBN
|
111
112
|
*/
|
@@ -120,6 +121,40 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|
120
121
|
base = NUM2INT(bs);
|
121
122
|
}
|
122
123
|
|
124
|
+
if (RB_TYPE_P(str, T_FIXNUM)) {
|
125
|
+
long i;
|
126
|
+
unsigned char bin[sizeof(long)];
|
127
|
+
long n = FIX2LONG(str);
|
128
|
+
unsigned long un = labs(n);
|
129
|
+
|
130
|
+
for (i = sizeof(long) - 1; 0 <= i; i--) {
|
131
|
+
bin[i] = un&0xff;
|
132
|
+
un >>= 8;
|
133
|
+
}
|
134
|
+
|
135
|
+
GetBN(self, bn);
|
136
|
+
if (!BN_bin2bn(bin, sizeof(bin), bn)) {
|
137
|
+
ossl_raise(eBNError, NULL);
|
138
|
+
}
|
139
|
+
if (n < 0) BN_set_negative(bn, 1);
|
140
|
+
return self;
|
141
|
+
}
|
142
|
+
else if (RB_TYPE_P(str, T_BIGNUM)) {
|
143
|
+
int len = rb_big_bytes_used(str);
|
144
|
+
unsigned char* bin = (unsigned char*)XMALLOC(len);
|
145
|
+
|
146
|
+
rb_big_pack(str, (unsigned long*)bin, len / sizeof(long));
|
147
|
+
|
148
|
+
GetBN(self, bn);
|
149
|
+
if (!BN_bin2bn(bin, len, bn)) {
|
150
|
+
XFREE(bin);
|
151
|
+
ossl_raise(eBNError, NULL);
|
152
|
+
}
|
153
|
+
XFREE(bin);
|
154
|
+
|
155
|
+
if (!RBIGNUM_SIGN(str)) BN_set_negative(bn, 1);
|
156
|
+
return self;
|
157
|
+
}
|
123
158
|
if (RTEST(rb_obj_is_kind_of(str, cBN))) {
|
124
159
|
BIGNUM *other;
|
125
160
|
|
@@ -226,10 +261,10 @@ ossl_bn_to_i(VALUE self)
|
|
226
261
|
|
227
262
|
GetBN(self, bn);
|
228
263
|
|
229
|
-
if (!(txt =
|
264
|
+
if (!(txt = BN_bn2hex(bn))) {
|
230
265
|
ossl_raise(eBNError, NULL);
|
231
266
|
}
|
232
|
-
num = rb_cstr_to_inum(txt,
|
267
|
+
num = rb_cstr_to_inum(txt, 16, Qtrue);
|
233
268
|
OPENSSL_free(txt);
|
234
269
|
|
235
270
|
return num;
|
@@ -213,7 +213,7 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
|
|
213
213
|
* We deprecated the arguments for this method, but we decided
|
214
214
|
* keeping this behaviour for backward compatibility.
|
215
215
|
*/
|
216
|
-
|
216
|
+
VALUE cname = rb_class_path(rb_obj_class(self));
|
217
217
|
rb_warn("arguments for %s#encrypt and %s#decrypt were deprecated; "
|
218
218
|
"use %s#pkcs5_keyivgen to derive key and IV",
|
219
219
|
cname, cname, cname);
|
@@ -15,6 +15,11 @@
|
|
15
15
|
* Classes
|
16
16
|
*/
|
17
17
|
VALUE cConfig;
|
18
|
+
/* Document-class: OpenSSL::ConfigError
|
19
|
+
*
|
20
|
+
* General error for openssl library configuration files. Including formating,
|
21
|
+
* parsing errors, etc.
|
22
|
+
*/
|
18
23
|
VALUE eConfigError;
|
19
24
|
|
20
25
|
/*
|
@@ -55,6 +60,10 @@ GetConfigPtr(VALUE obj)
|
|
55
60
|
return conf;
|
56
61
|
}
|
57
62
|
|
63
|
+
/* Document-const: DEFAULT_CONFIG_FILE
|
64
|
+
*
|
65
|
+
* The default system configuration file for openssl
|
66
|
+
*/
|
58
67
|
|
59
68
|
/*
|
60
69
|
* INIT
|