Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
ducnguyen-sb committed Oct 20, 2023
1 parent 2ca5d81 commit 8d5190a
Show file tree
Hide file tree
Showing 34 changed files with 706 additions and 353 deletions.
44 changes: 15 additions & 29 deletions src/sig_stfl/sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
OQS_API const char *OQS_SIG_STFL_alg_identifier(size_t i) {

const char *a[OQS_SIG_STFL_algs_length] = {
// XMSS
OQS_SIG_STFL_alg_xmss_sha256_h10,
OQS_SIG_STFL_alg_xmss_sha256_h16,
OQS_SIG_STFL_alg_xmss_sha256_h20,
Expand Down Expand Up @@ -42,6 +43,7 @@ OQS_API const char *OQS_SIG_STFL_alg_identifier(size_t i) {
OQS_SIG_STFL_alg_xmssmt_shake128_h60_3,
OQS_SIG_STFL_alg_xmssmt_shake128_h60_6,
OQS_SIG_STFL_alg_xmssmt_shake128_h60_12,
// LMS
OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1,
OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2,
OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4,
Expand Down Expand Up @@ -799,54 +801,38 @@ OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SIG_STFL_SECRET_KEY_new(const char *method_
}
}

void OQS_SECRET_KEY_XMSS_free(OQS_SIG_STFL_SECRET_KEY *sk) {
if (sk == NULL) {
return;
}

OQS_MEM_secure_free(sk->secret_key_data, sk->length_secret_key);
sk->secret_key_data = NULL;
}

OQS_API void OQS_SIG_STFL_SECRET_KEY_free(OQS_SIG_STFL_SECRET_KEY *sk) {
if (sk == NULL) {
if (sk == NULL || sk->free_key == NULL) {
return;
}

/* Call object specific free */
if (sk->free_key) {
sk->free_key(sk);
}
sk->free_key(sk);

/* Free sk object */
OQS_MEM_secure_free(sk, sizeof(sk));
sk = NULL;
}

OQS_API void OQS_SIG_STFL_SECRET_KEY_SET_store_cb(OQS_SIG_STFL_SECRET_KEY *sk, secure_store_sk store_cb, void *context) {
if (sk) {
if (sk->set_scrt_key_store_cb) {
sk->set_scrt_key_store_cb(sk, store_cb, context);
}
if (sk == NULL || sk->set_scrt_key_store_cb == NULL) {
return;
}
sk->set_scrt_key_store_cb(sk, store_cb, context);
}

/* Convert secret key object to byte string */
OQS_API OQS_STATUS OQS_SECRET_KEY_STFL_serialize_key(const OQS_SIG_STFL_SECRET_KEY *sk, size_t *sk_len, uint8_t **sk_buf) {
if ((sk == NULL) || (sk_len == NULL) || (sk_buf == NULL)) {
return 0;
}
if (sk->serialize_key) {
return sk->serialize_key(sk, sk_len, sk_buf);
} else {
return 0;
if (sk == NULL || sk_len == NULL || sk_buf == NULL || sk->serialize_key == NULL) {
return OQS_ERROR;
}

return sk->serialize_key(sk, sk_len, sk_buf);
}

/* Insert secret key byte string in an Stateful secret key object */
OQS_API OQS_STATUS OQS_SECRET_KEY_STFL_deserialize_key(OQS_SIG_STFL_SECRET_KEY *sk, const size_t key_len, const uint8_t *sk_buf, void *context) {
if ((sk == NULL) || (sk_buf == NULL)) {
return OQS_ERROR;
}

if (sk->deserialize_key == NULL) {
if (sk == NULL || sk_buf == NULL || sk->deserialize_key == NULL) {
return OQS_ERROR;
}

Expand Down
8 changes: 4 additions & 4 deletions src/sig_stfl/sig_stfl.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name);
*/
typedef struct OQS_SIG_STFL {

/** A local ordinal representing the LMS parameter of the signature scheme. */
/** A local ordinal representing the OID parameter of the signature scheme. */
uint32_t oid;

/** Printable string representing the name of the signature scheme. */
Expand Down Expand Up @@ -280,12 +280,12 @@ typedef struct OQS_SIG_STFL_SECRET_KEY {
OQS_STATUS (*serialize_key)(const OQS_SIG_STFL_SECRET_KEY *sk, size_t *sk_len, uint8_t **sk_buf_ptr);

/**
* set Secret Key to internal structure Function
* Secret Key to internal structure Function
*
* @param[in] sk OQS_SIG_STFL_SECRET_KEY object
* @param[in] key_len length of the returned byte string
* @param[in] sk_buf The secret key data to populate key obj
* @param[in] context application specific data
* @param[in] sk_buf The secret key data to populate key object
* @param[in] context application specific data
* @returns status of the operation populated with key material none-zero length. Caller
* deletes the buffer. if sk_buf is NULL the function returns the length
*/
Expand Down
139 changes: 0 additions & 139 deletions src/sig_stfl/xmss/external/sign.c

This file was deleted.

90 changes: 0 additions & 90 deletions src/sig_stfl/xmss/external/sign.h

This file was deleted.

Loading

0 comments on commit 8d5190a

Please sign in to comment.