Skip to content

Commit c26029a

Browse files
committed
[tests] update the OpenSSL wrapper signing function to use Keccak256
1 parent e89e984 commit c26029a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/openssl_wrapper.nim

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ proc EVP_DigestSignInit*(ctx: EVP_MD_CTX,
9292
e: pointer,
9393
pkey: EVP_PKEY): cint
9494

95+
96+
proc EVP_MD_fetch*(ctx: OSSL_LIB_CTX, algorithm: cstring, properties: cstring): pointer
97+
9598
proc EVP_DigestSign*(ctx: EVP_MD_CTX,
9699
sig: ptr byte,
97100
siglen: ptr uint,
@@ -138,7 +141,12 @@ proc signMessageOpenSSL*(sig: var array[72, byte], msg: openArray[byte], key: EV
138141
let ctx = EVP_MD_CTX_new()
139142
var pctx: EVP_PKEY_CTX
140143

141-
if EVP_DigestSignInit(ctx, addr pctx, EVP_sha256(), nil, key) <= 0:
144+
let md = EVP_MD_fetch(nil, "KECCAK-256", nil)
145+
if md.isNil:
146+
raise newException(Exception, "Failed to fetch KECCAK-256")
147+
148+
149+
if EVP_DigestSignInit(ctx, addr pctx, md, nil, key) <= 0:
142150
raise newException(Exception, "Signing init failed")
143151

144152
# Get required signature length

0 commit comments

Comments
 (0)