rubysl-openssl 2.1.0 → 2.2.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 +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
@@ -32,7 +32,18 @@
|
|
32
32
|
/*
|
33
33
|
* Classes
|
34
34
|
*/
|
35
|
+
/* Document-class: OpenSSL::Engine
|
36
|
+
*
|
37
|
+
* This class is the access to openssl's ENGINE cryptographic module
|
38
|
+
* implementation.
|
39
|
+
*
|
40
|
+
* See also, https://www.openssl.org/docs/crypto/engine.html
|
41
|
+
*/
|
35
42
|
VALUE cEngine;
|
43
|
+
/* Document-class: OpenSSL::Engine::EngineError
|
44
|
+
*
|
45
|
+
* This is the generic exception for OpenSSL::Engine related errors
|
46
|
+
*/
|
36
47
|
VALUE eEngineError;
|
37
48
|
|
38
49
|
/*
|
@@ -46,6 +57,17 @@ do{\
|
|
46
57
|
}\
|
47
58
|
}while(0)
|
48
59
|
|
60
|
+
/* Document-method: OpenSSL::Engine.load
|
61
|
+
*
|
62
|
+
* call-seq:
|
63
|
+
* load(enginename = nil)
|
64
|
+
*
|
65
|
+
* This method loads engines. If +name+ is nil, then all builtin engines are
|
66
|
+
* loaded. Otherwise, the given +name+, as a string, is loaded if available to
|
67
|
+
* your runtime, and returns true. If +name+ is not found, then nil is
|
68
|
+
* returned.
|
69
|
+
*
|
70
|
+
*/
|
49
71
|
static VALUE
|
50
72
|
ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
|
51
73
|
{
|
@@ -116,6 +138,15 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
|
|
116
138
|
#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
|
117
139
|
}
|
118
140
|
|
141
|
+
/* Document-method: OpenSSL::Engine.cleanup
|
142
|
+
* call-seq:
|
143
|
+
* OpenSSL::Engine.cleanup
|
144
|
+
*
|
145
|
+
* It is only necessary to run cleanup when engines are loaded via
|
146
|
+
* OpenSSL::Engine.load. However, running cleanup before exit is recommended.
|
147
|
+
*
|
148
|
+
* See also, https://www.openssl.org/docs/crypto/engine.html
|
149
|
+
*/
|
119
150
|
static VALUE
|
120
151
|
ossl_engine_s_cleanup(VALUE self)
|
121
152
|
{
|
@@ -125,6 +156,10 @@ ossl_engine_s_cleanup(VALUE self)
|
|
125
156
|
return Qnil;
|
126
157
|
}
|
127
158
|
|
159
|
+
/* Document-method: OpenSSL::Engine.engines
|
160
|
+
*
|
161
|
+
* Returns an array of currently loaded engines.
|
162
|
+
*/
|
128
163
|
static VALUE
|
129
164
|
ossl_engine_s_engines(VALUE klass)
|
130
165
|
{
|
@@ -144,6 +179,18 @@ ossl_engine_s_engines(VALUE klass)
|
|
144
179
|
return ary;
|
145
180
|
}
|
146
181
|
|
182
|
+
/* Document-method: OpenSSL::Engine.by_id
|
183
|
+
*
|
184
|
+
* call-seq:
|
185
|
+
* by_id(name) -> engine
|
186
|
+
*
|
187
|
+
* Fetch the engine as specified by the +id+ String
|
188
|
+
*
|
189
|
+
* OpenSSL::Engine.by_id("openssl")
|
190
|
+
* => #<OpenSSL::Engine id="openssl" name="Software engine support">
|
191
|
+
*
|
192
|
+
* See OpenSSL::Engine.engines for the currently loaded engines
|
193
|
+
*/
|
147
194
|
static VALUE
|
148
195
|
ossl_engine_s_by_id(VALUE klass, VALUE id)
|
149
196
|
{
|
@@ -179,6 +226,15 @@ ossl_engine_s_alloc(VALUE klass)
|
|
179
226
|
return obj;
|
180
227
|
}
|
181
228
|
|
229
|
+
/* Document-method: OpenSSL::Engine#id
|
230
|
+
*
|
231
|
+
* Get the id for this engine
|
232
|
+
*
|
233
|
+
* OpenSSL::Engine.load
|
234
|
+
* OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
|
235
|
+
* OpenSSL::Engine.engines.first.id
|
236
|
+
* #=> "rsax"
|
237
|
+
*/
|
182
238
|
static VALUE
|
183
239
|
ossl_engine_get_id(VALUE self)
|
184
240
|
{
|
@@ -187,6 +243,16 @@ ossl_engine_get_id(VALUE self)
|
|
187
243
|
return rb_str_new2(ENGINE_get_id(e));
|
188
244
|
}
|
189
245
|
|
246
|
+
/* Document-method: OpenSSL::Engine#name
|
247
|
+
*
|
248
|
+
* Get the descriptive name for this engine
|
249
|
+
*
|
250
|
+
* OpenSSL::Engine.load
|
251
|
+
* OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
|
252
|
+
* OpenSSL::Engine.engines.first.name
|
253
|
+
* #=> "RSAX engine support"
|
254
|
+
*
|
255
|
+
*/
|
190
256
|
static VALUE
|
191
257
|
ossl_engine_get_name(VALUE self)
|
192
258
|
{
|
@@ -195,6 +261,12 @@ ossl_engine_get_name(VALUE self)
|
|
195
261
|
return rb_str_new2(ENGINE_get_name(e));
|
196
262
|
}
|
197
263
|
|
264
|
+
/* Document-method: OpenSSL::Engine#finish
|
265
|
+
*
|
266
|
+
* Releases all internal structural references for this engine.
|
267
|
+
*
|
268
|
+
* May raise an EngineError if the engine is unavailable
|
269
|
+
*/
|
198
270
|
static VALUE
|
199
271
|
ossl_engine_finish(VALUE self)
|
200
272
|
{
|
@@ -207,6 +279,22 @@ ossl_engine_finish(VALUE self)
|
|
207
279
|
}
|
208
280
|
|
209
281
|
#if defined(HAVE_ENGINE_GET_CIPHER)
|
282
|
+
/* Document-method: OpenSSL::Engine#cipher
|
283
|
+
*
|
284
|
+
* call-seq:
|
285
|
+
* engine.cipher(name) -> OpenSSL::Cipher
|
286
|
+
*
|
287
|
+
* This returns an OpenSSL::Cipher by +name+, if it is available in this
|
288
|
+
* engine.
|
289
|
+
*
|
290
|
+
* A EngineError will be raised if the cipher is unavailable.
|
291
|
+
*
|
292
|
+
* e = OpenSSL::Engine.by_id("openssl")
|
293
|
+
* => #<OpenSSL::Engine id="openssl" name="Software engine support">
|
294
|
+
* e.cipher("RC4")
|
295
|
+
* => #<OpenSSL::Cipher:0x007fc5cacc3048>
|
296
|
+
*
|
297
|
+
*/
|
210
298
|
static VALUE
|
211
299
|
ossl_engine_get_cipher(VALUE self, VALUE name)
|
212
300
|
{
|
@@ -230,6 +318,22 @@ ossl_engine_get_cipher(VALUE self, VALUE name)
|
|
230
318
|
#endif
|
231
319
|
|
232
320
|
#if defined(HAVE_ENGINE_GET_DIGEST)
|
321
|
+
/* Document-method: OpenSSL::Engine#digest
|
322
|
+
*
|
323
|
+
* call-seq:
|
324
|
+
* engine.digest(name) -> OpenSSL::Digest
|
325
|
+
*
|
326
|
+
* This returns an OpenSSL::Digest by +name+.
|
327
|
+
*
|
328
|
+
* Will raise an EngineError if the digest is unavailable.
|
329
|
+
*
|
330
|
+
* e = OpenSSL::Engine.by_id("openssl")
|
331
|
+
* #=> #<OpenSSL::Engine id="openssl" name="Software engine support">
|
332
|
+
* e.digest("SHA1")
|
333
|
+
* #=> #<OpenSSL::Digest: da39a3ee5e6b4b0d3255bfef95601890afd80709>
|
334
|
+
* e.digest("zomg")
|
335
|
+
* #=> OpenSSL::Engine::EngineError: no such digest `zomg'
|
336
|
+
*/
|
233
337
|
static VALUE
|
234
338
|
ossl_engine_get_digest(VALUE self, VALUE name)
|
235
339
|
{
|
@@ -252,6 +356,16 @@ ossl_engine_get_digest(VALUE self, VALUE name)
|
|
252
356
|
#define ossl_engine_get_digest rb_f_notimplement
|
253
357
|
#endif
|
254
358
|
|
359
|
+
/* Document-method: OpenSSL::Engine#load_private_key
|
360
|
+
*
|
361
|
+
* call-seq:
|
362
|
+
* engine.load_private_key(id = nil, data = nil) -> OpenSSL::PKey
|
363
|
+
*
|
364
|
+
* Loads the given private key by +id+ and +data+.
|
365
|
+
*
|
366
|
+
* An EngineError is raised of the OpenSSL::PKey is unavailable.
|
367
|
+
*
|
368
|
+
*/
|
255
369
|
static VALUE
|
256
370
|
ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self)
|
257
371
|
{
|
@@ -276,6 +390,16 @@ ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self)
|
|
276
390
|
return obj;
|
277
391
|
}
|
278
392
|
|
393
|
+
/* Document-method: OpenSSL::Engine#load_public_key
|
394
|
+
*
|
395
|
+
* call-seq:
|
396
|
+
* engine.load_public_key(id = nil, data = nil) -> OpenSSL::PKey
|
397
|
+
*
|
398
|
+
* Loads the given private key by +id+ and +data+.
|
399
|
+
*
|
400
|
+
* An EngineError is raised of the OpenSSL::PKey is unavailable.
|
401
|
+
*
|
402
|
+
*/
|
279
403
|
static VALUE
|
280
404
|
ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
|
281
405
|
{
|
@@ -298,6 +422,23 @@ ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
|
|
298
422
|
return ossl_pkey_new(pkey);
|
299
423
|
}
|
300
424
|
|
425
|
+
/* Document-method: OpenSSL::Engine#set_default
|
426
|
+
*
|
427
|
+
* call-seq:
|
428
|
+
* engine.set_default(flag)
|
429
|
+
*
|
430
|
+
* Set the defaults for this engine with the given +flag+.
|
431
|
+
*
|
432
|
+
* These flags are used to control combinations of algorithm methods.
|
433
|
+
*
|
434
|
+
* +flag+ can be one of the following, other flags are available depending on
|
435
|
+
* your OS.
|
436
|
+
*
|
437
|
+
* [All flags] 0xFFFF
|
438
|
+
* [No flags] 0x0000
|
439
|
+
*
|
440
|
+
* See also <openssl/engine.h>
|
441
|
+
*/
|
301
442
|
static VALUE
|
302
443
|
ossl_engine_set_default(VALUE self, VALUE flag)
|
303
444
|
{
|
@@ -310,6 +451,15 @@ ossl_engine_set_default(VALUE self, VALUE flag)
|
|
310
451
|
return Qtrue;
|
311
452
|
}
|
312
453
|
|
454
|
+
/* Document-method: OpenSSL::Engine#ctrl_cmd
|
455
|
+
*
|
456
|
+
* call-seq:
|
457
|
+
* engine.ctrl_cmd(command, value = nil) -> engine
|
458
|
+
*
|
459
|
+
* Send the given +command+ to this engine.
|
460
|
+
*
|
461
|
+
* Raises an EngineError if the +command+ fails.
|
462
|
+
*/
|
313
463
|
static VALUE
|
314
464
|
ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self)
|
315
465
|
{
|
@@ -340,6 +490,10 @@ ossl_engine_cmd_flag_to_name(int flag)
|
|
340
490
|
}
|
341
491
|
}
|
342
492
|
|
493
|
+
/* Document-method: OpenSSL::Engine#cmds
|
494
|
+
*
|
495
|
+
* Returns an array of command definitions for the current engine
|
496
|
+
*/
|
343
497
|
static VALUE
|
344
498
|
ossl_engine_get_cmds(VALUE self)
|
345
499
|
{
|
@@ -362,6 +516,10 @@ ossl_engine_get_cmds(VALUE self)
|
|
362
516
|
return ary;
|
363
517
|
}
|
364
518
|
|
519
|
+
/* Document-method: OpenSSL::Engine#inspect
|
520
|
+
*
|
521
|
+
* Pretty print this engine
|
522
|
+
*/
|
365
523
|
static VALUE
|
366
524
|
ossl_engine_inspect(VALUE self)
|
367
525
|
{
|
@@ -62,6 +62,36 @@ ossl_hmac_alloc(VALUE klass)
|
|
62
62
|
* call-seq:
|
63
63
|
* HMAC.new(key, digest) -> hmac
|
64
64
|
*
|
65
|
+
* Returns an instance of OpenSSL::HMAC set with the key and digest
|
66
|
+
* algorithm to be used. The instance represents the initial state of
|
67
|
+
* the message authentication code before any data has been processed.
|
68
|
+
* To process data with it, use the instance method #update with your
|
69
|
+
* data as an argument.
|
70
|
+
*
|
71
|
+
* === Example
|
72
|
+
*
|
73
|
+
* key = 'key'
|
74
|
+
* digest = OpenSSL::Digest.new('sha1')
|
75
|
+
* instance = OpenSSL::HMAC.new(key, digest)
|
76
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
77
|
+
* instance.class
|
78
|
+
* #=> OpenSSL::HMAC
|
79
|
+
*
|
80
|
+
* === A note about comparisons
|
81
|
+
*
|
82
|
+
* Two instances won't be equal when they're compared, even if they have the
|
83
|
+
* same value. Use #to_s or #hexdigest to return the authentication code that
|
84
|
+
* the instance represents. For example:
|
85
|
+
*
|
86
|
+
* other_instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
|
87
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
88
|
+
* instance
|
89
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
90
|
+
* instance == other_instance
|
91
|
+
* #=> false
|
92
|
+
* instance.to_s == other_instance.to_s
|
93
|
+
* #=> true
|
94
|
+
*
|
65
95
|
*/
|
66
96
|
static VALUE
|
67
97
|
ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
|
@@ -95,6 +125,19 @@ ossl_hmac_copy(VALUE self, VALUE other)
|
|
95
125
|
* call-seq:
|
96
126
|
* hmac.update(string) -> self
|
97
127
|
*
|
128
|
+
* Returns +self+ updated with the message to be authenticated.
|
129
|
+
* Can be called repeatedly with chunks of the message.
|
130
|
+
*
|
131
|
+
* === Example
|
132
|
+
*
|
133
|
+
* first_chunk = 'The quick brown fox jumps '
|
134
|
+
* second_chunk = 'over the lazy dog'
|
135
|
+
*
|
136
|
+
* instance.update(first_chunk)
|
137
|
+
* #=> 5b9a8038a65d571076d97fe783989e52278a492a
|
138
|
+
* instance.update(second_chunk)
|
139
|
+
* #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
|
140
|
+
*
|
98
141
|
*/
|
99
142
|
static VALUE
|
100
143
|
ossl_hmac_update(VALUE self, VALUE data)
|
@@ -125,7 +168,16 @@ hmac_final(HMAC_CTX *ctx, unsigned char **buf, unsigned int *buf_len)
|
|
125
168
|
|
126
169
|
/*
|
127
170
|
* call-seq:
|
128
|
-
* hmac.digest ->
|
171
|
+
* hmac.digest -> string
|
172
|
+
*
|
173
|
+
* Returns the authentication code an instance represents as a binary string.
|
174
|
+
*
|
175
|
+
* === Example
|
176
|
+
*
|
177
|
+
* instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
|
178
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
179
|
+
* instance.digest
|
180
|
+
* #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?"
|
129
181
|
*
|
130
182
|
*/
|
131
183
|
static VALUE
|
@@ -145,7 +197,10 @@ ossl_hmac_digest(VALUE self)
|
|
145
197
|
|
146
198
|
/*
|
147
199
|
* call-seq:
|
148
|
-
* hmac.hexdigest ->
|
200
|
+
* hmac.hexdigest -> string
|
201
|
+
*
|
202
|
+
* Returns the authentication code an instance represents as a hex-encoded
|
203
|
+
* string.
|
149
204
|
*
|
150
205
|
*/
|
151
206
|
static VALUE
|
@@ -173,6 +228,20 @@ ossl_hmac_hexdigest(VALUE self)
|
|
173
228
|
* call-seq:
|
174
229
|
* hmac.reset -> self
|
175
230
|
*
|
231
|
+
* Returns +self+ as it was when it was first initialized, with all processed
|
232
|
+
* data cleared from it.
|
233
|
+
*
|
234
|
+
* === Example
|
235
|
+
*
|
236
|
+
* data = "The quick brown fox jumps over the lazy dog"
|
237
|
+
* instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
|
238
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
239
|
+
*
|
240
|
+
* instance.update(data)
|
241
|
+
* #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
|
242
|
+
* instance.reset
|
243
|
+
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
|
244
|
+
*
|
176
245
|
*/
|
177
246
|
static VALUE
|
178
247
|
ossl_hmac_reset(VALUE self)
|
@@ -189,6 +258,18 @@ ossl_hmac_reset(VALUE self)
|
|
189
258
|
* call-seq:
|
190
259
|
* HMAC.digest(digest, key, data) -> aString
|
191
260
|
*
|
261
|
+
* Returns the authentication code as a binary string. The +digest+ parameter
|
262
|
+
* must be an instance of OpenSSL::Digest.
|
263
|
+
*
|
264
|
+
* === Example
|
265
|
+
*
|
266
|
+
* key = 'key'
|
267
|
+
* data = 'The quick brown fox jumps over the lazy dog'
|
268
|
+
* digest = OpenSSL::Digest.new('sha1')
|
269
|
+
*
|
270
|
+
* hmac = OpenSSL::HMAC.digest(digest, key, data)
|
271
|
+
* #=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9"
|
272
|
+
*
|
192
273
|
*/
|
193
274
|
static VALUE
|
194
275
|
ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
|
@@ -206,7 +287,19 @@ ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
|
|
206
287
|
|
207
288
|
/*
|
208
289
|
* call-seq:
|
209
|
-
* HMAC.
|
290
|
+
* HMAC.hexdigest(digest, key, data) -> aString
|
291
|
+
*
|
292
|
+
* Returns the authentication code as a hex-encoded string. The +digest+
|
293
|
+
* parameter must be an instance of OpenSSL::Digest.
|
294
|
+
*
|
295
|
+
* === Example
|
296
|
+
*
|
297
|
+
* key = 'key'
|
298
|
+
* data = 'The quick brown fox jumps over the lazy dog'
|
299
|
+
* digest = OpenSSL::Digest.new('sha1')
|
300
|
+
*
|
301
|
+
* hmac = OpenSSL::HMAC.hexdigest(digest, key, data)
|
302
|
+
* #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"
|
210
303
|
*
|
211
304
|
*/
|
212
305
|
static VALUE
|
@@ -237,6 +330,7 @@ void
|
|
237
330
|
Init_ossl_hmac()
|
238
331
|
{
|
239
332
|
#if 0
|
333
|
+
/* :nodoc: */
|
240
334
|
mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
|
241
335
|
#endif
|
242
336
|
|
@@ -149,7 +149,7 @@ ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
|
|
149
149
|
* 2: nonces both absent.
|
150
150
|
* 3: nonce present in response only.
|
151
151
|
* 0: nonces both present and not equal.
|
152
|
-
*
|
152
|
+
* -1: nonce in request only.
|
153
153
|
*
|
154
154
|
* For most responders clients can check return > 0.
|
155
155
|
* If responder doesn't handle nonces return != 0 may be
|
@@ -466,7 +466,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
|
|
466
466
|
/* All ary's members should be X509Extension */
|
467
467
|
Check_Type(ext, T_ARRAY);
|
468
468
|
for (i = 0; i < RARRAY_LEN(ext); i++)
|
469
|
-
OSSL_Check_Kind(
|
469
|
+
OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
|
470
470
|
}
|
471
471
|
|
472
472
|
error = 0;
|
@@ -495,7 +495,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
|
|
495
495
|
sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
|
496
496
|
single->singleExtensions = NULL;
|
497
497
|
for(i = 0; i < RARRAY_LEN(ext); i++){
|
498
|
-
x509ext = DupX509ExtPtr(
|
498
|
+
x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
|
499
499
|
if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
|
500
500
|
X509_EXTENSION_free(x509ext);
|
501
501
|
error = 1;
|
@@ -624,7 +624,7 @@ pkcs7_get_crls(VALUE self)
|
|
624
624
|
}
|
625
625
|
|
626
626
|
static VALUE
|
627
|
-
ossl_pkcs7_set_certs_i(
|
627
|
+
ossl_pkcs7_set_certs_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
|
628
628
|
{
|
629
629
|
return ossl_pkcs7_add_certificate(arg, i);
|
630
630
|
}
|
@@ -664,7 +664,7 @@ ossl_pkcs7_add_crl(VALUE self, VALUE crl)
|
|
664
664
|
}
|
665
665
|
|
666
666
|
static VALUE
|
667
|
-
ossl_pkcs7_set_crls_i(
|
667
|
+
ossl_pkcs7_set_crls_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
|
668
668
|
{
|
669
669
|
return ossl_pkcs7_add_crl(arg, i);
|
670
670
|
}
|
@@ -112,7 +112,7 @@ ossl_pkey_new_from_file(VALUE filename)
|
|
112
112
|
if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
|
113
113
|
ossl_raise(ePKeyError, "%s", strerror(errno));
|
114
114
|
}
|
115
|
-
|
115
|
+
rb_fd_fix_cloexec(fileno(fp));
|
116
116
|
|
117
117
|
pkey = PEM_read_PrivateKey(fp, NULL, ossl_pem_passwd_cb, NULL);
|
118
118
|
fclose(fp);
|
@@ -318,13 +318,16 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
|
|
318
318
|
{
|
319
319
|
EVP_PKEY *pkey;
|
320
320
|
EVP_MD_CTX ctx;
|
321
|
+
int result;
|
321
322
|
|
322
323
|
GetPKey(self, pkey);
|
323
|
-
EVP_VerifyInit(&ctx, GetDigestPtr(digest));
|
324
324
|
StringValue(sig);
|
325
325
|
StringValue(data);
|
326
|
+
EVP_VerifyInit(&ctx, GetDigestPtr(digest));
|
326
327
|
EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
|
327
|
-
|
328
|
+
result = EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey);
|
329
|
+
EVP_MD_CTX_cleanup(&ctx);
|
330
|
+
switch (result) {
|
328
331
|
case 0:
|
329
332
|
return Qfalse;
|
330
333
|
case 1:
|
@@ -278,7 +278,9 @@ ossl_dh_is_private(VALUE self)
|
|
278
278
|
|
279
279
|
/*
|
280
280
|
* call-seq:
|
281
|
+
* dh.export -> aString
|
281
282
|
* dh.to_pem -> aString
|
283
|
+
* dh.to_s -> aString
|
282
284
|
*
|
283
285
|
* Encodes this DH to its PEM encoding. Note that any existing per-session
|
284
286
|
* public/private keys will *not* get encoded, just the Diffie-Hellman
|
@@ -428,7 +430,7 @@ ossl_dh_to_public_key(VALUE self)
|
|
428
430
|
|
429
431
|
/*
|
430
432
|
* call-seq:
|
431
|
-
* dh.
|
433
|
+
* dh.params_ok? -> true | false
|
432
434
|
*
|
433
435
|
* Validates the Diffie-Hellman parameters associated with this instance.
|
434
436
|
* It checks whether a safe prime and a suitable generator are used. If this
|
@@ -619,7 +621,7 @@ Init_ossl_dh()
|
|
619
621
|
*
|
620
622
|
* === Example of a key exchange
|
621
623
|
* dh1 = OpenSSL::PKey::DH.new(2048)
|
622
|
-
*
|
624
|
+
* der = dh1.public_key.to_der #you may send this publicly to the participating party
|
623
625
|
* dh2 = OpenSSL::PKey::DH.new(der)
|
624
626
|
* dh2.generate_key! #generate the per-session key pair
|
625
627
|
* symm_key1 = dh1.compute_key(dh2.pub_key)
|
@@ -662,4 +664,3 @@ Init_ossl_dh()
|
|
662
664
|
{
|
663
665
|
}
|
664
666
|
#endif /* NO_DH */
|
665
|
-
|
@@ -291,7 +291,9 @@ ossl_dsa_is_private(VALUE self)
|
|
291
291
|
|
292
292
|
/*
|
293
293
|
* call-seq:
|
294
|
+
* dsa.export([cipher, password]) -> aString
|
294
295
|
* dsa.to_pem([cipher, password]) -> aString
|
296
|
+
* dsa.to_s([cipher, password]) -> aString
|
295
297
|
*
|
296
298
|
* Encodes this DSA to its PEM encoding.
|
297
299
|
*
|
@@ -533,8 +533,8 @@ static VALUE ossl_ec_key_to_string(VALUE self, VALUE ciph, VALUE pass, int forma
|
|
533
533
|
|
534
534
|
/*
|
535
535
|
* call-seq:
|
536
|
-
* key.export
|
537
|
-
* key.
|
536
|
+
* key.export([cipher, pass_phrase]) => String
|
537
|
+
* key.to_pem([cipher, pass_phrase]) => String
|
538
538
|
*
|
539
539
|
* Outputs the EC key in PEM encoding. If +cipher+ and +pass_phrase+ are
|
540
540
|
* given they will be used to encrypt the key. +cipher+ must be an
|
@@ -847,6 +847,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
|
|
847
847
|
}
|
848
848
|
|
849
849
|
/* call-seq:
|
850
|
+
* group1.eql?(group2) => true | false
|
850
851
|
* group1 == group2 => true | false
|
851
852
|
*
|
852
853
|
*/
|
@@ -1316,6 +1317,7 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
|
|
1316
1317
|
|
1317
1318
|
/*
|
1318
1319
|
* call-seq:
|
1320
|
+
* point1.eql?(point2) => true | false
|
1319
1321
|
* point1 == point2 => true | false
|
1320
1322
|
*
|
1321
1323
|
*/
|
@@ -291,8 +291,9 @@ ossl_rsa_is_private(VALUE self)
|
|
291
291
|
|
292
292
|
/*
|
293
293
|
* call-seq:
|
294
|
-
* rsa.
|
295
|
-
* rsa.to_pem(cipher, pass_phrase) => PEM-format String
|
294
|
+
* rsa.export([cipher, pass_phrase]) => PEM-format String
|
295
|
+
* rsa.to_pem([cipher, pass_phrase]) => PEM-format String
|
296
|
+
* rsa.to_s([cipher, pass_phrase]) => PEM-format String
|
296
297
|
*
|
297
298
|
* Outputs this keypair in PEM encoding. If +cipher+ and +pass_phrase+ are
|
298
299
|
* given they will be used to encrypt the key. +cipher+ must be an
|