Skip to content

Commit

Permalink
faest: mark helper functions as static inline
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinas committed Jul 12, 2023
1 parent fb787b2 commit 128fc95
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions faest.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@

// helpers to compute position in signature (sign)

static ATTR_PURE uint8_t* signature_c(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_c(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;

return base_ptr + index * ell_hat_bytes;
}

static ATTR_PURE uint8_t* signature_u_tilde(uint8_t* base_ptr, const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_u_tilde(uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;

return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes;
}

static ATTR_PURE uint8_t* signature_d(uint8_t* base_ptr, const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_d(uint8_t* base_ptr, const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;
Expand All @@ -43,7 +44,8 @@ static ATTR_PURE uint8_t* signature_d(uint8_t* base_ptr, const faest_paramset_t*
return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes + utilde_bytes;
}

static ATTR_PURE uint8_t* signature_a_tilde(uint8_t* base_ptr, const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_a_tilde(uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;
Expand All @@ -52,8 +54,8 @@ static ATTR_PURE uint8_t* signature_a_tilde(uint8_t* base_ptr, const faest_param
return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes + utilde_bytes + ell_bytes;
}

static ATTR_PURE uint8_t* signature_pdec(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_pdec(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const unsigned int tau0 = params->faest_param.t0;
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
Expand All @@ -71,8 +73,8 @@ static ATTR_PURE uint8_t* signature_pdec(uint8_t* base_ptr, unsigned int index,
}
}

static ATTR_PURE uint8_t* signature_com(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_com(uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const unsigned int tau0 = params->faest_param.t0;
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
Expand All @@ -91,37 +93,38 @@ static ATTR_PURE uint8_t* signature_com(uint8_t* base_ptr, unsigned int index,
}
}

static ATTR_PURE uint8_t* signature_chall_3(uint8_t* base_ptr, const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_chall_3(uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
return base_ptr + params->faest_param.sigSize - IV_SIZE - lambda_bytes;
}

static ATTR_PURE uint8_t* signature_iv(uint8_t* base_ptr, const faest_paramset_t* params) {
ATTR_PURE static inline uint8_t* signature_iv(uint8_t* base_ptr, const faest_paramset_t* params) {
return base_ptr + params->faest_param.sigSize - IV_SIZE;
}

// helpers to compute position in signature (verify)

static ATTR_PURE const uint8_t* dsignature_c(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_c(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;

return base_ptr + index * ell_hat_bytes;
}

static ATTR_PURE const uint8_t* dsignature_u_tilde(const uint8_t* base_ptr,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_u_tilde(const uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;

return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes;
}

static ATTR_PURE const uint8_t* dsignature_d(const uint8_t* base_ptr,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_d(const uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;
Expand All @@ -130,8 +133,8 @@ static ATTR_PURE const uint8_t* dsignature_d(const uint8_t* base_ptr,
return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes + utilde_bytes;
}

static ATTR_PURE const uint8_t* dsignature_a_tilde(const uint8_t* base_ptr,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_a_tilde(const uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
const size_t ell_hat_bytes = ell_bytes + 2 * lambda_bytes + UNIVERSAL_HASH_B;
Expand All @@ -140,8 +143,8 @@ static ATTR_PURE const uint8_t* dsignature_a_tilde(const uint8_t* base_ptr,
return base_ptr + (params->faest_param.tau - 1) * ell_hat_bytes + utilde_bytes + ell_bytes;
}

static ATTR_PURE const uint8_t* dsignature_pdec(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_pdec(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const unsigned int tau0 = params->faest_param.t0;
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
Expand All @@ -159,8 +162,8 @@ static ATTR_PURE const uint8_t* dsignature_pdec(const uint8_t* base_ptr, unsigne
}
}

static ATTR_PURE const uint8_t* dsignature_com(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_com(const uint8_t* base_ptr, unsigned int index,
const faest_paramset_t* params) {
const unsigned int tau0 = params->faest_param.t0;
const size_t lambda_bytes = params->faest_param.lambda / 8;
const size_t ell_bytes = params->faest_param.l / 8;
Expand All @@ -179,14 +182,14 @@ static ATTR_PURE const uint8_t* dsignature_com(const uint8_t* base_ptr, unsigned
}
}

static ATTR_PURE const uint8_t* dsignature_chall_3(const uint8_t* base_ptr,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_chall_3(const uint8_t* base_ptr,
const faest_paramset_t* params) {
const size_t lambda_bytes = params->faest_param.lambda / 8;
return base_ptr + params->faest_param.sigSize - IV_SIZE - lambda_bytes;
}

static ATTR_PURE const uint8_t* dsignature_iv(const uint8_t* base_ptr,
const faest_paramset_t* params) {
ATTR_PURE static inline const uint8_t* dsignature_iv(const uint8_t* base_ptr,
const faest_paramset_t* params) {
return base_ptr + params->faest_param.sigSize - IV_SIZE;
}

Expand Down

0 comments on commit 128fc95

Please sign in to comment.