Skip to content

Commit 3f9a87a

Browse files
committed
Merge branch 'maint-3.2'
* maint-3.2: Ruby/OpenSSL 3.2.1 Configure RubyGems Trusted Publishing Ruby/OpenSSL 3.1.1 Ruby/OpenSSL 3.0.3 digest: make output buffer String independent in #finish cipher: make output buffer String independent
2 parents 63db970 + 2d7247e commit 3f9a87a

File tree

7 files changed

+119
-3
lines changed

7 files changed

+119
-3
lines changed

.github/workflows/push_gem.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish gem to rubygems.org
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
push:
13+
if: github.repository == 'ruby/openssl'
14+
runs-on: ubuntu-latest
15+
16+
environment:
17+
name: rubygems.org
18+
url: https://rubygems.org/gems/openssl
19+
20+
permissions:
21+
contents: write
22+
id-token: write
23+
24+
strategy:
25+
matrix:
26+
ruby: [ 'ruby', 'jruby' ]
27+
28+
steps:
29+
- name: Harden Runner
30+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
31+
with:
32+
egress-policy: audit
33+
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Ruby
37+
uses: ruby/setup-ruby@v1
38+
with:
39+
bundler-cache: true
40+
ruby-version: ${{ matrix.ruby }}
41+
42+
- name: Publish to RubyGems
43+
uses: rubygems/release-gem@v1
44+
45+
- name: Create GitHub release
46+
run: |
47+
tag_name="$(git describe --tags --abbrev=0)"
48+
gh release create "${tag_name}" --verify-tag --draft --generate-notes pkg/*.gem
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
if: matrix.ruby == 'ruby'

History.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 3.2.1
2+
=============
3+
4+
Merged changes in 3.0.3.
5+
6+
17
Version 3.2.0
28
=============
39

@@ -38,6 +44,12 @@ Notable changes
3844
[[GitHub #141]](https://github.com/ruby/openssl/pull/141)
3945

4046

47+
Version 3.1.1
48+
=============
49+
50+
Merged changes in 3.0.3.
51+
52+
4153
Version 3.1.0
4254
=============
4355

@@ -74,6 +86,31 @@ Notable changes
7486
LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
7587

7688

89+
Version 3.0.3
90+
=============
91+
92+
Bug fixes
93+
---------
94+
95+
* Fix a performance regression introduced in v2.1.3 on a buffered write to
96+
`SSLSocket`.
97+
[[GitHub #706]](https://github.com/ruby/openssl/pull/706)
98+
* Fix `OpenSSL::PKCS7` to handle PKCS#7 structures without content.
99+
[[GitHub #690]](https://github.com/ruby/openssl/pull/690)
100+
[[GitHub #752]](https://github.com/ruby/openssl/pull/752)
101+
* Fix `OpenSSL::ASN1::ObjectId#==` with OIDs without a known name.
102+
[[GitHub #791]](https://github.com/ruby/openssl/issues/791)
103+
[[GitHub #792]](https://github.com/ruby/openssl/pull/792)
104+
* Fix `OpenSSL::X509::Certificate#crl_uris` to handle CDP with multiple CRL
105+
URIs.
106+
[[GitHub #775]](https://github.com/ruby/openssl/issues/775)
107+
[[GitHub #776]](https://github.com/ruby/openssl/pull/776)
108+
* Fix `OpenSSL::Cipher#update` to always make the output buffer `String`
109+
independent.
110+
[[Bug #20937]](https://bugs.ruby-lang.org/issues/20937)
111+
[[GitHub #824]](https://github.com/ruby/openssl/pull/824)
112+
113+
77114
Version 3.0.2
78115
=============
79116

ext/openssl/ossl_cipher.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
408408
str = rb_str_new(0, out_len);
409409
} else {
410410
StringValue(str);
411-
rb_str_resize(str, out_len);
411+
if ((long)rb_str_capacity(str) >= out_len)
412+
rb_str_modify(str);
413+
else
414+
rb_str_modify_expand(str, out_len - RSTRING_LEN(str));
412415
}
413416

414417
if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))

ext/openssl/ossl_digest.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ ossl_digest_finish(int argc, VALUE *argv, VALUE self)
259259
str = rb_str_new(NULL, out_len);
260260
} else {
261261
StringValue(str);
262+
rb_str_modify(str);
262263
rb_str_resize(str, out_len);
263264
}
264265

lib/openssl/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module OpenSSL
4-
VERSION = "3.2.0"
4+
VERSION = "3.2.1"
55
end

openssl.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = "openssl"
3-
spec.version = "3.2.0"
3+
spec.version = "3.2.1"
44
spec.authors = ["Martin Bosslet", "SHIBATA Hiroshi", "Zachary Scott", "Kazuki Yamaguchi"]
55
spec.email = ["ruby-core@ruby-lang.org"]
66
spec.summary = %q{SSL/TLS and general-purpose cryptography for Ruby}

test/openssl/test_cipher.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ def test_ctr_if_exists
128128
assert_equal pt, cipher.update(ct) << cipher.final
129129
end
130130

131+
def test_update_with_buffer
132+
cipher = OpenSSL::Cipher.new("aes-128-ecb").encrypt
133+
cipher.random_key
134+
expected = cipher.update("data") << cipher.final
135+
assert_equal 16, expected.bytesize
136+
137+
# Buffer is supplied
138+
cipher.reset
139+
buf = String.new
140+
assert_same buf, cipher.update("data", buf)
141+
assert_equal expected, buf + cipher.final
142+
143+
# Buffer is frozen
144+
cipher.reset
145+
assert_raise(FrozenError) { cipher.update("data", String.new.freeze) }
146+
147+
# Buffer is a shared string [ruby-core:120141] [Bug #20937]
148+
cipher.reset
149+
buf = "x" * 1024
150+
shared = buf[-("data".bytesize + 32)..-1]
151+
assert_same shared, cipher.update("data", shared)
152+
assert_equal expected, shared + cipher.final
153+
end
154+
131155
def test_ciphers
132156
ciphers = OpenSSL::Cipher.ciphers
133157
assert_kind_of Array, ciphers

0 commit comments

Comments
 (0)