openssl 2.1.4 → 2.2.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 +9 -7
- data/History.md +68 -37
- data/README.md +2 -2
- data/ext/openssl/extconf.rb +43 -41
- data/ext/openssl/openssl_missing.h +36 -1
- data/ext/openssl/ossl.c +49 -23
- data/ext/openssl/ossl.h +7 -4
- data/ext/openssl/ossl_asn1.c +25 -0
- data/ext/openssl/ossl_bn.c +16 -23
- data/ext/openssl/ossl_cipher.c +33 -24
- data/ext/openssl/ossl_digest.c +18 -57
- data/ext/openssl/ossl_engine.c +2 -12
- data/ext/openssl/ossl_hmac.c +5 -11
- data/ext/openssl/ossl_kdf.c +3 -19
- data/ext/openssl/ossl_ns_spki.c +1 -1
- data/ext/openssl/ossl_ocsp.c +6 -11
- data/ext/openssl/ossl_ocsp.h +3 -3
- data/ext/openssl/ossl_pkcs7.c +3 -19
- data/ext/openssl/ossl_pkcs7.h +16 -0
- data/ext/openssl/ossl_pkey.c +180 -14
- data/ext/openssl/ossl_pkey_dsa.c +2 -2
- data/ext/openssl/ossl_pkey_ec.c +37 -8
- data/ext/openssl/ossl_pkey_rsa.c +17 -9
- data/ext/openssl/ossl_rand.c +2 -32
- data/ext/openssl/ossl_ssl.c +78 -72
- data/ext/openssl/ossl_ts.c +1514 -0
- data/ext/openssl/ossl_ts.h +16 -0
- data/ext/openssl/ossl_x509cert.c +2 -2
- data/ext/openssl/ossl_x509ext.c +14 -0
- data/ext/openssl/ossl_x509name.c +7 -3
- data/ext/openssl/ossl_x509store.c +20 -39
- data/lib/openssl/bn.rb +1 -1
- data/lib/openssl/buffering.rb +28 -5
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/config.rb +17 -8
- data/lib/openssl/digest.rb +10 -12
- data/lib/openssl/hmac.rb +13 -0
- data/lib/openssl/marshal.rb +30 -0
- data/lib/openssl/pkcs5.rb +1 -1
- data/lib/openssl/pkey.rb +18 -1
- data/lib/openssl/ssl.rb +40 -2
- data/lib/openssl/version.rb +5 -0
- data/lib/openssl/x509.rb +155 -1
- data/lib/openssl.rb +25 -9
- metadata +13 -24
- data/ext/openssl/deprecation.rb +0 -27
- data/ext/openssl/ossl_version.h +0 -15
data/lib/openssl/x509.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#--
|
3
3
|
# = Ruby-space definitions that completes C-space funcs for X509 and subclasses
|
4
4
|
#
|
@@ -12,6 +12,8 @@
|
|
12
12
|
# (See the file 'LICENCE'.)
|
13
13
|
#++
|
14
14
|
|
15
|
+
require_relative 'marshal'
|
16
|
+
|
15
17
|
module OpenSSL
|
16
18
|
module X509
|
17
19
|
class ExtensionFactory
|
@@ -41,6 +43,8 @@ module OpenSSL
|
|
41
43
|
end
|
42
44
|
|
43
45
|
class Extension
|
46
|
+
include OpenSSL::Marshal
|
47
|
+
|
44
48
|
def ==(other)
|
45
49
|
return false unless Extension === other
|
46
50
|
to_der == other.to_der
|
@@ -60,9 +64,146 @@ module OpenSSL
|
|
60
64
|
def to_a
|
61
65
|
[ self.oid, self.value, self.critical? ]
|
62
66
|
end
|
67
|
+
|
68
|
+
module Helpers
|
69
|
+
def find_extension(oid)
|
70
|
+
extensions.find { |e| e.oid == oid }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module SubjectKeyIdentifier
|
75
|
+
include Helpers
|
76
|
+
|
77
|
+
# Get the subject's key identifier from the subjectKeyIdentifier
|
78
|
+
# exteension, as described in RFC5280 Section 4.2.1.2.
|
79
|
+
#
|
80
|
+
# Returns the binary String key identifier or nil or raises
|
81
|
+
# ASN1::ASN1Error.
|
82
|
+
def subject_key_identifier
|
83
|
+
ext = find_extension("subjectKeyIdentifier")
|
84
|
+
return nil if ext.nil?
|
85
|
+
|
86
|
+
ski_asn1 = ASN1.decode(ext.value_der)
|
87
|
+
if ext.critical? || ski_asn1.tag_class != :UNIVERSAL || ski_asn1.tag != ASN1::OCTET_STRING
|
88
|
+
raise ASN1::ASN1Error, "invalid extension"
|
89
|
+
end
|
90
|
+
|
91
|
+
ski_asn1.value
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
module AuthorityKeyIdentifier
|
96
|
+
include Helpers
|
97
|
+
|
98
|
+
# Get the issuing certificate's key identifier from the
|
99
|
+
# authorityKeyIdentifier extension, as described in RFC5280
|
100
|
+
# Section 4.2.1.1
|
101
|
+
#
|
102
|
+
# Returns the binary String keyIdentifier or nil or raises
|
103
|
+
# ASN1::ASN1Error.
|
104
|
+
def authority_key_identifier
|
105
|
+
ext = find_extension("authorityKeyIdentifier")
|
106
|
+
return nil if ext.nil?
|
107
|
+
|
108
|
+
aki_asn1 = ASN1.decode(ext.value_der)
|
109
|
+
if ext.critical? || aki_asn1.tag_class != :UNIVERSAL || aki_asn1.tag != ASN1::SEQUENCE
|
110
|
+
raise ASN1::ASN1Error, "invalid extension"
|
111
|
+
end
|
112
|
+
|
113
|
+
key_id = aki_asn1.value.find do |v|
|
114
|
+
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
|
115
|
+
end
|
116
|
+
|
117
|
+
key_id.nil? ? nil : key_id.value
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
module CRLDistributionPoints
|
122
|
+
include Helpers
|
123
|
+
|
124
|
+
# Get the distributionPoint fullName URI from the certificate's CRL
|
125
|
+
# distribution points extension, as described in RFC5280 Section
|
126
|
+
# 4.2.1.13
|
127
|
+
#
|
128
|
+
# Returns an array of strings or nil or raises ASN1::ASN1Error.
|
129
|
+
def crl_uris
|
130
|
+
ext = find_extension("crlDistributionPoints")
|
131
|
+
return nil if ext.nil?
|
132
|
+
|
133
|
+
cdp_asn1 = ASN1.decode(ext.value_der)
|
134
|
+
if cdp_asn1.tag_class != :UNIVERSAL || cdp_asn1.tag != ASN1::SEQUENCE
|
135
|
+
raise ASN1::ASN1Error, "invalid extension"
|
136
|
+
end
|
137
|
+
|
138
|
+
crl_uris = cdp_asn1.map do |crl_distribution_point|
|
139
|
+
distribution_point = crl_distribution_point.value.find do |v|
|
140
|
+
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
|
141
|
+
end
|
142
|
+
full_name = distribution_point&.value&.find do |v|
|
143
|
+
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
|
144
|
+
end
|
145
|
+
full_name&.value&.find do |v|
|
146
|
+
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 6 # uniformResourceIdentifier
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
crl_uris&.map(&:value)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
module AuthorityInfoAccess
|
155
|
+
include Helpers
|
156
|
+
|
157
|
+
# Get the information and services for the issuer from the certificate's
|
158
|
+
# authority information access extension exteension, as described in RFC5280
|
159
|
+
# Section 4.2.2.1.
|
160
|
+
#
|
161
|
+
# Returns an array of strings or nil or raises ASN1::ASN1Error.
|
162
|
+
def ca_issuer_uris
|
163
|
+
aia_asn1 = parse_aia_asn1
|
164
|
+
return nil if aia_asn1.nil?
|
165
|
+
|
166
|
+
ca_issuer = aia_asn1.value.select do |authority_info_access|
|
167
|
+
authority_info_access.value.first.value == "caIssuers"
|
168
|
+
end
|
169
|
+
|
170
|
+
ca_issuer&.map(&:value)&.map(&:last)&.map(&:value)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Get the URIs for OCSP from the certificate's authority information access
|
174
|
+
# extension exteension, as described in RFC5280 Section 4.2.2.1.
|
175
|
+
#
|
176
|
+
# Returns an array of strings or nil or raises ASN1::ASN1Error.
|
177
|
+
def ocsp_uris
|
178
|
+
aia_asn1 = parse_aia_asn1
|
179
|
+
return nil if aia_asn1.nil?
|
180
|
+
|
181
|
+
ocsp = aia_asn1.value.select do |authority_info_access|
|
182
|
+
authority_info_access.value.first.value == "OCSP"
|
183
|
+
end
|
184
|
+
|
185
|
+
ocsp&.map(&:value)&.map(&:last)&.map(&:value)
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
def parse_aia_asn1
|
191
|
+
ext = find_extension("authorityInfoAccess")
|
192
|
+
return nil if ext.nil?
|
193
|
+
|
194
|
+
aia_asn1 = ASN1.decode(ext.value_der)
|
195
|
+
if ext.critical? || aia_asn1.tag_class != :UNIVERSAL || aia_asn1.tag != ASN1::SEQUENCE
|
196
|
+
raise ASN1::ASN1Error, "invalid extension"
|
197
|
+
end
|
198
|
+
|
199
|
+
aia_asn1
|
200
|
+
end
|
201
|
+
end
|
63
202
|
end
|
64
203
|
|
65
204
|
class Name
|
205
|
+
include OpenSSL::Marshal
|
206
|
+
|
66
207
|
module RFC2253DN
|
67
208
|
Special = ',=+<>#;'
|
68
209
|
HexChar = /[0-9a-fA-F]/
|
@@ -166,6 +307,8 @@ module OpenSSL
|
|
166
307
|
end
|
167
308
|
|
168
309
|
class Attribute
|
310
|
+
include OpenSSL::Marshal
|
311
|
+
|
169
312
|
def ==(other)
|
170
313
|
return false unless Attribute === other
|
171
314
|
to_der == other.to_der
|
@@ -179,6 +322,12 @@ module OpenSSL
|
|
179
322
|
end
|
180
323
|
|
181
324
|
class Certificate
|
325
|
+
include OpenSSL::Marshal
|
326
|
+
include Extension::SubjectKeyIdentifier
|
327
|
+
include Extension::AuthorityKeyIdentifier
|
328
|
+
include Extension::CRLDistributionPoints
|
329
|
+
include Extension::AuthorityInfoAccess
|
330
|
+
|
182
331
|
def pretty_print(q)
|
183
332
|
q.object_group(self) {
|
184
333
|
q.breakable
|
@@ -192,6 +341,9 @@ module OpenSSL
|
|
192
341
|
end
|
193
342
|
|
194
343
|
class CRL
|
344
|
+
include OpenSSL::Marshal
|
345
|
+
include Extension::AuthorityKeyIdentifier
|
346
|
+
|
195
347
|
def ==(other)
|
196
348
|
return false unless CRL === other
|
197
349
|
to_der == other.to_der
|
@@ -206,6 +358,8 @@ module OpenSSL
|
|
206
358
|
end
|
207
359
|
|
208
360
|
class Request
|
361
|
+
include OpenSSL::Marshal
|
362
|
+
|
209
363
|
def ==(other)
|
210
364
|
return false unless Request === other
|
211
365
|
to_der == other.to_der
|
data/lib/openssl.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
=begin
|
3
3
|
= Info
|
4
4
|
'OpenSSL for Ruby 2' project
|
@@ -12,11 +12,27 @@
|
|
12
12
|
|
13
13
|
require 'openssl.so'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
require_relative 'openssl/bn'
|
16
|
+
require_relative 'openssl/pkey'
|
17
|
+
require_relative 'openssl/cipher'
|
18
|
+
require_relative 'openssl/config'
|
19
|
+
require_relative 'openssl/digest'
|
20
|
+
require_relative 'openssl/hmac'
|
21
|
+
require_relative 'openssl/x509'
|
22
|
+
require_relative 'openssl/ssl'
|
23
|
+
require_relative 'openssl/pkcs5'
|
24
|
+
require_relative 'openssl/version'
|
25
|
+
|
26
|
+
module OpenSSL
|
27
|
+
# call-seq:
|
28
|
+
# OpenSSL.secure_compare(string, string) -> boolean
|
29
|
+
#
|
30
|
+
# Constant time memory comparison. Inputs are hashed using SHA-256 to mask
|
31
|
+
# the length of the secret. Returns +true+ if the strings are identical,
|
32
|
+
# +false+ otherwise.
|
33
|
+
def self.secure_compare(a, b)
|
34
|
+
hashed_a = OpenSSL::Digest.digest('SHA256', a)
|
35
|
+
hashed_b = OpenSSL::Digest.digest('SHA256', b)
|
36
|
+
OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Bosslet
|
8
8
|
- SHIBATA Hiroshi
|
9
9
|
- Zachary Scott
|
10
10
|
- Kazuki Yamaguchi
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: ipaddr
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '0'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
16
|
- !ruby/object:Gem::Dependency
|
31
17
|
name: rake
|
32
18
|
requirement: !ruby/object:Gem::Requirement
|
33
19
|
requirements:
|
34
20
|
- - ">="
|
35
21
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
22
|
+
version: '0'
|
37
23
|
type: :development
|
38
24
|
prerelease: false
|
39
25
|
version_requirements: !ruby/object:Gem::Requirement
|
40
26
|
requirements:
|
41
27
|
- - ">="
|
42
28
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
29
|
+
version: '0'
|
44
30
|
- !ruby/object:Gem::Dependency
|
45
31
|
name: rake-compiler
|
46
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +85,6 @@ files:
|
|
99
85
|
- History.md
|
100
86
|
- LICENSE.txt
|
101
87
|
- README.md
|
102
|
-
- ext/openssl/deprecation.rb
|
103
88
|
- ext/openssl/extconf.rb
|
104
89
|
- ext/openssl/openssl_missing.c
|
105
90
|
- ext/openssl/openssl_missing.h
|
@@ -142,7 +127,8 @@ files:
|
|
142
127
|
- ext/openssl/ossl_ssl.c
|
143
128
|
- ext/openssl/ossl_ssl.h
|
144
129
|
- ext/openssl/ossl_ssl_session.c
|
145
|
-
- ext/openssl/
|
130
|
+
- ext/openssl/ossl_ts.c
|
131
|
+
- ext/openssl/ossl_ts.h
|
146
132
|
- ext/openssl/ossl_x509.c
|
147
133
|
- ext/openssl/ossl_x509.h
|
148
134
|
- ext/openssl/ossl_x509attr.c
|
@@ -160,16 +146,19 @@ files:
|
|
160
146
|
- lib/openssl/cipher.rb
|
161
147
|
- lib/openssl/config.rb
|
162
148
|
- lib/openssl/digest.rb
|
149
|
+
- lib/openssl/hmac.rb
|
150
|
+
- lib/openssl/marshal.rb
|
163
151
|
- lib/openssl/pkcs5.rb
|
164
152
|
- lib/openssl/pkey.rb
|
165
153
|
- lib/openssl/ssl.rb
|
154
|
+
- lib/openssl/version.rb
|
166
155
|
- lib/openssl/x509.rb
|
167
156
|
homepage: https://github.com/ruby/openssl
|
168
157
|
licenses:
|
169
158
|
- Ruby
|
170
159
|
metadata:
|
171
160
|
msys2_mingw_dependencies: openssl
|
172
|
-
post_install_message:
|
161
|
+
post_install_message:
|
173
162
|
rdoc_options:
|
174
163
|
- "--main"
|
175
164
|
- README.md
|
@@ -186,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
175
|
- !ruby/object:Gem::Version
|
187
176
|
version: '0'
|
188
177
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
190
|
-
signing_key:
|
178
|
+
rubygems_version: 3.2.0.pre1
|
179
|
+
signing_key:
|
191
180
|
specification_version: 4
|
192
181
|
summary: OpenSSL provides SSL, TLS and general purpose cryptography.
|
193
182
|
test_files: []
|
data/ext/openssl/deprecation.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
module OpenSSL
|
3
|
-
def self.deprecated_warning_flag
|
4
|
-
unless flag = (@deprecated_warning_flag ||= nil)
|
5
|
-
if try_compile("", flag = "-Werror=deprecated-declarations")
|
6
|
-
$warnflags = "#{@warnflags = $warnflags}" #{flag}"
|
7
|
-
else
|
8
|
-
flag = ""
|
9
|
-
end
|
10
|
-
@deprecated_warning_flag = flag
|
11
|
-
end
|
12
|
-
flag
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.restore_warning_flag
|
16
|
-
$warnflags = @warnflags
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.check_func(func, header)
|
20
|
-
have_func(func, header, deprecated_warning_flag)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.check_func_or_macro(func, header)
|
24
|
-
check_func(func, header) or
|
25
|
-
have_macro(func, header) && $defs.push("-DHAVE_#{func.upcase}")
|
26
|
-
end
|
27
|
-
end
|
data/ext/openssl/ossl_version.h
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* 'OpenSSL for Ruby' project
|
3
|
-
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
4
|
-
* All rights reserved.
|
5
|
-
*/
|
6
|
-
/*
|
7
|
-
* This program is licensed under the same licence as Ruby.
|
8
|
-
* (See the file 'LICENCE'.)
|
9
|
-
*/
|
10
|
-
#if !defined(_OSSL_VERSION_H_)
|
11
|
-
#define _OSSL_VERSION_H_
|
12
|
-
|
13
|
-
#define OSSL_VERSION "2.1.4"
|
14
|
-
|
15
|
-
#endif /* _OSSL_VERSION_H_ */
|