openssl 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +180 -29
- data/History.md +69 -42
- data/README.md +11 -7
- data/ext/openssl/extconf.rb +6 -5
- data/ext/openssl/openssl_missing.c +1 -2
- data/ext/openssl/openssl_missing.h +1 -28
- data/ext/openssl/ossl.c +8 -10
- data/ext/openssl/ossl.h +13 -10
- data/ext/openssl/ossl_asn1.c +77 -273
- data/ext/openssl/ossl_asn1.h +1 -19
- data/ext/openssl/ossl_bio.c +1 -1
- data/ext/openssl/ossl_bio.h +1 -1
- data/ext/openssl/ossl_bn.c +12 -12
- data/ext/openssl/ossl_bn.h +1 -2
- data/ext/openssl/ossl_cipher.c +5 -5
- data/ext/openssl/ossl_cipher.h +1 -4
- data/ext/openssl/ossl_config.c +10 -9
- data/ext/openssl/ossl_config.h +1 -1
- data/ext/openssl/ossl_digest.c +39 -21
- data/ext/openssl/ossl_digest.h +1 -4
- data/ext/openssl/ossl_engine.c +3 -3
- data/ext/openssl/ossl_engine.h +1 -4
- data/ext/openssl/ossl_hmac.c +3 -3
- data/ext/openssl/ossl_hmac.h +1 -4
- data/ext/openssl/ossl_kdf.c +5 -5
- data/ext/openssl/ossl_ns_spki.c +13 -12
- data/ext/openssl/ossl_ns_spki.h +1 -5
- data/ext/openssl/ossl_ocsp.c +16 -16
- data/ext/openssl/ossl_ocsp.h +1 -8
- data/ext/openssl/ossl_pkcs12.c +54 -3
- data/ext/openssl/ossl_pkcs12.h +1 -4
- data/ext/openssl/ossl_pkcs7.c +69 -22
- data/ext/openssl/ossl_pkcs7.h +2 -22
- data/ext/openssl/ossl_pkey.c +22 -63
- data/ext/openssl/ossl_pkey.h +3 -14
- data/ext/openssl/ossl_pkey_dh.c +2 -4
- data/ext/openssl/ossl_pkey_dsa.c +2 -4
- data/ext/openssl/ossl_pkey_ec.c +6 -8
- data/ext/openssl/ossl_pkey_rsa.c +2 -4
- data/ext/openssl/ossl_provider.c +3 -1
- data/ext/openssl/ossl_rand.c +3 -3
- data/ext/openssl/ossl_rand.h +1 -4
- data/ext/openssl/ossl_ssl.c +71 -52
- data/ext/openssl/ossl_ssl.h +1 -1
- data/ext/openssl/ossl_ts.c +77 -19
- data/ext/openssl/ossl_ts.h +1 -1
- data/ext/openssl/ossl_x509.c +1 -1
- data/ext/openssl/ossl_x509.h +7 -26
- data/ext/openssl/ossl_x509attr.c +30 -32
- data/ext/openssl/ossl_x509cert.c +48 -9
- data/ext/openssl/ossl_x509crl.c +13 -9
- data/ext/openssl/ossl_x509ext.c +12 -21
- data/ext/openssl/ossl_x509name.c +8 -10
- data/ext/openssl/ossl_x509req.c +10 -6
- data/ext/openssl/ossl_x509revoked.c +5 -6
- data/ext/openssl/ossl_x509store.c +21 -14
- data/lib/openssl/asn1.rb +188 -0
- data/lib/openssl/bn.rb +1 -1
- data/lib/openssl/buffering.rb +13 -3
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/digest.rb +1 -1
- data/lib/openssl/marshal.rb +1 -1
- data/lib/openssl/ssl.rb +68 -4
- data/lib/openssl/version.rb +1 -1
- data/lib/openssl/x509.rb +1 -1
- data/lib/openssl.rb +2 -1
- metadata +9 -4
- /data/{LICENSE.txt → COPYING} +0 -0
data/ext/openssl/ossl_bn.c
CHANGED
|
@@ -5,15 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
|
|
11
11
|
#include "ossl.h"
|
|
12
12
|
|
|
13
|
-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
14
|
-
#include <ruby/ractor.h>
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
13
|
#define NewBN(klass) \
|
|
18
14
|
TypedData_Wrap_Struct((klass), &ossl_bn_type, 0)
|
|
19
15
|
#define SetBN(obj, bn) do { \
|
|
@@ -41,7 +37,7 @@ static const rb_data_type_t ossl_bn_type = {
|
|
|
41
37
|
{
|
|
42
38
|
0, ossl_bn_free,
|
|
43
39
|
},
|
|
44
|
-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
|
40
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
/*
|
|
@@ -53,7 +49,7 @@ VALUE cBN;
|
|
|
53
49
|
*
|
|
54
50
|
* Generic Error for all of OpenSSL::BN (big num)
|
|
55
51
|
*/
|
|
56
|
-
VALUE eBNError;
|
|
52
|
+
static VALUE eBNError;
|
|
57
53
|
|
|
58
54
|
/*
|
|
59
55
|
* Public
|
|
@@ -156,19 +152,19 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
|
|
|
156
152
|
*/
|
|
157
153
|
|
|
158
154
|
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
159
|
-
void
|
|
155
|
+
static void
|
|
160
156
|
ossl_bn_ctx_free(void *ptr)
|
|
161
157
|
{
|
|
162
158
|
BN_CTX *ctx = (BN_CTX *)ptr;
|
|
163
159
|
BN_CTX_free(ctx);
|
|
164
160
|
}
|
|
165
161
|
|
|
166
|
-
struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
|
|
162
|
+
static struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
|
|
167
163
|
NULL, // mark
|
|
168
164
|
ossl_bn_ctx_free,
|
|
169
165
|
};
|
|
170
166
|
|
|
171
|
-
rb_ractor_local_key_t ossl_bn_ctx_key;
|
|
167
|
+
static rb_ractor_local_key_t ossl_bn_ctx_key;
|
|
172
168
|
|
|
173
169
|
BN_CTX *
|
|
174
170
|
ossl_bn_ctx_get(void)
|
|
@@ -244,7 +240,7 @@ ossl_bn_alloc(VALUE klass)
|
|
|
244
240
|
* number.
|
|
245
241
|
* - +10+ - Decimal number representation, with a leading '-' for a negative
|
|
246
242
|
* number.
|
|
247
|
-
* - +16+ -
|
|
243
|
+
* - +16+ - Hexadecimal number representation, with a leading '-' for a
|
|
248
244
|
* negative number.
|
|
249
245
|
*/
|
|
250
246
|
static VALUE
|
|
@@ -263,6 +259,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
263
259
|
ossl_raise(rb_eArgError, "invalid argument");
|
|
264
260
|
}
|
|
265
261
|
|
|
262
|
+
rb_check_frozen(self);
|
|
266
263
|
if (RB_INTEGER_TYPE_P(str)) {
|
|
267
264
|
GetBN(self, bn);
|
|
268
265
|
integer_to_bnptr(str, bn);
|
|
@@ -326,7 +323,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
326
323
|
* the bignum is ignored.
|
|
327
324
|
* - +10+ - Decimal number representation, with a leading '-' for a negative
|
|
328
325
|
* bignum.
|
|
329
|
-
* - +16+ -
|
|
326
|
+
* - +16+ - Hexadecimal number representation, with a leading '-' for a
|
|
330
327
|
* negative bignum.
|
|
331
328
|
*/
|
|
332
329
|
static VALUE
|
|
@@ -693,6 +690,7 @@ BIGNUM_3c(mod_exp)
|
|
|
693
690
|
ossl_bn_##func(VALUE self, VALUE bit) \
|
|
694
691
|
{ \
|
|
695
692
|
BIGNUM *bn; \
|
|
693
|
+
rb_check_frozen(self); \
|
|
696
694
|
GetBN(self, bn); \
|
|
697
695
|
if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
|
|
698
696
|
ossl_raise(eBNError, NULL); \
|
|
@@ -782,6 +780,7 @@ BIGNUM_SHIFT(rshift)
|
|
|
782
780
|
{ \
|
|
783
781
|
BIGNUM *bn; \
|
|
784
782
|
int b; \
|
|
783
|
+
rb_check_frozen(self); \
|
|
785
784
|
b = NUM2INT(bits); \
|
|
786
785
|
GetBN(self, bn); \
|
|
787
786
|
if (BN_##func(bn, bn, b) <= 0) \
|
|
@@ -1191,6 +1190,7 @@ ossl_bn_set_flags(VALUE self, VALUE arg)
|
|
|
1191
1190
|
BIGNUM *bn;
|
|
1192
1191
|
GetBN(self, bn);
|
|
1193
1192
|
|
|
1193
|
+
rb_check_frozen(self);
|
|
1194
1194
|
BN_set_flags(bn, NUM2INT(arg));
|
|
1195
1195
|
return Qnil;
|
|
1196
1196
|
}
|
data/ext/openssl/ossl_bn.h
CHANGED
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#if !defined(_OSSL_BN_H_)
|
|
11
11
|
#define _OSSL_BN_H_
|
|
12
12
|
|
|
13
13
|
extern VALUE cBN;
|
|
14
|
-
extern VALUE eBNError;
|
|
15
14
|
|
|
16
15
|
BN_CTX *ossl_bn_ctx_get(void);
|
|
17
16
|
#define ossl_bn_ctx ossl_bn_ctx_get()
|
data/ext/openssl/ossl_cipher.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
/*
|
|
31
31
|
* Classes
|
|
32
32
|
*/
|
|
33
|
-
VALUE cCipher;
|
|
34
|
-
VALUE eCipherError;
|
|
33
|
+
static VALUE cCipher;
|
|
34
|
+
static VALUE eCipherError;
|
|
35
35
|
static ID id_auth_tag_len, id_key_set;
|
|
36
36
|
|
|
37
37
|
static VALUE ossl_cipher_alloc(VALUE klass);
|
|
@@ -457,8 +457,8 @@ ossl_cipher_final(VALUE self)
|
|
|
457
457
|
* call-seq:
|
|
458
458
|
* cipher.name -> string
|
|
459
459
|
*
|
|
460
|
-
* Returns the name of the cipher which may differ slightly from the
|
|
461
|
-
* name provided.
|
|
460
|
+
* Returns the short name of the cipher which may differ slightly from the
|
|
461
|
+
* original name provided.
|
|
462
462
|
*/
|
|
463
463
|
static VALUE
|
|
464
464
|
ossl_cipher_name(VALUE self)
|
data/ext/openssl/ossl_cipher.h
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#if !defined(_OSSL_CIPHER_H_)
|
|
11
11
|
#define _OSSL_CIPHER_H_
|
|
12
12
|
|
|
13
|
-
extern VALUE cCipher;
|
|
14
|
-
extern VALUE eCipherError;
|
|
15
|
-
|
|
16
13
|
const EVP_CIPHER *ossl_evp_get_cipherbyname(VALUE);
|
|
17
14
|
VALUE ossl_cipher_new(const EVP_CIPHER *);
|
|
18
15
|
void Init_ossl_cipher(void);
|
data/ext/openssl/ossl_config.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ static const rb_data_type_t ossl_config_type = {
|
|
|
22
22
|
{
|
|
23
23
|
0, nconf_free,
|
|
24
24
|
},
|
|
25
|
-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
|
25
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
CONF *
|
|
@@ -87,6 +87,7 @@ config_s_parse(VALUE klass, VALUE str)
|
|
|
87
87
|
|
|
88
88
|
bio = ossl_obj2bio(&str);
|
|
89
89
|
config_load_bio(conf, bio); /* Consumes BIO */
|
|
90
|
+
rb_obj_freeze(obj);
|
|
90
91
|
return obj;
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -144,6 +145,7 @@ config_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
144
145
|
ossl_raise(eConfigError, "BIO_new_file");
|
|
145
146
|
config_load_bio(conf, bio); /* Consumes BIO */
|
|
146
147
|
}
|
|
148
|
+
rb_obj_freeze(self);
|
|
147
149
|
return self;
|
|
148
150
|
}
|
|
149
151
|
|
|
@@ -158,6 +160,7 @@ config_initialize_copy(VALUE self, VALUE other)
|
|
|
158
160
|
rb_check_frozen(self);
|
|
159
161
|
bio = ossl_obj2bio(&str);
|
|
160
162
|
config_load_bio(conf, bio); /* Consumes BIO */
|
|
163
|
+
rb_obj_freeze(self);
|
|
161
164
|
return self;
|
|
162
165
|
}
|
|
163
166
|
|
|
@@ -305,18 +308,16 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE, VALUE)
|
|
|
305
308
|
*
|
|
306
309
|
* Gets the parsable form of the current configuration.
|
|
307
310
|
*
|
|
308
|
-
* Given the following configuration being
|
|
311
|
+
* Given the following configuration file being loaded:
|
|
309
312
|
*
|
|
310
|
-
* config = OpenSSL::Config.
|
|
311
|
-
* #=> #<OpenSSL::Config sections=[]>
|
|
312
|
-
* config['default'] = {"foo"=>"bar","baz"=>"buz"}
|
|
313
|
-
* #=> {"foo"=>"bar", "baz"=>"buz"}
|
|
313
|
+
* config = OpenSSL::Config.load('baz.cnf')
|
|
314
|
+
* #=> #<OpenSSL::Config sections=["default"]>
|
|
314
315
|
* puts config.to_s
|
|
315
316
|
* #=> [ default ]
|
|
316
317
|
* # foo=bar
|
|
317
318
|
* # baz=buz
|
|
318
319
|
*
|
|
319
|
-
* You can
|
|
320
|
+
* You can get the serialized configuration using #to_s and then parse
|
|
320
321
|
* it later:
|
|
321
322
|
*
|
|
322
323
|
* serialized_config = config.to_s
|
|
@@ -455,6 +456,6 @@ Init_ossl_config(void)
|
|
|
455
456
|
* The default system configuration file for OpenSSL.
|
|
456
457
|
*/
|
|
457
458
|
path = CONF_get1_default_config_file();
|
|
458
|
-
path_str = ossl_buf2str(path, rb_long2int(strlen(path)));
|
|
459
|
+
path_str = rb_obj_freeze(ossl_buf2str(path, rb_long2int(strlen(path))));
|
|
459
460
|
rb_define_const(cConfig, "DEFAULT_CONFIG_FILE", path_str);
|
|
460
461
|
}
|
data/ext/openssl/ossl_config.h
CHANGED
data/ext/openssl/ossl_digest.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
/*
|
|
20
20
|
* Classes
|
|
21
21
|
*/
|
|
22
|
-
VALUE cDigest;
|
|
23
|
-
VALUE eDigestError;
|
|
22
|
+
static VALUE cDigest;
|
|
23
|
+
static VALUE eDigestError;
|
|
24
24
|
|
|
25
25
|
static VALUE ossl_digest_alloc(VALUE klass);
|
|
26
26
|
|
|
@@ -96,14 +96,15 @@ ossl_digest_alloc(VALUE klass)
|
|
|
96
96
|
return TypedData_Wrap_Struct(klass, &ossl_digest_type, 0);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
VALUE ossl_digest_update(VALUE, VALUE);
|
|
99
|
+
static VALUE ossl_digest_update(VALUE, VALUE);
|
|
100
100
|
|
|
101
101
|
/*
|
|
102
102
|
* call-seq:
|
|
103
103
|
* Digest.new(string [, data]) -> Digest
|
|
104
104
|
*
|
|
105
105
|
* Creates a Digest instance based on _string_, which is either the ln
|
|
106
|
-
* (long name) or sn (short name) of a supported digest algorithm.
|
|
106
|
+
* (long name) or sn (short name) of a supported digest algorithm. A list of
|
|
107
|
+
* supported algorithms can be obtained by calling OpenSSL::Digest.digests.
|
|
107
108
|
*
|
|
108
109
|
* If _data_ (a String) is given, it is used as the initial input to the
|
|
109
110
|
* Digest instance, i.e.
|
|
@@ -162,6 +163,32 @@ ossl_digest_copy(VALUE self, VALUE other)
|
|
|
162
163
|
return self;
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
static void
|
|
167
|
+
add_digest_name_to_ary(const OBJ_NAME *name, void *arg)
|
|
168
|
+
{
|
|
169
|
+
VALUE ary = (VALUE)arg;
|
|
170
|
+
rb_ary_push(ary, rb_str_new2(name->name));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/*
|
|
174
|
+
* call-seq:
|
|
175
|
+
* OpenSSL::Digest.digests -> array[string...]
|
|
176
|
+
*
|
|
177
|
+
* Returns the names of all available digests in an array.
|
|
178
|
+
*/
|
|
179
|
+
static VALUE
|
|
180
|
+
ossl_s_digests(VALUE self)
|
|
181
|
+
{
|
|
182
|
+
VALUE ary;
|
|
183
|
+
|
|
184
|
+
ary = rb_ary_new();
|
|
185
|
+
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH,
|
|
186
|
+
add_digest_name_to_ary,
|
|
187
|
+
(void*)ary);
|
|
188
|
+
|
|
189
|
+
return ary;
|
|
190
|
+
}
|
|
191
|
+
|
|
165
192
|
/*
|
|
166
193
|
* call-seq:
|
|
167
194
|
* digest.reset -> self
|
|
@@ -198,7 +225,7 @@ ossl_digest_reset(VALUE self)
|
|
|
198
225
|
* result = digest.digest
|
|
199
226
|
*
|
|
200
227
|
*/
|
|
201
|
-
VALUE
|
|
228
|
+
static VALUE
|
|
202
229
|
ossl_digest_update(VALUE self, VALUE data)
|
|
203
230
|
{
|
|
204
231
|
EVP_MD_CTX *ctx;
|
|
@@ -218,24 +245,13 @@ ossl_digest_update(VALUE self, VALUE data)
|
|
|
218
245
|
*
|
|
219
246
|
*/
|
|
220
247
|
static VALUE
|
|
221
|
-
ossl_digest_finish(
|
|
248
|
+
ossl_digest_finish(VALUE self)
|
|
222
249
|
{
|
|
223
250
|
EVP_MD_CTX *ctx;
|
|
224
251
|
VALUE str;
|
|
225
|
-
int out_len;
|
|
226
252
|
|
|
227
253
|
GetDigest(self, ctx);
|
|
228
|
-
|
|
229
|
-
out_len = EVP_MD_CTX_size(ctx);
|
|
230
|
-
|
|
231
|
-
if (NIL_P(str)) {
|
|
232
|
-
str = rb_str_new(NULL, out_len);
|
|
233
|
-
} else {
|
|
234
|
-
StringValue(str);
|
|
235
|
-
rb_str_modify(str);
|
|
236
|
-
rb_str_resize(str, out_len);
|
|
237
|
-
}
|
|
238
|
-
|
|
254
|
+
str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
|
|
239
255
|
if (!EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL))
|
|
240
256
|
ossl_raise(eDigestError, "EVP_DigestFinal_ex");
|
|
241
257
|
|
|
@@ -246,7 +262,8 @@ ossl_digest_finish(int argc, VALUE *argv, VALUE self)
|
|
|
246
262
|
* call-seq:
|
|
247
263
|
* digest.name -> string
|
|
248
264
|
*
|
|
249
|
-
* Returns the
|
|
265
|
+
* Returns the short name of this Digest algorithm which may differ slightly
|
|
266
|
+
* from the original name provided.
|
|
250
267
|
*
|
|
251
268
|
* === Example
|
|
252
269
|
* digest = OpenSSL::Digest.new('SHA512')
|
|
@@ -413,12 +430,13 @@ Init_ossl_digest(void)
|
|
|
413
430
|
|
|
414
431
|
rb_define_alloc_func(cDigest, ossl_digest_alloc);
|
|
415
432
|
|
|
433
|
+
rb_define_module_function(cDigest, "digests", ossl_s_digests, 0);
|
|
416
434
|
rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
|
|
417
435
|
rb_define_method(cDigest, "initialize_copy", ossl_digest_copy, 1);
|
|
418
436
|
rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
|
|
419
437
|
rb_define_method(cDigest, "update", ossl_digest_update, 1);
|
|
420
438
|
rb_define_alias(cDigest, "<<", "update");
|
|
421
|
-
rb_define_private_method(cDigest, "finish", ossl_digest_finish,
|
|
439
|
+
rb_define_private_method(cDigest, "finish", ossl_digest_finish, 0);
|
|
422
440
|
rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
|
|
423
441
|
rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);
|
|
424
442
|
|
data/ext/openssl/ossl_digest.h
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#if !defined(_OSSL_DIGEST_H_)
|
|
11
11
|
#define _OSSL_DIGEST_H_
|
|
12
12
|
|
|
13
|
-
extern VALUE cDigest;
|
|
14
|
-
extern VALUE eDigestError;
|
|
15
|
-
|
|
16
13
|
const EVP_MD *ossl_evp_get_digestbyname(VALUE);
|
|
17
14
|
VALUE ossl_digest_new(const EVP_MD *);
|
|
18
15
|
void Init_ossl_digest(void);
|
data/ext/openssl/ossl_engine.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
*
|
|
38
38
|
* See also, https://www.openssl.org/docs/crypto/engine.html
|
|
39
39
|
*/
|
|
40
|
-
VALUE cEngine;
|
|
40
|
+
static VALUE cEngine;
|
|
41
41
|
/* Document-class: OpenSSL::Engine::EngineError
|
|
42
42
|
*
|
|
43
43
|
* This is the generic exception for OpenSSL::Engine related errors
|
|
44
44
|
*/
|
|
45
|
-
VALUE eEngineError;
|
|
45
|
+
static VALUE eEngineError;
|
|
46
46
|
|
|
47
47
|
/*
|
|
48
48
|
* Private
|
data/ext/openssl/ossl_engine.h
CHANGED
|
@@ -6,14 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/*
|
|
8
8
|
* This program is licensed under the same licence as Ruby.
|
|
9
|
-
* (See the file '
|
|
9
|
+
* (See the file 'COPYING'.)
|
|
10
10
|
*/
|
|
11
11
|
#if !defined(OSSL_ENGINE_H)
|
|
12
12
|
#define OSSL_ENGINE_H
|
|
13
13
|
|
|
14
|
-
extern VALUE cEngine;
|
|
15
|
-
extern VALUE eEngineError;
|
|
16
|
-
|
|
17
14
|
void Init_ossl_engine(void);
|
|
18
15
|
|
|
19
16
|
#endif /* OSSL_ENGINE_H */
|
data/ext/openssl/ossl_hmac.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
/*
|
|
22
22
|
* Classes
|
|
23
23
|
*/
|
|
24
|
-
VALUE cHMAC;
|
|
25
|
-
VALUE eHMACError;
|
|
24
|
+
static VALUE cHMAC;
|
|
25
|
+
static VALUE eHMACError;
|
|
26
26
|
|
|
27
27
|
/*
|
|
28
28
|
* Public
|
data/ext/openssl/ossl_hmac.h
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#if !defined(_OSSL_HMAC_H_)
|
|
11
11
|
#define _OSSL_HMAC_H_
|
|
12
12
|
|
|
13
|
-
extern VALUE cHMAC;
|
|
14
|
-
extern VALUE eHMACError;
|
|
15
|
-
|
|
16
13
|
void Init_ossl_hmac(void);
|
|
17
14
|
|
|
18
15
|
#endif /* _OSSL_HMAC_H_ */
|
data/ext/openssl/ossl_kdf.c
CHANGED
|
@@ -18,7 +18,7 @@ static VALUE mKDF, eKDF;
|
|
|
18
18
|
* of _length_ bytes.
|
|
19
19
|
*
|
|
20
20
|
* For more information about PBKDF2, see RFC 2898 Section 5.2
|
|
21
|
-
* (https://
|
|
21
|
+
* (https://www.rfc-editor.org/rfc/rfc2898#section-5.2).
|
|
22
22
|
*
|
|
23
23
|
* === Parameters
|
|
24
24
|
* pass :: The password.
|
|
@@ -81,10 +81,10 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
|
|
|
81
81
|
* bcrypt.
|
|
82
82
|
*
|
|
83
83
|
* The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914
|
|
84
|
-
* (published on 2016-08, https://
|
|
84
|
+
* (published on 2016-08, https://www.rfc-editor.org/rfc/rfc7914#section-2) states
|
|
85
85
|
* that using values r=8 and p=1 appears to yield good results.
|
|
86
86
|
*
|
|
87
|
-
* See RFC 7914 (https://
|
|
87
|
+
* See RFC 7914 (https://www.rfc-editor.org/rfc/rfc7914) for more information.
|
|
88
88
|
*
|
|
89
89
|
* === Parameters
|
|
90
90
|
* pass :: Passphrase.
|
|
@@ -147,7 +147,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
|
|
|
147
147
|
* KDF.hkdf(ikm, salt:, info:, length:, hash:) -> String
|
|
148
148
|
*
|
|
149
149
|
* HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in
|
|
150
|
-
* {RFC 5869}[https://
|
|
150
|
+
* {RFC 5869}[https://www.rfc-editor.org/rfc/rfc5869].
|
|
151
151
|
*
|
|
152
152
|
* New in OpenSSL 1.1.0.
|
|
153
153
|
*
|
|
@@ -165,7 +165,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
|
|
|
165
165
|
* The hash function.
|
|
166
166
|
*
|
|
167
167
|
* === Example
|
|
168
|
-
* # The values from https://
|
|
168
|
+
* # The values from https://www.rfc-editor.org/rfc/rfc5869#appendix-A.1
|
|
169
169
|
* ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*")
|
|
170
170
|
* salt = ["000102030405060708090a0b0c"].pack("H*")
|
|
171
171
|
* info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*")
|
data/ext/openssl/ossl_ns_spki.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
/*
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
|
-
VALUE mNetscape;
|
|
31
|
-
VALUE cSPKI;
|
|
32
|
-
VALUE eSPKIError;
|
|
30
|
+
static VALUE mNetscape;
|
|
31
|
+
static VALUE cSPKI;
|
|
32
|
+
static VALUE eSPKIError;
|
|
33
33
|
|
|
34
34
|
/*
|
|
35
35
|
* Public functions
|
|
@@ -115,11 +115,11 @@ ossl_spki_to_der(VALUE self)
|
|
|
115
115
|
|
|
116
116
|
GetSPKI(self, spki);
|
|
117
117
|
if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
|
|
118
|
-
ossl_raise(
|
|
118
|
+
ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
|
|
119
119
|
str = rb_str_new(0, len);
|
|
120
120
|
p = (unsigned char *)RSTRING_PTR(str);
|
|
121
121
|
if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
|
|
122
|
-
ossl_raise(
|
|
122
|
+
ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
|
|
123
123
|
ossl_str_adjust(str, p);
|
|
124
124
|
|
|
125
125
|
return str;
|
|
@@ -230,12 +230,13 @@ ossl_spki_get_challenge(VALUE self)
|
|
|
230
230
|
NETSCAPE_SPKI *spki;
|
|
231
231
|
|
|
232
232
|
GetSPKI(self, spki);
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
if (spki->spkac->challenge->length <= 0) {
|
|
234
|
+
OSSL_Debug("Challenge.length <= 0?");
|
|
235
|
+
return rb_str_new(0, 0);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
return
|
|
238
|
+
return rb_str_new((const char *)spki->spkac->challenge->data,
|
|
239
|
+
spki->spkac->challenge->length);
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
/*
|
|
@@ -364,8 +365,8 @@ ossl_spki_verify(VALUE self, VALUE key)
|
|
|
364
365
|
*
|
|
365
366
|
* OpenSSL::Netscape is a namespace for SPKI (Simple Public Key
|
|
366
367
|
* Infrastructure) which implements Signed Public Key and Challenge.
|
|
367
|
-
* See {RFC 2692}[
|
|
368
|
-
* 2693}[
|
|
368
|
+
* See {RFC 2692}[https://www.rfc-editor.org/rfc/rfc2692] and {RFC
|
|
369
|
+
* 2693}[https://www.rfc-editor.org/rfc/rfc2692] for details.
|
|
369
370
|
*/
|
|
370
371
|
|
|
371
372
|
/* Document-class: OpenSSL::Netscape::SPKIError
|
data/ext/openssl/ossl_ns_spki.h
CHANGED
|
@@ -5,15 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#if !defined(_OSSL_NS_SPKI_H_)
|
|
11
11
|
#define _OSSL_NS_SPKI_H_
|
|
12
12
|
|
|
13
|
-
extern VALUE mNetscape;
|
|
14
|
-
extern VALUE cSPKI;
|
|
15
|
-
extern VALUE eSPKIError;
|
|
16
|
-
|
|
17
13
|
void Init_ossl_ns_spki(void);
|
|
18
14
|
|
|
19
15
|
#endif /* _OSSL_NS_SPKI_H_ */
|
data/ext/openssl/ossl_ocsp.c
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/*
|
|
8
8
|
* This program is licensed under the same licence as Ruby.
|
|
9
|
-
* (See the file '
|
|
9
|
+
* (See the file 'COPYING'.)
|
|
10
10
|
*/
|
|
11
11
|
#include "ossl.h"
|
|
12
12
|
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
|
|
68
68
|
} while (0)
|
|
69
69
|
|
|
70
|
-
VALUE mOCSP;
|
|
71
|
-
VALUE eOCSPError;
|
|
72
|
-
VALUE cOCSPReq;
|
|
73
|
-
VALUE cOCSPRes;
|
|
74
|
-
VALUE cOCSPBasicRes;
|
|
75
|
-
VALUE cOCSPSingleRes;
|
|
76
|
-
VALUE cOCSPCertId;
|
|
70
|
+
static VALUE mOCSP;
|
|
71
|
+
static VALUE eOCSPError;
|
|
72
|
+
static VALUE cOCSPReq;
|
|
73
|
+
static VALUE cOCSPRes;
|
|
74
|
+
static VALUE cOCSPBasicRes;
|
|
75
|
+
static VALUE cOCSPSingleRes;
|
|
76
|
+
static VALUE cOCSPCertId;
|
|
77
77
|
|
|
78
78
|
static void
|
|
79
79
|
ossl_ocsp_request_free(void *ptr)
|
|
@@ -900,6 +900,7 @@ ossl_ocspbres_get_status(VALUE self)
|
|
|
900
900
|
OCSP_CERTID *cid;
|
|
901
901
|
ASN1_TIME *revtime, *thisupd, *nextupd;
|
|
902
902
|
int status, reason;
|
|
903
|
+
X509_EXTENSION *x509ext;
|
|
903
904
|
VALUE ret, ary, ext;
|
|
904
905
|
int count, ext_count, i, j;
|
|
905
906
|
|
|
@@ -926,7 +927,7 @@ ossl_ocspbres_get_status(VALUE self)
|
|
|
926
927
|
ext = rb_ary_new();
|
|
927
928
|
ext_count = OCSP_SINGLERESP_get_ext_count(single);
|
|
928
929
|
for(j = 0; j < ext_count; j++){
|
|
929
|
-
|
|
930
|
+
x509ext = OCSP_SINGLERESP_get_ext(single, j);
|
|
930
931
|
rb_ary_push(ext, ossl_x509ext_new(x509ext));
|
|
931
932
|
}
|
|
932
933
|
rb_ary_push(ary, ext);
|
|
@@ -1357,6 +1358,7 @@ static VALUE
|
|
|
1357
1358
|
ossl_ocspsres_get_extensions(VALUE self)
|
|
1358
1359
|
{
|
|
1359
1360
|
OCSP_SINGLERESP *sres;
|
|
1361
|
+
X509_EXTENSION *ext;
|
|
1360
1362
|
int count, i;
|
|
1361
1363
|
VALUE ary;
|
|
1362
1364
|
|
|
@@ -1365,7 +1367,7 @@ ossl_ocspsres_get_extensions(VALUE self)
|
|
|
1365
1367
|
count = OCSP_SINGLERESP_get_ext_count(sres);
|
|
1366
1368
|
ary = rb_ary_new2(count);
|
|
1367
1369
|
for (i = 0; i < count; i++) {
|
|
1368
|
-
|
|
1370
|
+
ext = OCSP_SINGLERESP_get_ext(sres, i);
|
|
1369
1371
|
rb_ary_push(ary, ossl_x509ext_new(ext)); /* will dup */
|
|
1370
1372
|
}
|
|
1371
1373
|
|
|
@@ -1563,9 +1565,8 @@ ossl_ocspcid_get_issuer_name_hash(VALUE self)
|
|
|
1563
1565
|
GetOCSPCertId(self, id);
|
|
1564
1566
|
OCSP_id_get0_info(&name_hash, NULL, NULL, NULL, id);
|
|
1565
1567
|
|
|
1566
|
-
ret = rb_str_new(NULL,
|
|
1567
|
-
ossl_bin2hex(
|
|
1568
|
-
ASN1_STRING_length(name_hash));
|
|
1568
|
+
ret = rb_str_new(NULL, name_hash->length * 2);
|
|
1569
|
+
ossl_bin2hex(name_hash->data, RSTRING_PTR(ret), name_hash->length);
|
|
1569
1570
|
|
|
1570
1571
|
return ret;
|
|
1571
1572
|
}
|
|
@@ -1587,9 +1588,8 @@ ossl_ocspcid_get_issuer_key_hash(VALUE self)
|
|
|
1587
1588
|
GetOCSPCertId(self, id);
|
|
1588
1589
|
OCSP_id_get0_info(NULL, NULL, &key_hash, NULL, id);
|
|
1589
1590
|
|
|
1590
|
-
ret = rb_str_new(NULL,
|
|
1591
|
-
ossl_bin2hex(
|
|
1592
|
-
ASN1_STRING_length(key_hash));
|
|
1591
|
+
ret = rb_str_new(NULL, key_hash->length * 2);
|
|
1592
|
+
ossl_bin2hex(key_hash->data, RSTRING_PTR(ret), key_hash->length);
|
|
1593
1593
|
|
|
1594
1594
|
return ret;
|
|
1595
1595
|
}
|