Skip to content

Commit de54be0

Browse files
authored
crypto.ecdsa: improves internal function of calc_digest_with_evpkey (#23901)
1 parent 4cc6f25 commit de54be0

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

vlib/crypto/ecdsa/ecdsa.v

+1-6
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,6 @@ fn calc_digest_with_evpkey(key &C.EVP_PKEY, message []u8, opt SignerOpts) ![]u8
318318
if message.len == 0 {
319319
return error('null-length messages')
320320
}
321-
bits_size := C.EVP_PKEY_get_bits(key)
322-
if bits_size <= 0 {
323-
return error(' bits_size was invalid')
324-
}
325-
key_size := (bits_size + 7) / 8
326-
327321
match opt.hash_config {
328322
.with_no_hash, .with_recommended_hash {
329323
md := default_digest(key)!
@@ -337,6 +331,7 @@ fn calc_digest_with_evpkey(key &C.EVP_PKEY, message []u8, opt SignerOpts) ![]u8
337331
if cfg.custom_hash == unsafe { nil } {
338332
return error('Custom hasher was not defined')
339333
}
334+
key_size := evp_key_size(key)!
340335
if key_size > cfg.custom_hash.size() {
341336
if !cfg.allow_smaller_size {
342337
return error('Hash into smaller size than current key size was not allowed')

0 commit comments

Comments
 (0)