Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Signed-off-by: Vlad Gheorghiu <[email protected]>
  • Loading branch information
vsoftco committed Jan 15, 2025
1 parent b419a08 commit cb372f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions oqs/oqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ class Signature(ct.Structure):
("alg_version", ct.c_char_p),
("claimed_nist_level", ct.c_ubyte),
("euf_cma", ct.c_ubyte),
("sig_with_ctx_support", ct.c_ubyte),
("length_public_key", ct.c_size_t),
("length_secret_key", ct.c_size_t),
("length_signature", ct.c_size_t),
Expand Down Expand Up @@ -394,6 +395,7 @@ def __init__(self, alg_name, secret_key=None):
"version": self._sig.contents.alg_version.decode(),
"claimed_nist_level": int(self._sig.contents.claimed_nist_level),
"is_euf_cma": bool(self._sig.contents.euf_cma),
"sig_with_ctx_support": bool(self._sig.contents.sig_with_ctx_support),
"length_public_key": int(self._sig.contents.length_public_key),
"length_secret_key": int(self._sig.contents.length_secret_key),
"length_signature": int(self._sig.contents.length_signature),
Expand Down Expand Up @@ -440,6 +442,7 @@ def sign(self, message):

# Initialize to maximum signature size
signature_len = ct.c_int(self._sig.contents.length_signature)

rv = native().OQS_SIG_sign(
self._sig,
ct.byref(my_signature),
Expand All @@ -462,13 +465,12 @@ def verify(self, message, signature, public_key):
# Provide length to avoid extra null char
my_message = ct.create_string_buffer(message, len(message))
message_len = ct.c_int(len(my_message))

# Provide length to avoid extra null char in sig
my_signature = ct.create_string_buffer(signature, len(signature))
signature_len = ct.c_int(len(my_signature))
my_public_key = ct.create_string_buffer(
public_key, self._sig.contents.length_public_key
)

rv = native().OQS_SIG_verify(
self._sig,
my_message,
Expand Down Expand Up @@ -496,6 +498,7 @@ def sign_with_ctx_str(self, message, context):

# Initialize to maximum signature size
signature_len = ct.c_int(self._sig.contents.length_signature)

rv = native().OQS_SIG_sign_with_ctx_str(
self._sig,
ct.byref(my_signature),
Expand Down Expand Up @@ -525,10 +528,10 @@ def verify_with_ctx_str(self, message, signature, context, public_key):
signature_len = ct.c_int(len(my_signature))
my_context = ct.create_string_buffer(context, len(context))
context_len = ct.c_int(len(my_context))

my_public_key = ct.create_string_buffer(
public_key, self._sig.contents.length_public_key
)

rv = native().OQS_SIG_verify_with_ctx_str(
self._sig,
my_message,
Expand Down

0 comments on commit cb372f7

Please sign in to comment.