openssl 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +180 -29
- data/History.md +76 -0
- data/README.md +11 -7
- data/ext/openssl/extconf.rb +7 -9
- data/ext/openssl/openssl_missing.c +1 -1
- data/ext/openssl/openssl_missing.h +1 -1
- data/ext/openssl/ossl.c +7 -9
- data/ext/openssl/ossl.h +12 -8
- data/ext/openssl/ossl_asn1.c +46 -237
- 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 +8 -8
- data/ext/openssl/ossl_ns_spki.h +1 -5
- data/ext/openssl/ossl_ocsp.c +8 -8
- 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 +68 -21
- data/ext/openssl/ossl_pkcs7.h +2 -22
- data/ext/openssl/ossl_pkey.c +1 -1
- data/ext/openssl/ossl_pkey.h +3 -14
- data/ext/openssl/ossl_pkey_dh.c +2 -2
- data/ext/openssl/ossl_pkey_dsa.c +2 -2
- data/ext/openssl/ossl_pkey_ec.c +6 -6
- data/ext/openssl/ossl_pkey_rsa.c +2 -2
- data/ext/openssl/ossl_provider.c +1 -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 +73 -15
- data/ext/openssl/ossl_ts.h +1 -1
- data/ext/openssl/ossl_x509.c +1 -1
- data/ext/openssl/ossl_x509.h +1 -20
- data/ext/openssl/ossl_x509attr.c +25 -26
- data/ext/openssl/ossl_x509cert.c +42 -3
- data/ext/openssl/ossl_x509crl.c +8 -4
- data/ext/openssl/ossl_x509ext.c +3 -3
- data/ext/openssl/ossl_x509name.c +3 -3
- data/ext/openssl/ossl_x509req.c +8 -4
- data/ext/openssl/ossl_x509revoked.c +2 -2
- data/ext/openssl/ossl_x509store.c +16 -11
- 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 +67 -4
- data/lib/openssl/version.rb +1 -1
- data/lib/openssl/x509.rb +1 -1
- data/lib/openssl.rb +2 -1
- metadata +5 -3
- /data/{LICENSE.txt → COPYING} +0 -0
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;
|
@@ -365,8 +365,8 @@ ossl_spki_verify(VALUE self, VALUE key)
|
|
365
365
|
*
|
366
366
|
* OpenSSL::Netscape is a namespace for SPKI (Simple Public Key
|
367
367
|
* Infrastructure) which implements Signed Public Key and Challenge.
|
368
|
-
* See {RFC 2692}[
|
369
|
-
* 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.
|
370
370
|
*/
|
371
371
|
|
372
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)
|
data/ext/openssl/ossl_ocsp.h
CHANGED
@@ -6,18 +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_OCSP_H_)
|
12
12
|
#define _OSSL_OCSP_H_
|
13
13
|
|
14
|
-
#if !defined(OPENSSL_NO_OCSP)
|
15
|
-
extern VALUE mOCSP;
|
16
|
-
extern VALUE cOCSPReq;
|
17
|
-
extern VALUE cOCSPRes;
|
18
|
-
extern VALUE cOCSPBasicRes;
|
19
|
-
#endif
|
20
|
-
|
21
14
|
void Init_ossl_ocsp(void);
|
22
15
|
|
23
16
|
#endif /* _OSSL_OCSP_H_ */
|
data/ext/openssl/ossl_pkcs12.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* This program is licensed under the same licence as Ruby.
|
3
|
-
* (See the file '
|
3
|
+
* (See the file 'COPYING'.)
|
4
4
|
*/
|
5
5
|
#include "ossl.h"
|
6
6
|
|
@@ -27,8 +27,8 @@
|
|
27
27
|
/*
|
28
28
|
* Classes
|
29
29
|
*/
|
30
|
-
VALUE cPKCS12;
|
31
|
-
VALUE ePKCS12Error;
|
30
|
+
static VALUE cPKCS12;
|
31
|
+
static VALUE ePKCS12Error;
|
32
32
|
|
33
33
|
/*
|
34
34
|
* Private
|
@@ -134,6 +134,10 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
|
|
134
134
|
if (!NIL_P(keytype))
|
135
135
|
ktype = NUM2INT(keytype);
|
136
136
|
|
137
|
+
if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
|
138
|
+
ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
|
139
|
+
}
|
140
|
+
|
137
141
|
obj = NewPKCS12(cPKCS12);
|
138
142
|
x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
|
139
143
|
p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
|
@@ -247,6 +251,48 @@ ossl_pkcs12_to_der(VALUE self)
|
|
247
251
|
return str;
|
248
252
|
}
|
249
253
|
|
254
|
+
/*
|
255
|
+
* call-seq:
|
256
|
+
* pkcs12.set_mac(pass, salt = nil, iter = nil, md_type = nil)
|
257
|
+
*
|
258
|
+
* Sets MAC parameters and generates MAC over the PKCS #12 structure.
|
259
|
+
*
|
260
|
+
* This method uses HMAC and the PKCS #12 specific password-based KDF as
|
261
|
+
* specified in the original PKCS #12.
|
262
|
+
*
|
263
|
+
* See also the man page PKCS12_set_mac(3).
|
264
|
+
*
|
265
|
+
* Added in version 3.3.0.
|
266
|
+
*/
|
267
|
+
static VALUE
|
268
|
+
pkcs12_set_mac(int argc, VALUE *argv, VALUE self)
|
269
|
+
{
|
270
|
+
PKCS12 *p12;
|
271
|
+
VALUE pass, salt, iter, md_name;
|
272
|
+
int iter_i = 0;
|
273
|
+
const EVP_MD *md_type = NULL;
|
274
|
+
|
275
|
+
rb_scan_args(argc, argv, "13", &pass, &salt, &iter, &md_name);
|
276
|
+
rb_check_frozen(self);
|
277
|
+
GetPKCS12(self, p12);
|
278
|
+
|
279
|
+
StringValue(pass);
|
280
|
+
if (!NIL_P(salt))
|
281
|
+
StringValue(salt);
|
282
|
+
if (!NIL_P(iter))
|
283
|
+
iter_i = NUM2INT(iter);
|
284
|
+
if (!NIL_P(md_name))
|
285
|
+
md_type = ossl_evp_get_digestbyname(md_name);
|
286
|
+
|
287
|
+
if (!PKCS12_set_mac(p12, RSTRING_PTR(pass), RSTRING_LENINT(pass),
|
288
|
+
!NIL_P(salt) ? (unsigned char *)RSTRING_PTR(salt) : NULL,
|
289
|
+
!NIL_P(salt) ? RSTRING_LENINT(salt) : 0,
|
290
|
+
iter_i, md_type))
|
291
|
+
ossl_raise(ePKCS12Error, "PKCS12_set_mac");
|
292
|
+
|
293
|
+
return Qnil;
|
294
|
+
}
|
295
|
+
|
250
296
|
void
|
251
297
|
Init_ossl_pkcs12(void)
|
252
298
|
{
|
@@ -272,4 +318,9 @@ Init_ossl_pkcs12(void)
|
|
272
318
|
rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
|
273
319
|
rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
|
274
320
|
rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
|
321
|
+
rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
|
322
|
+
|
323
|
+
/* MSIE specific PKCS12 key usage extensions */
|
324
|
+
rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
|
325
|
+
rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
|
275
326
|
}
|
data/ext/openssl/ossl_pkcs12.h
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
/*
|
2
2
|
* This program is licensed under the same licence as Ruby.
|
3
|
-
* (See the file '
|
3
|
+
* (See the file 'COPYING'.)
|
4
4
|
*/
|
5
5
|
#if !defined(_OSSL_PKCS12_H_)
|
6
6
|
#define _OSSL_PKCS12_H_
|
7
7
|
|
8
|
-
extern VALUE cPKCS12;
|
9
|
-
extern VALUE ePKCS12Error;
|
10
|
-
|
11
8
|
void Init_ossl_pkcs12(void);
|
12
9
|
|
13
10
|
#endif /* _OSSL_PKCS12_H_ */
|