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

The "(maximum) length" words in OQS_SIG and OQS_KEM are misleading #1744

Closed
wangweij opened this issue Apr 2, 2024 · 5 comments
Closed

The "(maximum) length" words in OQS_SIG and OQS_KEM are misleading #1744

wangweij opened this issue Apr 2, 2024 · 5 comments

Comments

@wangweij
Copy link
Contributor

wangweij commented Apr 2, 2024

All fields for the lengths of secret keys, public keys, signatures, ciphertexts, and shared secrets in the OQS_SIG and OQS_KEM structs claim they are "The (maximum) length". However, except for the signature length, all of them should be the exact lengths. In fact, only the OQS_SIG_sign function has an out parameter to retrieve the length of the signature.

@cothan
Copy link
Contributor

cothan commented Apr 2, 2024

Hi @wangweij , I'm not sure that I understand your point.

The maximum length actually returns the length, designed for current and the future scheme that are variable in length, if it's variable in length, return the maximum length, otherwise return the exact length.

@wangweij
Copy link
Contributor Author

wangweij commented Apr 2, 2024

Even if a key has a variable length, I don't know how to obtain it. The OQS_KEM_keypair(const OQS_KEM *kem, uint8_t *public_key, uint8_t *secret_key) function only accepts pre-allocating memory of public_key but does not provide any information on the actual length. Thus, although the key's length might vary in theory, this variability isn't practical within the program's context and users must always utilize the entire allocated array.

A variable length only makes sense if the function had been designed as

OQS_STATUS OQS_KEM_keypair(const OQS_KEM *kem, uint8_t *public_key, size_t *public_key_len, uint8_t *secret_key, size_t *secret_key_len);

@SWilson4
Copy link
Member

SWilson4 commented Apr 3, 2024

None of the schemes in liboqs have variable-length keys, in theory or practice. As you note, variable-length keys wouldn't fit with the APIs. You can safely use those as exact lengths.

Even for signature schemes, the only ones with variable-length signatures are Falcon-{512,1024}.

@wangweij
Copy link
Contributor Author

wangweij commented Apr 3, 2024

@SWilson4, thanks for the confirmation. Then, shall we remove the words from the header files?

@SWilson4
Copy link
Member

SWilson4 commented Apr 3, 2024

@SWilson4, thanks for the confirmation. Then, shall we remove the words from the header files?

That seems reasonable to me. Please feel free to create a PR and tag me as a reviewer.

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

No branches or pull requests

3 participants