Skip to content

Commit

Permalink
API with checks for signatures without ctx support
Browse files Browse the repository at this point in the history
Additional test for signatures with ctx
[extended tests] [trigger downstream]

Signed-off-by: Basil Hess <[email protected]>
  • Loading branch information
bhess committed Nov 14, 2024
1 parent f77f2d4 commit 3d104e3
Show file tree
Hide file tree
Showing 46 changed files with 513 additions and 675 deletions.
2 changes: 1 addition & 1 deletion docs/algorithms/sig/ml_dsa.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- **Authors' website**: https://pq-crystals.org/dilithium/ and https://csrc.nist.gov/pubs/fips/204/final
- **Specification version**: ML-DSA.
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/pq-crystals/dilit/commit/444cdcc84eb36b66fe27b3a2529ee48f6d8150c2 with copy_from_upstream patches
- **Source**: https://github.com/pq-crystals/dilithium/commit/444cdcc84eb36b66fe27b3a2529ee48f6d8150c2 with copy_from_upstream patches
- **Implementation license (SPDX-Identifier)**: CC0-1.0 or Apache-2.0


Expand Down
2 changes: 1 addition & 1 deletion docs/algorithms/sig/ml_dsa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ website: https://pq-crystals.org/dilithium/ and https://csrc.nist.gov/pubs/fips/
nist-round: FIPS204
spec-version: ML-DSA
primary-upstream:
source: https://github.com/pq-crystals/dilit/commit/444cdcc84eb36b66fe27b3a2529ee48f6d8150c2
source: https://github.com/pq-crystals/dilithium/commit/444cdcc84eb36b66fe27b3a2529ee48f6d8150c2
with copy_from_upstream patches
spdx-license-identifier: CC0-1.0 or Apache-2.0
parameter-sets:
Expand Down
2 changes: 1 addition & 1 deletion scripts/copy_from_upstream/copy_from_upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ upstreams:
patches: [pqcrystals-dilithium-yml.patch, pqcrystals-dilithium-ref-shake-aes.patch, pqcrystals-dilithium-avx2-shake-aes.patch]
-
name: pqcrystals-dilithium-standard
git_url: https://github.com/pq-crystals/dilithium
git_url: https://github.com/pq-crystals/dilithium.git
git_branch: master
git_commit: 444cdcc84eb36b66fe27b3a2529ee48f6d8150c2
sig_meta_path: '{pretty_name_full}_META.yml'
Expand Down
28 changes: 12 additions & 16 deletions scripts/copy_from_upstream/src/sig/family/sig_scheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,25 +344,21 @@ OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_s
{%- endif %}
}
{%- else %}

OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
{%- endif %}
#endif
Expand Down
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_128_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_balanced_verify(const uint8_t *message
return (OQS_STATUS) PQCLEAN_CROSSRSDP128BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_balanced_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_balanced_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_balanced_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_balanced_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_128_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_fast_verify(const uint8_t *message, si
return (OQS_STATUS) PQCLEAN_CROSSRSDP128FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_fast_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_fast_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_fast_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_fast_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_128_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_small_verify(const uint8_t *message, s
return (OQS_STATUS) PQCLEAN_CROSSRSDP128SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_small_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_small_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_small_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_128_small_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_192_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_balanced_verify(const uint8_t *message
return (OQS_STATUS) PQCLEAN_CROSSRSDP192BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_balanced_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_balanced_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_balanced_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_balanced_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_192_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_fast_verify(const uint8_t *message, si
return (OQS_STATUS) PQCLEAN_CROSSRSDP192FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_fast_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_fast_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_fast_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_fast_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_192_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_small_verify(const uint8_t *message, s
return (OQS_STATUS) PQCLEAN_CROSSRSDP192SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_small_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_small_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_small_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_192_small_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_256_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_balanced_verify(const uint8_t *message
return (OQS_STATUS) PQCLEAN_CROSSRSDP256BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_balanced_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_balanced_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_balanced_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_balanced_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_256_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_fast_verify(const uint8_t *message, si
return (OQS_STATUS) PQCLEAN_CROSSRSDP256FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_fast_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_fast_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_fast_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_fast_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
28 changes: 12 additions & 16 deletions src/sig/cross/sig_cross_rsdp_256_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_small_verify(const uint8_t *message, s
return (OQS_STATUS) PQCLEAN_CROSSRSDP256SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
#endif
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_small_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) {
(void) signature;
(void) signature_len;
(void) message;
(void) message_len;
(void) ctx_str;
(void) ctx_str_len;
(void) secret_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_small_sign(signature, signature_len, message, message_len, secret_key);
} else {
return OQS_ERROR;
}
}

OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_small_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) {
(void) message;
(void) message_len;
(void) signature;
(void) signature_len;
(void) ctx_str;
(void) ctx_str_len;
(void) public_key;
return OQS_ERROR;
if (ctx_str == NULL && ctx_str_len == 0) {
return OQS_SIG_cross_rsdp_256_small_verify(message, message_len, signature, signature_len, public_key);
} else {
return OQS_ERROR;
}
}
#endif
Loading

0 comments on commit 3d104e3

Please sign in to comment.