Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.ecdsa: improves internal sign_digest routine #23960

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions vlib/crypto/ecdsa/ecdsa.v
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,12 @@ fn sign_digest(key &C.EVP_PKEY, digest []u8) ![]u8 {
// siglen was used to store the size of the signature output. When EVP_PKEY_sign
// was called with NULL signature buffer, siglen will tell maximum size of signature.
siglen := usize(C.EVP_PKEY_size(key))
st := C.EVP_PKEY_sign(ctx, 0, &siglen, digest.data, digest.len)
if st <= 0 {
C.EVP_PKEY_CTX_free(ctx)
return error('Get null buffer length on EVP_PKEY_sign')
}
sig := []u8{len: int(siglen)}

// calls directly with sign
do := C.EVP_PKEY_sign(ctx, sig.data, &siglen, digest.data, digest.len)
if do <= 0 {
unsafe { sig.free() }
C.EVP_PKEY_CTX_free(ctx)
return error('EVP_PKEY_sign fails to sign message')
}
Expand Down
Loading