diff options
| author | Kazuki Yamaguchi <k@rhe.jp> | 2025-11-03 18:26:28 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-06 13:25:09 +0000 |
| commit | 26751e40857be6faf91d0c87362ebae769f51faa (patch) | |
| tree | 065e65f53cc1696d4797d5b27f4dcee3bece0931 /ext/openssl | |
| parent | 18ab5023b63af88eddb083e89e19224e9f25af4d (diff) | |
[ruby/openssl] cipher: raise CipherError for unsupported algorithm name
Raise OpenSSL::Cipher::CipherError instead of ArgumentError or
RuntimeError for consistency.
https://github.com/ruby/openssl/commit/78601c9c34
Diffstat (limited to 'ext/openssl')
| -rw-r--r-- | ext/openssl/ossl_cipher.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index f449c63b69..075e92c67f 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -65,8 +65,8 @@ ossl_evp_get_cipherbyname(VALUE obj) StringValueCStr(obj); cipher = EVP_get_cipherbyname(RSTRING_PTR(obj)); if (!cipher) - ossl_raise(rb_eArgError, - "unsupported cipher algorithm: %"PRIsVALUE, obj); + ossl_raise(eCipherError, "unsupported cipher algorithm: %"PRIsVALUE, + obj); return cipher; } @@ -114,17 +114,13 @@ ossl_cipher_initialize(VALUE self, VALUE str) { EVP_CIPHER_CTX *ctx; const EVP_CIPHER *cipher; - char *name; - name = StringValueCStr(str); GetCipherInit(self, ctx); if (ctx) { ossl_raise(rb_eRuntimeError, "Cipher already initialized!"); } + cipher = ossl_evp_get_cipherbyname(str); AllocCipher(self, ctx); - if (!(cipher = EVP_get_cipherbyname(name))) { - ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%"PRIsVALUE")", str); - } if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1) ossl_raise(eCipherError, NULL); |
