Skip to content

Commit b62375b

Browse files
committed
Support signing CRLs using Ed25519
Allow CRLs to be signed using Ed25519 private keys by passing a nil digest.
1 parent d960903 commit b62375b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/openssl/ossl_x509crl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
350350

351351
GetX509CRL(self, crl);
352352
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
353-
md = ossl_evp_get_digestbyname(digest);
353+
if (NIL_P(digest)) {
354+
md = NULL; /* needed for some key types, e.g. Ed25519 */
355+
} else {
356+
md = ossl_evp_get_digestbyname(digest);
357+
}
354358
if (!X509_CRL_sign(crl, pkey, md)) {
355359
ossl_raise(eX509CRLError, NULL);
356360
}

test/openssl/test_x509crl.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,23 @@ def test_sign_and_verify
204204
assert_equal(false, crl.verify(@dsa512))
205205
end
206206

207+
def test_sign_and_verify_ed25519
208+
# Ed25519 is not FIPS-approved.
209+
omit_on_fips
210+
# See ASN1_item_sign_ctx in ChangeLog for 3.8.1: https://github.com/libressl/portable/blob/master/ChangeLog
211+
omit "Ed25519 not supported" unless openssl?(1, 1, 1) || libressl?(3, 8, 1)
212+
ed25519 = OpenSSL::PKey::generate_key("ED25519")
213+
cert = issue_cert(@ca, ed25519, 1, [], nil, nil, digest: nil)
214+
crl = issue_crl([], 1, Time.now, Time.now+1600, [],
215+
cert, ed25519, nil)
216+
assert_equal(false, crl_error_returns_false { crl.verify(@rsa1024) })
217+
assert_equal(false, crl_error_returns_false { crl.verify(@rsa2048) })
218+
assert_equal(false, crl.verify(OpenSSL::PKey::generate_key("ED25519")))
219+
assert_equal(true, crl.verify(ed25519))
220+
crl.version = 0
221+
assert_equal(false, crl.verify(ed25519))
222+
end
223+
207224
def test_revoked_to_der
208225
# revokedCertificates SEQUENCE OF SEQUENCE {
209226
# userCertificate CertificateSerialNumber,

0 commit comments

Comments
 (0)