openssl 2.1.3 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +35 -45
  3. data/History.md +237 -1
  4. data/README.md +2 -2
  5. data/ext/openssl/extconf.rb +46 -38
  6. data/ext/openssl/openssl_missing.c +0 -66
  7. data/ext/openssl/openssl_missing.h +59 -43
  8. data/ext/openssl/ossl.c +110 -64
  9. data/ext/openssl/ossl.h +27 -10
  10. data/ext/openssl/ossl_asn1.c +41 -4
  11. data/ext/openssl/ossl_bn.c +251 -134
  12. data/ext/openssl/ossl_bn.h +2 -1
  13. data/ext/openssl/ossl_cipher.c +38 -29
  14. data/ext/openssl/ossl_config.c +412 -41
  15. data/ext/openssl/ossl_config.h +4 -7
  16. data/ext/openssl/ossl_digest.c +25 -60
  17. data/ext/openssl/ossl_engine.c +18 -27
  18. data/ext/openssl/ossl_hmac.c +60 -145
  19. data/ext/openssl/ossl_kdf.c +11 -19
  20. data/ext/openssl/ossl_ns_spki.c +1 -1
  21. data/ext/openssl/ossl_ocsp.c +9 -62
  22. data/ext/openssl/ossl_ocsp.h +3 -3
  23. data/ext/openssl/ossl_pkcs12.c +21 -3
  24. data/ext/openssl/ossl_pkcs7.c +45 -78
  25. data/ext/openssl/ossl_pkcs7.h +16 -0
  26. data/ext/openssl/ossl_pkey.c +1295 -178
  27. data/ext/openssl/ossl_pkey.h +35 -72
  28. data/ext/openssl/ossl_pkey_dh.c +124 -334
  29. data/ext/openssl/ossl_pkey_dsa.c +93 -398
  30. data/ext/openssl/ossl_pkey_ec.c +159 -318
  31. data/ext/openssl/ossl_pkey_rsa.c +105 -484
  32. data/ext/openssl/ossl_rand.c +2 -32
  33. data/ext/openssl/ossl_ssl.c +347 -394
  34. data/ext/openssl/ossl_ssl_session.c +24 -29
  35. data/ext/openssl/ossl_ts.c +1539 -0
  36. data/ext/openssl/ossl_ts.h +16 -0
  37. data/ext/openssl/ossl_x509.c +0 -6
  38. data/ext/openssl/ossl_x509cert.c +169 -13
  39. data/ext/openssl/ossl_x509crl.c +13 -10
  40. data/ext/openssl/ossl_x509ext.c +15 -2
  41. data/ext/openssl/ossl_x509name.c +15 -4
  42. data/ext/openssl/ossl_x509req.c +13 -10
  43. data/ext/openssl/ossl_x509revoked.c +3 -3
  44. data/ext/openssl/ossl_x509store.c +154 -70
  45. data/lib/openssl/bn.rb +1 -1
  46. data/lib/openssl/buffering.rb +37 -5
  47. data/lib/openssl/cipher.rb +1 -1
  48. data/lib/openssl/digest.rb +10 -12
  49. data/lib/openssl/hmac.rb +78 -0
  50. data/lib/openssl/marshal.rb +30 -0
  51. data/lib/openssl/pkcs5.rb +1 -1
  52. data/lib/openssl/pkey.rb +443 -1
  53. data/lib/openssl/ssl.rb +47 -9
  54. data/lib/openssl/version.rb +5 -0
  55. data/lib/openssl/x509.rb +177 -1
  56. data/lib/openssl.rb +24 -9
  57. metadata +10 -79
  58. data/ext/openssl/deprecation.rb +0 -27
  59. data/ext/openssl/ossl_version.h +0 -15
  60. data/ext/openssl/ruby_missing.h +0 -24
  61. data/lib/openssl/config.rb +0 -492
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7698d18ecab870cfddfbc527123fb4e77cd8f993321440167feec83485828ea7
4
- data.tar.gz: 1132a2cc147808d3e42ca9d3f726b24d635da93d3c8e62af31f4f9c8b5c51ce1
3
+ metadata.gz: b75bcd65f8742364f4a513c5ec991648ef6c859b185f2ae87b3eeb1551ab743b
4
+ data.tar.gz: 1e9674192c66fd95a3c201d9afd0d2d755da24ae2847e5abfd68734ba262c811
5
5
  SHA512:
