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')