From de54be058e66df40723bc009116b96163ce8367d Mon Sep 17 00:00:00 2001 From: blackshirt Date: Tue, 11 Mar 2025 16:27:14 +0700 Subject: [PATCH] crypto.ecdsa: improves internal function of `calc_digest_with_evpkey` (#23901) --- vlib/crypto/ecdsa/ecdsa.v | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vlib/crypto/ecdsa/ecdsa.v b/vlib/crypto/ecdsa/ecdsa.v index 701eb0afce..efb18d5fb0 100644 --- a/vlib/crypto/ecdsa/ecdsa.v +++ b/vlib/crypto/ecdsa/ecdsa.v @@ -318,12 +318,6 @@ fn calc_digest_with_evpkey(key &C.EVP_PKEY, message []u8, opt SignerOpts) ![]u8 if message.len == 0 { return error('null-length messages') } - bits_size := C.EVP_PKEY_get_bits(key) - if bits_size <= 0 { - return error(' bits_size was invalid') - } - key_size := (bits_size + 7) / 8 - match opt.hash_config { .with_no_hash, .with_recommended_hash { md := default_digest(key)! @@ -337,6 +331,7 @@ fn calc_digest_with_evpkey(key &C.EVP_PKEY, message []u8, opt SignerOpts) ![]u8 if cfg.custom_hash == unsafe { nil } { return error('Custom hasher was not defined') } + key_size := evp_key_size(key)! if key_size > cfg.custom_hash.size() { if !cfg.allow_smaller_size { return error('Hash into smaller size than current key size was not allowed')