6
- metadata.gz: 99bad919e464275130913d0ba39db26271d3d43f843a27cefc16b7777727715214e26810236227ef2c13588a7311f4cfef6954275f64e034724b21696ecf37e7
7
- data.tar.gz: d44e451531531e45db6f86ecfd2eaa0099c5e4143e5dc1f7794ff85822ef6dc92ad10ac87e62faa1c8a227e2aed1089cde2a022fb71f5eba4b764f6ef7bade12
6
+ metadata.gz: c28bc1d26bb1ae082481d1615d381bd2026b094eae39ddaadbe2791a9bade505bdc0431f19539254f66520feca5b073b675d93c53117b5df880460e029f2641c
7
+ data.tar.gz: b815b33563ece86bc99f7112db593765c8bc32c887511ef5caff77725d64fb3f78e470e1ae4fbec131d04eda464159852aac3373e485d36c47ef32b35f59d99c
data/CONTRIBUTING.md CHANGED
@@ -12,14 +12,17 @@ If you think you found a bug, file a ticket on GitHub. Please DO NOT report
12
12
  security issues here, there is a separate procedure which is described on
13
13
  ["Security at ruby-lang.org"](https://www.ruby-lang.org/en/security/).
14
14
 
15
- When reporting a bug, please make sure you include the version of Ruby, the
16
- version of openssl gem, the version of the OpenSSL library, along with a sample
17
- file that illustrates the problem or link to repository or gem that is
18
- associated with the bug.
15
+ When reporting a bug, please make sure you include:
19
16
 
20
- There is a number of unresolved issues and feature requests for openssl that
17
+ * Ruby version (`ruby -v`)
18
+ * `openssl` gem version (`gem list openssl` and `OpenSSL::VERSION`)
19
+ * OpenSSL library version (`OpenSSL::OPENSSL_VERSION`)
20
+ * A sample file that illustrates the problem or link to the repository or
21
+ gem that is associated with the bug.
22
+
23
+ There are a number of unresolved issues and feature requests for openssl that
21
24
  need review. Before submitting a new ticket, it is recommended to check
22
- [known issues] and [bugs.ruby-lang.org], the previous issue tracker.
25
+ [known issues].
23
26
 
24
27
  ## Submitting patches
25
28
 
@@ -32,62 +35,50 @@ Make sure that your branch does:
32
35
  * Have good commit messages
33
36
  * Follow Ruby's coding style ([DeveloperHowTo])
34
37
  * Pass the test suite successfully (see "Testing")
35
- * Add an entry to [History.md] if necessary
36
38
 
37
39
  ## Testing
38
40
 
39
41
  We have a test suite!
40
42
 
41
43
  Test cases are located under the
42
- [`test/`](https://github.com/ruby/openssl/tree/master/test) directory.
44
+ [`test/openssl`](https://github.com/ruby/openssl/tree/master/test/openssl)
45
+ directory.
43
46
 
44
47
  You can run it with the following three commands:
45
48
 
46
49
  ```
47
- $ rake install_dependencies # installs rake-compiler, test-unit, ...
48
- $ rake compile
49
- $ rake test
50
+ $ bundle install # installs rake-compiler, test-unit, ...
51
+ $ bundle exec rake compile
52
+ $ bundle exec rake test
50
53
  ```
51
54
 
52
- ### Docker
53
-
54
- You can also use Docker Compose to run tests. It can be used to check that your
55
- changes work correctly with various supported versions of Ruby and OpenSSL.
56
-
57
- First, you need to install [Docker](https://www.docker.com/products/docker) and
58
- [Docker Compose](https://www.docker.com/products/docker-compose) on your
59
- computer.
55
+ ### With different versions of OpenSSL
60
56
 
61
- If you're on MacOS or Windows, we recommended to use the official [Docker
62
- Toolbox](https://www.docker.com/products/docker-toolbox). On Linux, follow the
63
- instructions for your package manager. For further information, please check
64
- the [official documentation](https://docs.docker.com/).
57
+ Ruby OpenSSL supports various versions of OpenSSL library. The test suite needs
58
+ to pass on all supported combinations.
65
59
 
66
- Once you have Docker and Docker Compose, running the following commands will
67
- build the container and execute the openssl tests. In this example, we will use
68
- Ruby version 2.3 with OpenSSL version 1.0.2.
60
+ Similarly to when installing `openssl` gem via the `gem` command,
61
+ you can pass a `--with-openssl-dir` argument to `rake compile`
62
+ to specify the OpenSSL library to build against.
69
63
 
70
64
  ```
71
- $ docker-compose build
72
- $ export RUBY_VERSION=ruby-2.3
73
- $ export OPENSSL_VERSION=openssl-1.0.2
74
- $ docker-compose run test
75
-
76
- # You may want an interactive shell for dubugging
77
- $ docker-compose run debug
65
+ $ ( curl -OL https://ftp.openssl.org/source/openssl-3.0.1.tar.gz &&
66
+ tar xf openssl-3.0.1.tar.gz &&
67
+ cd openssl-3.0.1 &&
68
+ ./config --prefix=$HOME/.openssl/openssl-3.0.1 --libdir=lib &&
69
+ make -j4 &&
70
+ make install )
71
+
72
+ $ # in Ruby/OpenSSL's source directory
73
+ $ bundle exec rake clean
74
+ $ bundle exec rake compile -- --with-openssl-dir=$HOME/.openssl/openssl-3.0.1
75
+ $ bundle exec rake test
78
76
  ```
79
77
 
80
- All possible values for `RUBY_VERSION` and `OPENSSL_VERSION` can be found in
81
- [`.travis.yml`](https://github.com/ruby/openssl/tree/master/.travis.yml).
82
-
83
- **NOTE**: these commands must be run from the openssl repository root, in order
84
- to use the
85
- [`docker-compose.yml`](https://github.com/ruby/openssl/blob/master/docker-compose.yml)
86
- file we have provided.
87
-
88
- This Docker image is built using the
89
- [Dockerfile](https://github.com/ruby/openssl/tree/master/tool/ruby-openssl-docker)
90
- provided in the repository.
78
+ The GitHub Actions workflow file
79
+ [`test.yml`](https://github.com/ruby/openssl/tree/master/.github/workflows/test.yml)
80
+ contains useful information for building OpenSSL/LibreSSL and testing against
81
+ them.
91
82
 
92
83
 
93
84
  ## Relation with Ruby source tree
@@ -122,7 +113,6 @@ _Thanks for your contributions!_
122
113
 
123
114
  [GitHub]: https://github.com/ruby/openssl
124
115
  [known issues]: https://github.com/ruby/openssl/issues
125
- [bugs.ruby-lang.org]: https://bugs.ruby-lang.org/issues?utf8=%E2%9C%93&set_filter=1&f%5B%5D=status_id&op%5Bstatus_id%5D=o&f%5B%5D=assigned_to_id&op%5Bassigned_to_id%5D=%3D&v%5Bassigned_to_id%5D%5B%5D=7150&f%5B%5D=&c%5B%5D=project&c%5B%5D=tracker&c%5B%5D=status&c%5B%5D=subject&c%5B%5D=assigned_to&c%5B%5D=updated_on&group_by=&t%5B%5D=
126
116
  [DeveloperHowTo]: https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto
127
117
  [HackerOne]: https://hackerone.com/ruby
128
118
  [Security]: https://www.ruby-lang.org/en/security/
data/History.md CHANGED
@@ -1,3 +1,239 @@
1
+ Version 3.0.1
2
+ =============
3
+
4
+ Merged changes in 2.1.4 and 2.2.2. Additionally, the following issues are fixed
5
+ by this release.
6
+
7
+ Bug fixes
8
+ ---------
9
+
10
+ * Add missing type check in OpenSSL::PKey::PKey#sign's optional parameters.
11
+ [[GitHub #531]](https://github.com/ruby/openssl/pull/531)
12
+ * Work around OpenSSL 3.0's HMAC issues with a zero-length key.
13
+ [[GitHub #538]](https://github.com/ruby/openssl/pull/538)
14
+ * Fix a regression in OpenSSL::PKey::DSA.generate's default of 'q' size.
15
+ [[GitHub #483]](https://github.com/ruby/openssl/issues/483)
16
+ [[GitHub #539]](https://github.com/ruby/openssl/pull/539)
17
+ * Restore OpenSSL::PKey.read's ability to decode "openssl ecparam -genkey"
18
+ output when linked against OpenSSL 3.0.
19
+ [[GitHub #535]](https://github.com/ruby/openssl/pull/535)
20
+ [[GitHub #540]](https://github.com/ruby/openssl/pull/540)
21
+ * Restore error checks in OpenSSL::PKey::EC#{to_der,to_pem}.
22
+ [[GitHub #541]](https://github.com/ruby/openssl/pull/541)
23
+
24
+
25
+ Version 3.0.0
26
+ =============
27
+
28
+ Compatibility notes
29
+ -------------------
30
+
31
+ * OpenSSL 1.0.1 and Ruby 2.3-2.5 are no longer supported.
32
+ [[GitHub #396]](https://github.com/ruby/openssl/pull/396)
33
+ [[GitHub #466]](https://github.com/ruby/openssl/pull/466)
34
+
35
+ * OpenSSL 3.0 support is added. It is the first major version bump from OpenSSL
36
+ 1.1 and contains incompatible changes that affect Ruby/OpenSSL.
37
+ Note that OpenSSL 3.0 support is preliminary and not all features are
38
+ currently available:
39
+ [[GitHub #369]](https://github.com/ruby/openssl/issues/369)
40
+
41
+ - Deprecate the ability to modify `OpenSSL::PKey::PKey` instances. OpenSSL 3.0
42
+ made EVP_PKEY structure immutable, and hence the following methods are not
43
+ available when Ruby/OpenSSL is linked against OpenSSL 3.0.
44
+ [[GitHub #480]](https://github.com/ruby/openssl/pull/480)
45
+
46
+ - `OpenSSL::PKey::RSA#set_key`, `#set_factors`, `#set_crt_params`
47
+ - `OpenSSL::PKey::DSA#set_pqg`, `#set_key`
48
+ - `OpenSSL::PKey::DH#set_pqg`, `#set_key`, `#generate_key!`
49
+ - `OpenSSL::PKey::EC#private_key=`, `#public_key=`, `#group=`, `#generate_key!`
50
+
51
+ - Deprecate `OpenSSL::Engine`. The ENGINE API has been deprecated in OpenSSL 3.0
52
+ in favor of the new "provider" concept and will be removed in a future
53
+ version.
54
+ [[GitHub #481]](https://github.com/ruby/openssl/pull/481)
55
+
56
+ * `OpenSSL::SSL::SSLContext#tmp_ecdh_callback` has been removed. It has been
57
+ deprecated since v2.0.0 because it is incompatible with modern OpenSSL
58
+ versions.
59
+ [[GitHub #394]](https://github.com/ruby/openssl/pull/394)
60
+
61
+ * `OpenSSL::SSL::SSLSocket#read` and `#write` now raise `OpenSSL::SSL::SSLError`
62
+ if called before a TLS connection is established. Historically, they
63
+ read/wrote unencrypted data to the underlying socket directly in that case.
64
+ [[GitHub #9]](https://github.com/ruby/openssl/issues/9)
65
+ [[GitHub #469]](https://github.com/ruby/openssl/pull/469)
66
+
67
+
68
+ Notable changes
69
+ ---------------
70
+
71
+ * Enhance OpenSSL::PKey's common interface.
72
+ [[GitHub #370]](https://github.com/ruby/openssl/issues/370)
73
+
74
+ - Key deserialization: Enhance `OpenSSL::PKey.read` to handle PEM encoding of
75
+ DH parameters, which used to be only deserialized by `OpenSSL::PKey::DH.new`.
76
+ [[GitHub #328]](https://github.com/ruby/openssl/issues/328)
77
+ - Key generation: Add `OpenSSL::PKey.generate_parameters` and
78
+ `OpenSSL::PKey.generate_key`.
79
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
80
+ - Public key signing: Enhance `OpenSSL::PKey::PKey#sign` and `#verify` to use
81
+ the new EVP_DigestSign() family to enable PureEdDSA support on OpenSSL 1.1.1
82
+ or later. They also now take optional algorithm-specific parameters for more
83
+ control.
84
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
85
+ - Low-level public key signing and verification: Add
86
+ `OpenSSL::PKey::PKey#sign_raw`, `#verify_raw`, and `#verify_recover`.
87
+ [[GitHub #382]](https://github.com/ruby/openssl/issues/382)
88
+ - Public key encryption: Add `OpenSSL::PKey::PKey#encrypt` and `#decrypt`.
89
+ [[GitHub #382]](https://github.com/ruby/openssl/issues/382)
90
+ - Key agreement: Add `OpenSSL::PKey::PKey#derive`.
91
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
92
+ - Key comparison: Add `OpenSSL::PKey::PKey#compare?` to conveniently check
93
+ that two keys have common parameters and a public key.
94
+ [[GitHub #383]](https://github.com/ruby/openssl/issues/383)
95
+
96
+ * Add `OpenSSL::BN#set_flags` and `#get_flags`. This can be used in combination
97
+ with `OpenSSL::BN::CONSTTIME` to force constant-time computation.
98
+ [[GitHub #417]](https://github.com/ruby/openssl/issues/417)
99
+
100
+ * Add `OpenSSL::BN#abs` to get the absolute value of the BIGNUM.
101
+ [[GitHub #430]](https://github.com/ruby/openssl/issues/430)
102
+
103
+ * Add `OpenSSL::SSL::SSLSocket#getbyte`.
104
+ [[GitHub #438]](https://github.com/ruby/openssl/issues/438)
105
+
106
+ * Add `OpenSSL::SSL::SSLContext#tmp_dh=`.
107
+ [[GitHub #459]](https://github.com/ruby/openssl/pull/459)
108
+
109
+ * Add `OpenSSL::X509::Certificate.load` to load a PEM-encoded and concatenated
110
+ list of X.509 certificates at once.
111
+ [[GitHub #441]](https://github.com/ruby/openssl/pull/441)
112
+
113
+ * Change `OpenSSL::X509::Certificate.new` to attempt to deserialize the given
114
+ string first as DER encoding first and then as PEM encoding to ensure the
115
+ round-trip consistency.
116
+ [[GitHub #442]](https://github.com/ruby/openssl/pull/442)
117
+
118
+ * Update various part of the code base to use the modern API. No breaking
119
+ changes are intended with this. This includes:
120
+
121
+ - `OpenSSL::HMAC` uses the EVP API.
122
+ [[GitHub #371]](https://github.com/ruby/openssl/issues/371)
123
+ - `OpenSSL::Config` uses native OpenSSL API to parse config files.
124
+ [[GitHub #342]](https://github.com/ruby/openssl/issues/342)
125
+
126
+
127
+ Version 2.2.2
128
+ =============
129
+
130
+ Merged changes in 2.1.4.
131
+
132
+
133
+ Version 2.2.1
134
+ =============
135
+
136
+ Merged changes in 2.1.3. Additionally, the following issues are fixed by this
137
+ release.
138
+
139
+ Bug fixes
140
+ ---------
141
+
142
+ * Fix crash in `OpenSSL::Timestamp::{Request,Response,TokenInfo}.new` when
143
+ invalid arguments are given.
144
+ [[GitHub #407]](https://github.com/ruby/openssl/pull/407)
145
+ * Fix `OpenSSL::Timestamp::Factory#create_timestamp` with LibreSSL on platforms
146
+ where `time_t` has a different size from `long`.
147
+ [[GitHub #454]](https://github.com/ruby/openssl/pull/454)
148
+
149
+
150
+ Version 2.2.0
151
+ =============
152
+
153
+ Compatibility notes
154
+ -------------------
155
+
156
+ * Remove unsupported MDC2, DSS, DSS1, and SHA algorithms.
157
+ * Remove `OpenSSL::PKCS7::SignerInfo#name` alias for `#issuer`.
158
+ [[GitHub #266]](https://github.com/ruby/openssl/pull/266)
159
+ * Deprecate `OpenSSL::Config#add_value` and `#[]=` for future removal.
160
+ [[GitHub #322]](https://github.com/ruby/openssl/pull/322)
161
+
162
+
163
+ Notable changes
164
+ ---------------
165
+
166
+ * Change default `OpenSSL::SSL::SSLServer#listen` backlog argument from
167
+ 5 to `Socket::SOMAXCONN`.
168
+ [[GitHub #286]](https://github.com/ruby/openssl/issues/286)
169
+ * Make `OpenSSL::HMAC#==` use a timing safe string comparison.
170
+ [[GitHub #284]](https://github.com/ruby/openssl/pull/284)
171
+ * Add support for SHA3 and BLAKE digests.
172
+ [[GitHub #282]](https://github.com/ruby/openssl/pull/282)
173
+ * Add `OpenSSL::SSL::SSLSocket.open` for opening a `TCPSocket` and
174
+ returning an `OpenSSL::SSL::SSLSocket` for it.
175
+ [[GitHub #225]](https://github.com/ruby/openssl/issues/225)
176
+ * Support marshalling of `OpenSSL::X509` and `OpenSSL::PKey` objects.
177
+ [[GitHub #281]](https://github.com/ruby/openssl/pull/281)
178
+ [[GitHub #363]](https://github.com/ruby/openssl/pull/363)
179
+ * Add `OpenSSL.secure_compare` for timing safe string comparison for
180
+ strings of possibly unequal length.
181
+ [[GitHub #280]](https://github.com/ruby/openssl/pull/280)
182
+ * Add `OpenSSL.fixed_length_secure_compare` for timing safe string
183
+ comparison for strings of equal length.
184
+ [[GitHub #269]](https://github.com/ruby/openssl/pull/269)
185
+ * Add `OpenSSL::SSL::SSLSocket#{finished_message,peer_finished_message}`
186
+ for last finished message sent and received.
187
+ [[GitHub #250]](https://github.com/ruby/openssl/pull/250)
188
+ * Add `OpenSSL::Timestamp` module for handing timestamp requests and
189
+ responses.
190
+ [[GitHub #204]](https://github.com/ruby/openssl/pull/204)
191
+ * Add helper methods for `OpenSSL::X509::Certificate`:
192
+ `find_extension`, `subject_key_identifier`,
193
+ `authority_key_identifier`, `crl_uris`, `ca_issuer_uris` and
194
+ `ocsp_uris`, and for `OpenSSL::X509::CRL`:
195
+ `find_extension` and `subject_key_identifier`.
196
+ [[GitHub #260]](https://github.com/ruby/openssl/pull/260)
197
+ [[GitHub #275]](https://github.com/ruby/openssl/pull/275)
198
+ [[GitHub #293]](https://github.com/ruby/openssl/pull/293)
199
+ * Add `OpenSSL::ECPoint#add` for performing elliptic curve point addition.
200
+ [[GitHub #261]](https://github.com/ruby/openssl/pull/261)
201
+ * Make `OpenSSL::PKey::RSA#{export,to_der}` check `key`, `factors`, and
202
+ `crt_params` to do proper private key serialization.
203
+ [[GitHub #258]](https://github.com/ruby/openssl/pull/258)
204
+ * Add `OpenSSL::SSL::{SSLSocket,SSLServer}#fileno`, returning the
205
+ underlying socket file descriptor number.
206
+ [[GitHub #247]](https://github.com/ruby/openssl/pull/247)
207
+ * Support client certificates with TLS 1.3, and support post-handshake
208
+ authentication with OpenSSL 1.1.1+.
209
+ [[GitHub #239]](https://github.com/ruby/openssl/pull/239)
210
+ * Add `OpenSSL::ASN1::ObjectId#==` for equality testing.
211
+ * Add `OpenSSL::X509::Extension#value_der` for the raw value of
212
+ the extension.
213
+ [[GitHub #234]](https://github.com/ruby/openssl/pull/234)
214
+ * Significantly reduce allocated memory in `OpenSSL::Buffering#do_write`.
215
+ [[GitHub #212]](https://github.com/ruby/openssl/pull/212)
216
+ * Ensure all valid IPv6 addresses are considered valid as elements
217
+ of subjectAlternativeName in certificates.
218
+ [[GitHub #185]](https://github.com/ruby/openssl/pull/185)
219
+ * Allow recipient's certificate to be omitted in PCKS7#decrypt.
220
+ [[GitHub #183]](https://github.com/ruby/openssl/pull/183)
221
+ * Add support for reading keys in PKCS #8 format and export via instance methods
222
+ added to `OpenSSL::PKey` classes: `private_to_der`, `private_to_pem`,
223
+ `public_to_der` and `public_to_pem`.
224
+ [[GitHub #297]](https://github.com/ruby/openssl/pull/297)
225
+
226
+
227
+ Version 2.1.4
228
+ =============
229
+
230
+ Bug fixes
231
+ ---------
232
+
233
+ * Do not use pkg-config if --with-openssl-dir option is specified.
234
+ [[GitHub #486]](https://github.com/ruby/openssl/pull/486)
235
+
236
+
1
237
  Version 2.1.3
2
238
  =============
3
239
 
@@ -19,7 +255,7 @@ Bug fixes
19
255
  [[GitHub #453]](https://github.com/ruby/openssl/pull/453)
20
256
  * Fix misuse of input record separator in `OpenSSL::Buffering` where it was
21
257
  for output.
22
- * Fix wrong interger casting in `OpenSSL::PKey::EC#dsa_verify_asn1`.
258
+ * Fix wrong integer casting in `OpenSSL::PKey::EC#dsa_verify_asn1`.
23
259
  [[GitHub #460]](https://github.com/ruby/openssl/pull/460)
24
260
  * `extconf.rb` explicitly checks that OpenSSL's version number is 1.0.1 or
25
261
  newer but also less than 3.0. Ruby/OpenSSL v2.1.x and v2.2.x will not support
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # OpenSSL for Ruby
2
2
 
3
- [![Build Status](https://travis-ci.org/ruby/openssl.svg?branch=master)](https://travis-ci.org/ruby/openssl)
4
- [![Build status](https://ci.appveyor.com/api/projects/status/b8djtmwo7l26f88y/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/openssl/branch/master)
3
+ [![Actions Status](https://github.com/ruby/openssl/workflows/CI/badge.svg)](https://github.com/ruby/openssl/actions?workflow=CI)
4
+
5
5
 
6
6
  OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the
7
7
  OpenSSL library.
@@ -1,5 +1,5 @@
1
1
  # -*- coding: us-ascii -*-
2
- # frozen_string_literal: false
2
+ # frozen_string_literal: true
3
3
  =begin
4
4
  = Info
5
5
  'OpenSSL for Ruby 2' project
@@ -12,16 +12,12 @@
12
12
  =end
13
13
 
14
14
  require "mkmf"
15
- require File.expand_path('../deprecation', __FILE__)
16
15
 
17
- dir_config("openssl")
16
+ dir_config_given = dir_config("openssl").any?
18
17
  dir_config("kerberos")
19
18
 
20
19
  Logging::message "=== OpenSSL for Ruby configurator ===\n"
21
20
 
22
- # Check with -Werror=deprecated-declarations if available
23
- OpenSSL.deprecated_warning_flag
24
-
25
21
  ##
26
22
  # Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
27
23
  # To turn it on, use: --with-debug or --enable-debug
@@ -30,6 +26,8 @@ if with_config("debug") or enable_config("debug")
30
26
  $defs.push("-DOSSL_DEBUG")
31
27
  end
32
28
 
29
+ have_func("rb_io_maybe_wait") # Ruby 3.1
30
+
33
31
  Logging::message "=== Checking for system dependent stuff... ===\n"
34
32
  have_library("nsl", "t_open")
35
33
  have_library("socket", "socket")
@@ -37,6 +35,12 @@ if $mswin || $mingw
37
35
  have_library("ws2_32")
38
36
  end
39
37
 
38
+ if $mingw
39
+ append_cflags '-D_FORTIFY_SOURCE=2'
40
+ append_ldflags '-fstack-protector'
41
+ have_library 'ssp'
42
+ end
43
+
40
44
  def find_openssl_library
41
45
  if $mswin || $mingw
42
46
  # required for static OpenSSL libraries
@@ -88,7 +92,7 @@ def find_openssl_library
88
92
  end
89
93
 
90
94
  Logging::message "=== Checking for required stuff... ===\n"
91
- pkg_config_found = pkg_config("openssl") && have_header("openssl/ssl.h")
95
+ pkg_config_found = !dir_config_given && pkg_config("openssl") && have_header("openssl/ssl.h")
92
96
 
93
97
  if !pkg_config_found && !find_openssl_library
94
98
  Logging::message "=== Checking for required stuff failed. ===\n"
@@ -100,15 +104,14 @@ end
100
104
 
101
105
  version_ok = if have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
102
106
  is_libressl = true
103
- checking_for("LibreSSL version >= 2.5.0") {
104
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x20500000L", "openssl/opensslv.h") }
107
+ checking_for("LibreSSL version >= 3.1.0") {
108
+ try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30100000L", "openssl/opensslv.h") }
105
109
  else
106
- checking_for("OpenSSL version >= 1.0.1 and < 3.0.0") {
107
- try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") &&
108
- !try_static_assert("OPENSSL_VERSION_MAJOR >= 3", "openssl/opensslv.h") }
110
+ checking_for("OpenSSL version >= 1.0.2") {
111
+ try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10002000L", "openssl/opensslv.h") }
109
112
  end
110
113
  unless version_ok
111
- raise "OpenSSL >= 1.0.1, < 3.0.0 or LibreSSL >= 2.5.0 is required"
114
+ raise "OpenSSL >= 1.0.2 or LibreSSL >= 3.1.0 is required"
112
115
  end
113
116
 
114
117
  # Prevent wincrypt.h from being included, which defines conflicting macro with openssl/x509.h
@@ -119,38 +122,22 @@ end
119
122
  Logging::message "=== Checking for OpenSSL features... ===\n"
120
123
  # compile options
121
124
  have_func("RAND_egd")
122
- engines = %w{builtin_engines openbsd_dev_crypto dynamic 4758cca aep atalla chil
123
- cswift nuron sureware ubsec padlock capi gmp gost cryptodev aesni}
125
+ engines = %w{dynamic 4758cca aep atalla chil
126
+ cswift nuron sureware ubsec padlock capi gmp gost cryptodev}
124
127
  engines.each { |name|
125
- OpenSSL.check_func_or_macro("ENGINE_load_#{name}", "openssl/engine.h")
128
+ have_func("ENGINE_load_#{name}()", "openssl/engine.h")
126
129
  }
127
130
 
128
- # added in 1.0.2
129
- have_func("EC_curve_nist2nid")
130
- have_func("X509_REVOKED_dup")
131
- have_func("X509_STORE_CTX_get0_store")
132
- have_func("SSL_CTX_set_alpn_select_cb")
133
- OpenSSL.check_func_or_macro("SSL_CTX_set1_curves_list", "openssl/ssl.h")
134
- OpenSSL.check_func_or_macro("SSL_CTX_set_ecdh_auto", "openssl/ssl.h")
135
- OpenSSL.check_func_or_macro("SSL_get_server_tmp_key", "openssl/ssl.h")
136
- have_func("SSL_is_server")
137
-
138
131
  # added in 1.1.0
139
- if !have_struct_member("SSL", "ctx", "openssl/ssl.h") ||
140
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x2070000fL", "openssl/opensslv.h")
132
+ if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
141
133
  $defs.push("-DHAVE_OPAQUE_OPENSSL")
142
134
  end
143
- have_func("CRYPTO_lock") || $defs.push("-DHAVE_OPENSSL_110_THREADING_API")
144
- have_func("BN_GENCB_new")
145
- have_func("BN_GENCB_free")
146
- have_func("BN_GENCB_get_arg")
147
135
  have_func("EVP_MD_CTX_new")
148
136
  have_func("EVP_MD_CTX_free")
149
- have_func("HMAC_CTX_new")
150
- have_func("HMAC_CTX_free")
151
- OpenSSL.check_func("RAND_pseudo_bytes", "openssl/rand.h") # deprecated
137
+ have_func("EVP_MD_CTX_pkey_ctx")
152
138
  have_func("X509_STORE_get_ex_data")
153
139
  have_func("X509_STORE_set_ex_data")
140
+ have_func("X509_STORE_get_ex_new_index")
154
141
  have_func("X509_CRL_get0_signature")
155
142
  have_func("X509_REQ_get0_signature")
156
143
  have_func("X509_REVOKED_get0_serialNumber")
@@ -166,16 +153,37 @@ have_func("X509_CRL_up_ref")
166
153
  have_func("X509_STORE_up_ref")
167
154
  have_func("SSL_SESSION_up_ref")
168
155
  have_func("EVP_PKEY_up_ref")
169
- OpenSSL.check_func_or_macro("SSL_CTX_set_tmp_ecdh_callback", "openssl/ssl.h") # removed
170
- OpenSSL.check_func_or_macro("SSL_CTX_set_min_proto_version", "openssl/ssl.h")
156
+ have_func("SSL_CTX_set_min_proto_version(NULL, 0)", "openssl/ssl.h")
171
157
  have_func("SSL_CTX_get_security_level")
172
158
  have_func("X509_get0_notBefore")
173
159
  have_func("SSL_SESSION_get_protocol_version")
160
+ have_func("TS_STATUS_INFO_get0_status")
161
+ have_func("TS_STATUS_INFO_get0_text")
162
+ have_func("TS_STATUS_INFO_get0_failure_info")
163
+ have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", "openssl/ts.h")
164
+ have_func("TS_VERIFY_CTX_set_store")
165
+ have_func("TS_VERIFY_CTX_add_flags")
166
+ have_func("TS_RESP_CTX_set_time_cb")
174
167
  have_func("EVP_PBE_scrypt")
168
+ have_func("SSL_CTX_set_post_handshake_auth")
169
+
170
+ # added in 1.1.1
171
+ have_func("EVP_PKEY_check")
172
+ have_func("EVP_PKEY_new_raw_private_key")
173
+
174
+ # added in 3.0.0
175
+ have_func("SSL_set0_tmp_dh_pkey")
176
+ have_func("ERR_get_error_all")
177
+ have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", "openssl/ts.h")
178
+ have_func("SSL_CTX_load_verify_file")
179
+ have_func("BN_check_prime")
180
+ have_func("EVP_MD_CTX_get0_md")
181
+ have_func("EVP_MD_CTX_get_pkey_ctx")
182
+ have_func("EVP_PKEY_eq")
183
+ have_func("EVP_PKEY_dup")
175
184
 
176
185
  Logging::message "=== Checking done. ===\n"
177
186
 
178
187
  create_header
179
- OpenSSL.restore_warning_flag
180
188
  create_makefile("openssl")
181
189
  Logging::message "Done.\n"
@@ -10,77 +10,11 @@
10
10
  #include RUBY_EXTCONF_H
11
11
 
12
12
  #include <string.h> /* memcpy() */
13
- #if !defined(OPENSSL_NO_ENGINE)
14
- # include <openssl/engine.h>
15
- #endif
16
- #if !defined(OPENSSL_NO_HMAC)
17
- # include <openssl/hmac.h>
18
- #endif
19
13
  #include <openssl/x509_vfy.h>
20
14
 
21
15
  #include "openssl_missing.h"
22
16
 
23
- /* added in 1.0.2 */
24
- #if !defined(OPENSSL_NO_EC)
25
- #if !defined(HAVE_EC_CURVE_NIST2NID)
26
- static struct {
27
- const char *name;
28
- int nid;
29
- } nist_curves[] = {
30
- {"B-163", NID_sect163r2},
31
- {"B-233", NID_sect233r1},
32
- {"B-283", NID_sect283r1},
33
- {"B-409", NID_sect409r1},
34
- {"B-571", NID_sect571r1},
35
- {"K-163", NID_sect163k1},
36
- {"K-233", NID_sect233k1},
37
- {"K-283", NID_sect283k1},
38
- {"K-409", NID_sect409k1},
39
- {"K-571", NID_sect571k1},
40
- {"P-192", NID_X9_62_prime192v1},
41
- {"P-224", NID_secp224r1},
42
- {"P-256", NID_X9_62_prime256v1},
43
- {"P-384", NID_secp384r1},
44
- {"P-521", NID_secp521r1}
45
- };
46
-
47
- int
48
- ossl_EC_curve_nist2nid(const char *name)
49
- {
50
- size_t i;
51
- for (i = 0; i < (sizeof(nist_curves) / sizeof(nist_curves[0])); i++) {
52
- if (!strcmp(nist_curves[i].name, name))
53
- return nist_curves[i].nid;
54
- }
55
- return NID_undef;
56
- }
57
- #endif
58
- #endif
59
-
60
17
  /*** added in 1.1.0 ***/
61
- #if !defined(HAVE_HMAC_CTX_NEW)
62
- HMAC_CTX *
63
- ossl_HMAC_CTX_new(void)
64
- {
65
- HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
66
- if (!ctx)
67
- return NULL;
68
- HMAC_CTX_init(ctx);
69
- return ctx;
70
- }
71
- #endif
72
-
73
- #if !defined(HAVE_HMAC_CTX_FREE)
74
- void
75
- ossl_HMAC_CTX_free(HMAC_CTX *ctx)
76
- {
77
- if (ctx) {
78
- HMAC_CTX_cleanup(ctx);
79
- OPENSSL_free(ctx);
80
- }
81
- }
82
- #endif
83
-
84
18
  #if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
85
19
  void
86
20
  ossl_X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,