Skip to content

Conversation

@iyanmv
Copy link
Member

@iyanmv iyanmv commented Jan 23, 2025

ctypes.Structure.__init__() initializes the attributes using the list _fields_. However, this happens before native().OQS_SIG_new() is called. As a result, many attributes are either None or 0.

I propose we manually populate the attributes from self._sig, and then we use these values to construct the dict self.details.

I also add a small unit test to check that Python attributes work.

If you like this approach I can complete this PR by fixing KeyEncapsulation attributes as well.

Fixes: #102

Signed-off-by: Iyán Méndez Veiga <[email protected]>
@iyanmv iyanmv requested a review from vsoftco January 23, 2025 09:19
@iyanmv iyanmv self-assigned this Jan 23, 2025
ctypes.Structure.__init__() initializes attributes using the
list _fields_. However, these are empty because this happens before
native().OQS_SIG_new() or native().OQS_KEM_new() are called.

The dict self.details was showing correct values by reading and
decoding directly from self._sig/self._kem. However, all the other
public attributes like self.method_name, self.alg_version or the keys
and signature lengths were incorrect. Either None or 0 depending on the
ctype defined in _fields_.

Instead, let's manually populate all relevant attributes from _fields_
after OQS_SIG_new() or OQS_KEM_new() are called, and let's use those
values to create the dict self.details.

Signed-off-by: Iyán Méndez Veiga <[email protected]>
Signed-off-by: Iyán Méndez Veiga <[email protected]>
@vsoftco vsoftco merged commit 720f2cc into open-quantum-safe:main Jan 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python attributes do not work

2 participants