8000 Add tests for signature API with ctx · Issue #575 · PQClean/PQClean · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add tests for signature API with ctx #575

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

Open
mkannwischer opened this issue Oct 15, 2024 · 1 comment
Open

Add tests for signature API with ctx #575

mkannwischer opened this issue Oct 15, 2024 · 1 comment

Comments

@mkannwischer
Copy link
Contributor

FIPS204 and FIPS205 added an extra argument to the signing API named ctx:

Note that there was an API change introduced in FIPS204 addings a context string:

int crypto_sign_keypair(uint8_t *pk, uint8_t *sk);
 
int crypto_sign_signature(uint8_t *sig, size_t *siglen,
                                         const uint8_t *m, size_t mlen,
                                         const uint8_t *ctx, size_t ctxlen,
                                         const uint8_t *sk);
 
int crypto_sign(uint8_t *sm, size_t *smlen,
                               const uint8_t *m, size_t mlen,
                               const uint8_t *ctx, size_t ctxlen,
                               const uint8_t *sk);
 
int crypto_sign_verify(const uint8_t *sig, size_t siglen,
                                      const uint8_t *m, size_t mlen,
                                      const uint8_t *ctx, size_t ctxlen,
                                      const uint8_t *pk);
 
int crypto_sign_open(uint8_t *m, size_t *mlen,
                                    const uint8_t *sm, size_t smlen,
                                    const uint8_t *ctx, size_t ctxlen,
                                    const uint8_t *pk);

#574 implemented this API in addition to the regular API - liboqs is planning the same API, btw:

int crypto_sign_keypair(uint8_t *pk, uint8_t *sk);
 
int crypto_sign_signature_ctx(uint8_t *sig, size_t *siglen,
                                         const uint8_t *m, size_t mlen,
                                         const uint8_t *ctx, size_t ctxlen,
                                         const uint8_t *sk);
 
int crypto_sign_ctx(uint8_t *sm, size_t *smlen,
                               const uint8_t *m, size_t mlen,
                               const uint8_t *ctx, size_t ctxlen,
                               const uint8_t *sk);
 
int crypto_sign_verify_ctx(const uint8_t *sig, size_t siglen,
                                      const uint8_t *m, size_t mlen,
                                      const uint8_t *ctx, size_t ctxlen,
                                      const uint8_t *pk);
 
int crypto_sign_open_ctx(uint8_t *m, size_t *mlen,
                                    const uint8_t *sm, size_t smlen,
                                    const uint8_t *ctx, size_t ctxlen,
                                    const uint8_t *pk);

#define crypto_sign_signature(sig, siglen, m, mlen, sk) crypto_sign_signature_ctx(sig, siglen, m, mlen, NULL, 0, sk)
#define crypto_sign(sm, smlen, m, mlen, sk) crypto_sign_ctx(sm, smlen, m, mlen, NULL, 0, sk)
#define crypto_sign_verify(sig, siglen, m, mlen, pk) crypto_sign_verify_ctx(sig, siglen, m, mlen, NULL, 0, pk)
#define crypto_sign_open(m, mlen, sm, smlen, pk) crypto_sign_open_ctx(m, mlen, sm, smlen, NULL, 0, pk)

Right now the tests are unchanged, i.e., they only test the default case where ctx is empty.
We should add tests to properly test this API when implemented. Obvious tests are:

  • Signing should yield a different signed message in case a different ctx is passed
  • Verification should fail if different ctx is passed than used in signing
  • Signing and verification should fail if ctxlen > 255
@mkannwischer
Copy link
Contributor Author

Could also add testvectors with a different ctx.

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

1 participant
0