Skip to content

Commit

Permalink
proposal for using OQS_SIG [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
baentsch committed Jan 26, 2024
1 parent 7e23187 commit 1499916
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sig_stfl/sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,19 +921,27 @@ OQS_API OQS_STATUS OQS_SIG_STFL_verify(const OQS_SIG_STFL *sig, const uint8_t *m
}

OQS_API OQS_STATUS OQS_SIG_STFL_sigs_remaining(const OQS_SIG_STFL *sig, unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) {
#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
return OQS_ERROR;
#else
if (sig == NULL || sig->sigs_remaining == NULL || sig->sigs_remaining(remain, secret_key) != 0) {
return OQS_ERROR;
} else {
return OQS_SUCCESS;
}
#endif
}

OQS_API OQS_STATUS OQS_SIG_STFL_sigs_total(const OQS_SIG_STFL *sig, unsigned long long *max, const OQS_SIG_STFL_SECRET_KEY *secret_key) {
#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
return OQS_ERROR;
#else
if (sig == NULL || sig->sigs_total == NULL || sig->sigs_total(max, secret_key) != 0) {
return OQS_ERROR;
} else {
return OQS_SUCCESS;
}
#endif
}

OQS_API void OQS_SIG_STFL_free(OQS_SIG_STFL *sig) {
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/sig_stfl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ OQS_API int OQS_SIG_STFL_alg_count(void);
*/
OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name);

#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
#define OQS_SIG_STFL OQS_SIG
#else
/**
* Stateful signature scheme object
*/
Expand Down Expand Up @@ -281,6 +284,7 @@ typedef struct OQS_SIG_STFL {
OQS_STATUS (*sigs_total)(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key);

} OQS_SIG_STFL;
#endif

/**
* @brief OQS_SIG_STFL_SECRET_KEY object for stateful signature schemes
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h10_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha256_h10_oid;
#endif
sig->method_name = "XMSS-SHA2_10_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h10_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h10_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h10_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h10_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h16_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha256_h16_oid;
#endif
sig->method_name = "XMSS-SHA2_16_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h16_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h16_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h16_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h16_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h20_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha256_h20_oid;
#endif
sig->method_name = "XMSS-SHA2_20_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h20_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h20_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h20_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h20_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h10_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha512_h10_oid;
#endif
sig->method_name = "XMSS-SHA2_10_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h10_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h10_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h10_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h10_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h16_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha512_h16_oid;
#endif
sig->method_name = "XMSS-SHA2_16_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h16_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h16_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h16_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h16_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h20_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_sha512_h20_oid;
#endif
sig->method_name = "XMSS-SHA2_20_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h20_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h20_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h20_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h20_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h10_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake128_h10_oid;
#endif
sig->method_name = "XMSS-SHAKE_10_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h10_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h10_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h10_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h10_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h16_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake128_h16_oid;
#endif
sig->method_name = "XMSS-SHAKE_16_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h16_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h16_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h16_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h16_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h20_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake128_h20_oid;
#endif
sig->method_name = "XMSS-SHAKE_20_256";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h20_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h20_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h20_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h20_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h10_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake256_h10_oid;
#endif
sig->method_name = "XMSS-SHAKE_10_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h10_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h10_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h10_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h10_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h16_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake256_h16_oid;
#endif
sig->method_name = "XMSS-SHAKE_16_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h16_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h16_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h16_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h16_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_total;
#endif

return sig;
}
Expand Down
4 changes: 4 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h20_new(void) {
}
memset(sig, 0, sizeof(OQS_SIG_STFL));

#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->oid = OQS_SIG_STFL_alg_xmss_shake256_h20_oid;
#endif
sig->method_name = "XMSS-SHAKE_20_512";
sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391";
sig->euf_cma = true;
Expand All @@ -36,8 +38,10 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h20_new(void) {
sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h20_keypair;
sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h20_sign;
sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h20_verify;
#ifdef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN
sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_remaining;
sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_total;
#endif

return sig;
}
Expand Down

0 comments on commit 1499916

Please sign in to comment.