diff --git a/docs/algorithms/kem/classic_mceliece.md b/docs/algorithms/kem/classic_mceliece.md
index 2c6a267e4..7bc74028c 100644
--- a/docs/algorithms/kem/classic_mceliece.md
+++ b/docs/algorithms/kem/classic_mceliece.md
@@ -6,7 +6,7 @@
- **Authors' website**: https://classic.mceliece.org
- **Specification version**: SUPERCOP-20221025.
- **Primary Source**:
- - **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+ - **Source**: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
- **Implementation license (SPDX-Identifier)**: Public domain
- **Ancestors of primary source**:
- SUPERCOP-20221025 "clean" and "avx2" implementations
diff --git a/docs/algorithms/kem/classic_mceliece.yml b/docs/algorithms/kem/classic_mceliece.yml
index 99a828bc6..385e6e087 100644
--- a/docs/algorithms/kem/classic_mceliece.yml
+++ b/docs/algorithms/kem/classic_mceliece.yml
@@ -378,4 +378,4 @@ parameter-sets:
auxiliary-submitters: []
primary-upstream:
spdx-license-identifier: Public domain
- source: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+ source: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
diff --git a/docs/algorithms/kem/hqc.md b/docs/algorithms/kem/hqc.md
index df32ecdb2..585055a9a 100644
--- a/docs/algorithms/kem/hqc.md
+++ b/docs/algorithms/kem/hqc.md
@@ -6,7 +6,7 @@
- **Authors' website**: https://pqc-hqc.org/
- **Specification version**: 2023-04-30.
- **Primary Source**:
- - **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789 with copy_from_upstream patches
+ - **Source**: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
- **Implementation license (SPDX-Identifier)**: Public domain
- **Ancestors of primary source**:
- https://github.com/SWilson4/package-pqclean/tree/8db1b24b/hqc, which takes it from:
diff --git a/docs/algorithms/kem/hqc.yml b/docs/algorithms/kem/hqc.yml
index a9d0bb260..734ddbba7 100644
--- a/docs/algorithms/kem/hqc.yml
+++ b/docs/algorithms/kem/hqc.yml
@@ -76,5 +76,4 @@ parameter-sets:
upstream: primary-upstream
primary-upstream:
spdx-license-identifier: Public domain
- source: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
- with copy_from_upstream patches
+ source: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
diff --git a/docs/algorithms/sig/falcon.md b/docs/algorithms/sig/falcon.md
index 3dd6dddc9..30d94682b 100644
--- a/docs/algorithms/sig/falcon.md
+++ b/docs/algorithms/sig/falcon.md
@@ -7,9 +7,9 @@
- **Authors' website**: https://falcon-sign.info
- **Specification version**: 20211101.
- **Primary Source**:
- - **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+ - **Source**: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
- **Implementation license (SPDX-Identifier)**: MIT
-- **Optimized Implementation sources**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+- **Optimized Implementation sources**: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
- **pqclean-aarch64**:
- **Source**: https://github.com/PQClean/PQClean/commit/7707d1bcc8ae7f9ffd296dd13b1d76d2767d14f8
- **Implementation license (SPDX-Identifier)**: Apache-2.0
diff --git a/docs/algorithms/sig/falcon.yml b/docs/algorithms/sig/falcon.yml
index 781e188e0..c55c2d4fa 100644
--- a/docs/algorithms/sig/falcon.yml
+++ b/docs/algorithms/sig/falcon.yml
@@ -18,7 +18,7 @@ website: https://falcon-sign.info
nist-round: 3
spec-version: 20211101
primary-upstream:
- source: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+ source: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
spdx-license-identifier: MIT
upstream-ancestors:
- https://www.falcon-sign.info
diff --git a/docs/algorithms/sig/sphincs.md b/docs/algorithms/sig/sphincs.md
index 096a87b29..387f863b6 100644
--- a/docs/algorithms/sig/sphincs.md
+++ b/docs/algorithms/sig/sphincs.md
@@ -7,7 +7,7 @@
- **Authors' website**: https://sphincs.org/
- **Specification version**: NIST Round 3 submission, v3.1 (June 10, 2022).
- **Primary Source**:
- - **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789 with copy_from_upstream patches
+ - **Source**: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181 with copy_from_upstream patches
- **Implementation license (SPDX-Identifier)**: CC0-1.0
diff --git a/docs/algorithms/sig/sphincs.yml b/docs/algorithms/sig/sphincs.yml
index d3e6816c9..c836d7d84 100644
--- a/docs/algorithms/sig/sphincs.yml
+++ b/docs/algorithms/sig/sphincs.yml
@@ -26,7 +26,7 @@ nist-round: 3
spec-version: NIST Round 3 submission, v3.1 (June 10, 2022)
spdx-license-identifier: CC0-1.0
primary-upstream:
- source: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
+ source: https://github.com/PQClean/PQClean/commit/1eacfdafc15ddc5d5759d0b85b4cef26627df181
with copy_from_upstream patches
spdx-license-identifier: CC0-1.0
upstream-ancestors:
diff --git a/scripts/copy_from_upstream/copy_from_upstream.yml b/scripts/copy_from_upstream/copy_from_upstream.yml
index ff23a2287..f80f0979d 100644
--- a/scripts/copy_from_upstream/copy_from_upstream.yml
+++ b/scripts/copy_from_upstream/copy_from_upstream.yml
@@ -15,12 +15,12 @@ upstreams:
name: pqclean
git_url: https://github.com/PQClean/PQClean.git
git_branch: master
- git_commit: 8e221ae797b229858a0b0d784577a8cb149d5789
+ git_commit: 1eacfdafc15ddc5d5759d0b85b4cef26627df181
kem_meta_path: 'crypto_kem/{pqclean_scheme}/META.yml'
sig_meta_path: 'crypto_sign/{pqclean_scheme}/META.yml'
kem_scheme_path: 'crypto_kem/{pqclean_scheme}'
sig_scheme_path: 'crypto_sign/{pqclean_scheme}'
- patches: [pqclean-sphincs.patch, pqclean-hqc-decaps.patch]
+ patches: [pqclean-sphincs.patch]
ignore: pqclean_sphincs-shake-256s-simple_aarch64, pqclean_sphincs-shake-256s-simple_aarch64, pqclean_sphincs-shake-256f-simple_aarch64, pqclean_sphincs-shake-192s-simple_aarch64, pqclean_sphincs-shake-192f-simple_aarch64, pqclean_sphincs-shake-128s-simple_aarch64, pqclean_sphincs-shake-128f-simple_aarch64, pqclean_kyber512_aarch64, pqclean_kyber1024_aarch64, pqclean_kyber768_aarch64, pqclean_dilithium2_aarch64, pqclean_dilithium3_aarch64, pqclean_dilithium5_aarch64
-
name: pqcrystals-kyber
diff --git a/scripts/copy_from_upstream/patches/pqclean-hqc-decaps.patch b/scripts/copy_from_upstream/patches/pqclean-hqc-decaps.patch
deleted file mode 100644
index 87c8b004e..000000000
--- a/scripts/copy_from_upstream/patches/pqclean-hqc-decaps.patch
+++ /dev/null
@@ -1,88 +0,0 @@
-271d40f339844ece6a2046645da68c08a04b0921
-diff --git a/crypto_kem/hqc-128/clean/kem.c b/crypto_kem/hqc-128/clean/kem.c
-index ad09b35..c722a75 100644
---- a/crypto_kem/hqc-128/clean/kem.c
-+++ b/crypto_kem/hqc-128/clean/kem.c
-@@ -87,7 +87,7 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- uint8_t result;
- uint64_t u[VEC_N_SIZE_64] = {0};
- uint64_t v[VEC_N1N2_SIZE_64] = {0};
-- const uint8_t *pk = sk + SEED_BYTES;
-+ const uint8_t *pk = sk + SEED_BYTES + VEC_K_SIZE_BYTES;
- uint8_t sigma[VEC_K_SIZE_BYTES] = {0};
- uint8_t theta[SHAKE256_512_BYTES] = {0};
- uint64_t u2[VEC_N_SIZE_64] = {0};
-@@ -115,7 +115,7 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- result |= PQCLEAN_HQC128_CLEAN_vect_compare((uint8_t *)u, (uint8_t *)u2, VEC_N_SIZE_BYTES);
- result |= PQCLEAN_HQC128_CLEAN_vect_compare((uint8_t *)v, (uint8_t *)v2, VEC_N1N2_SIZE_BYTES);
-
-- result = (uint8_t) (-((int16_t) result) >> 15);
-+ result -= 1;
-
- for (size_t i = 0; i < VEC_K_SIZE_BYTES; ++i) {
- mc[i] = (m[i] & result) ^ (sigma[i] & ~result);
-@@ -126,5 +126,5 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- PQCLEAN_HQC128_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
- PQCLEAN_HQC128_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
-
-- return -(~result & 1);
-+ return (result & 1) - 1;
- }
-diff --git a/crypto_kem/hqc-192/clean/kem.c b/crypto_kem/hqc-192/clean/kem.c
-index f611ebb..95a0023 100644
---- a/crypto_kem/hqc-192/clean/kem.c
-+++ b/crypto_kem/hqc-192/clean/kem.c
-@@ -87,7 +87,7 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- uint8_t result;
- uint64_t u[VEC_N_SIZE_64] = {0};
- uint64_t v[VEC_N1N2_SIZE_64] = {0};
-- const uint8_t *pk = sk + SEED_BYTES;
-+ const uint8_t *pk = sk + SEED_BYTES + VEC_K_SIZE_BYTES;
- uint8_t sigma[VEC_K_SIZE_BYTES] = {0};
- uint8_t theta[SHAKE256_512_BYTES] = {0};
- uint64_t u2[VEC_N_SIZE_64] = {0};
-@@ -115,7 +115,7 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- result |= PQCLEAN_HQC192_CLEAN_vect_compare((uint8_t *)u, (uint8_t *)u2, VEC_N_SIZE_BYTES);
- result |= PQCLEAN_HQC192_CLEAN_vect_compare((uint8_t *)v, (uint8_t *)v2, VEC_N1N2_SIZE_BYTES);
-
-- result = (uint8_t) (-((int16_t) result) >> 15);
-+ result -= 1;
-
- for (size_t i = 0; i < VEC_K_SIZE_BYTES; ++i) {
- mc[i] = (m[i] & result) ^ (sigma[i] & ~result);
-@@ -126,5 +126,5 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- PQCLEAN_HQC192_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
- PQCLEAN_HQC192_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
-
-- return -(~result & 1);
-+ return (result & 1) - 1;
- }
-diff --git a/crypto_kem/hqc-256/clean/kem.c b/crypto_kem/hqc-256/clean/kem.c
-index 4e47e87..d4c6a08 100644
---- a/crypto_kem/hqc-256/clean/kem.c
-+++ b/crypto_kem/hqc-256/clean/kem.c
-@@ -87,7 +87,7 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- uint8_t result;
- uint64_t u[VEC_N_SIZE_64] = {0};
- uint64_t v[VEC_N1N2_SIZE_64] = {0};
-- const uint8_t *pk = sk + SEED_BYTES;
-+ const uint8_t *pk = sk + SEED_BYTES + VEC_K_SIZE_BYTES;
- uint8_t sigma[VEC_K_SIZE_BYTES] = {0};
- uint8_t theta[SHAKE256_512_BYTES] = {0};
- uint64_t u2[VEC_N_SIZE_64] = {0};
-@@ -115,7 +115,7 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- result |= PQCLEAN_HQC256_CLEAN_vect_compare((uint8_t *)u, (uint8_t *)u2, VEC_N_SIZE_BYTES);
- result |= PQCLEAN_HQC256_CLEAN_vect_compare((uint8_t *)v, (uint8_t *)v2, VEC_N1N2_SIZE_BYTES);
-
-- result = (uint8_t) (-((int16_t) result) >> 15);
-+ result -= 1;
-
- for (size_t i = 0; i < VEC_K_SIZE_BYTES; ++i) {
- mc[i] = (m[i] & result) ^ (sigma[i] & ~result);
-@@ -126,5 +126,5 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
- PQCLEAN_HQC256_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
- PQCLEAN_HQC256_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
-
-- return -(~result & 1);
-+ return (result & 1) - 1;
- }
diff --git a/src/kem/hqc/kem_hqc_128.c b/src/kem/hqc/kem_hqc_128.c
index 300ff93e0..0b26784b9 100644
--- a/src/kem/hqc/kem_hqc_128.c
+++ b/src/kem/hqc/kem_hqc_128.c
@@ -13,7 +13,7 @@ OQS_KEM *OQS_KEM_hqc_128_new(void) {
return NULL;
}
kem->method_name = OQS_KEM_alg_hqc_128;
- kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/8db1b24b/hqc";
+ kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/9b509aa7/hqc";
kem->claimed_nist_level = 1;
kem->ind_cca = true;
diff --git a/src/kem/hqc/kem_hqc_192.c b/src/kem/hqc/kem_hqc_192.c
index e0e6d676a..10f9ba7e5 100644
--- a/src/kem/hqc/kem_hqc_192.c
+++ b/src/kem/hqc/kem_hqc_192.c
@@ -13,7 +13,7 @@ OQS_KEM *OQS_KEM_hqc_192_new(void) {
return NULL;
}
kem->method_name = OQS_KEM_alg_hqc_192;
- kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/8db1b24b/hqc";
+ kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/9b509aa7/hqc";
kem->claimed_nist_level = 3;
kem->ind_cca = true;
diff --git a/src/kem/hqc/kem_hqc_256.c b/src/kem/hqc/kem_hqc_256.c
index 6cd66b634..aaf60fd96 100644
--- a/src/kem/hqc/kem_hqc_256.c
+++ b/src/kem/hqc/kem_hqc_256.c
@@ -13,7 +13,7 @@ OQS_KEM *OQS_KEM_hqc_256_new(void) {
return NULL;
}
kem->method_name = OQS_KEM_alg_hqc_256;
- kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/8db1b24b/hqc";
+ kem->alg_version = "hqc-submission_2023-04-30 via https://github.com/SWilson4/package-pqclean/tree/9b509aa7/hqc";
kem->claimed_nist_level = 5;
kem->ind_cca = true;
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/api.h b/src/kem/hqc/pqclean_hqc-128_clean/api.h
index 2a6ccfc56..a361da11c 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/api.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/api.h
@@ -23,4 +23,5 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/code.c b/src/kem/hqc/pqclean_hqc-128_clean/code.c
index acb7910cb..4499c0160 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/code.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/code.c
@@ -8,6 +8,8 @@
* @brief Implementation of concatenated code
*/
+
+
/**
*
* @brief Encoding the message m to a code word em using the concatenated code
@@ -26,6 +28,8 @@ void PQCLEAN_HQC128_CLEAN_code_encode(uint64_t *em, const uint8_t *m) {
}
+
+
/**
* @brief Decoding the code word em to a message m using the concatenated code
*
@@ -38,4 +42,5 @@ void PQCLEAN_HQC128_CLEAN_code_decode(uint8_t *m, const uint64_t *em) {
PQCLEAN_HQC128_CLEAN_reed_muller_decode(tmp, em);
PQCLEAN_HQC128_CLEAN_reed_solomon_decode(m, tmp);
+
}
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/code.h b/src/kem/hqc/pqclean_hqc-128_clean/code.h
index 32a69396e..e6fd629e9 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/code.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/code.h
@@ -1,6 +1,7 @@
#ifndef CODE_H
#define CODE_H
+
/**
* @file code.h
* @brief Header file of code.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC128_CLEAN_code_encode(uint64_t *em, const uint8_t *message);
void PQCLEAN_HQC128_CLEAN_code_decode(uint8_t *m, const uint64_t *em);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/domains.h b/src/kem/hqc/pqclean_hqc-128_clean/domains.h
index 86d0ef849..20c782cca 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/domains.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/domains.h
@@ -1,11 +1,13 @@
#ifndef DOMAINS_H
#define DOMAINS_H
+
/**
* @file domains.h
* @brief SHAKE-256 domains separation header grouping all domains to avoid collisions
*/
+
#define PRNG_DOMAIN 1
#define SEEDEXPANDER_DOMAIN 2
#define G_FCT_DOMAIN 3
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/fft.c b/src/kem/hqc/pqclean_hqc-128_clean/fft.c
index 54e202b92..386e0af43 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/fft.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/fft.c
@@ -14,6 +14,7 @@
* https://binary.cr.yp.to/mcbits-20130616.pdf
*/
+
static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_f);
/**
@@ -28,6 +29,8 @@ static void compute_fft_betas(uint16_t *betas) {
}
}
+
+
/**
* @brief Computes the subset sums of the given set
*
@@ -49,6 +52,8 @@ static void compute_subset_sums(uint16_t *subset_sums, const uint16_t *set, uint
}
}
+
+
/**
* @brief Computes the radix conversion of a polynomial f in GF(2^m)[x]
*
@@ -143,6 +148,8 @@ static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_
memcpy(f1 + n, Q1, 2 * n);
}
+
+
/**
* @brief Evaluates f at all subset sums of a given set
*
@@ -236,6 +243,8 @@ static void fft_rec(uint16_t *w, uint16_t *f, size_t f_coeffs, uint8_t m, uint32
}
}
+
+
/**
* @brief Evaluates f on all fields elements using an additive FFT algorithm
*
@@ -305,6 +314,8 @@ void PQCLEAN_HQC128_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs) {
}
}
+
+
/**
* @brief Retrieves the error polynomial error from the evaluations w of the ELP (Error Locator Polynomial) on all field elements.
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/fft.h b/src/kem/hqc/pqclean_hqc-128_clean/fft.h
index f571437c5..7d9f2367e 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/fft.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/fft.h
@@ -1,6 +1,7 @@
#ifndef FFT_H
#define FFT_H
+
/**
* @file fft.h
* @brief Header file of fft.c
@@ -13,4 +14,5 @@ void PQCLEAN_HQC128_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs);
void PQCLEAN_HQC128_CLEAN_fft_retrieve_error_poly(uint8_t *error, const uint16_t *w);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/gf.c b/src/kem/hqc/pqclean_hqc-128_clean/gf.c
index 504f32a67..0d7387e68 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/gf.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/gf.c
@@ -7,6 +7,7 @@
* @brief Galois field implementation
*/
+
/**
* @brief Computes the number of trailing zero bits.
*
@@ -23,6 +24,8 @@ static uint16_t trailing_zero_bits_count(uint16_t a) {
return tmp;
}
+
+
/**
* Reduces polynomial x modulo primitive polynomial GF_POLY.
* @returns x mod GF_POLY
@@ -57,6 +60,8 @@ static uint16_t gf_reduce(uint64_t x, size_t deg_x) {
return (uint16_t)x;
}
+
+
/**
* Carryless multiplication of two polynomials a and b.
*
@@ -105,6 +110,8 @@ static void gf_carryless_mul(uint8_t c[2], uint8_t a, uint8_t b) {
c[1] = (uint8_t)h;
}
+
+
/**
* Multiplies two elements of GF(2^GF_M).
* @returns the product a*b
@@ -118,6 +125,8 @@ uint16_t PQCLEAN_HQC128_CLEAN_gf_mul(uint16_t a, uint16_t b) {
return gf_reduce(tmp, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Squares an element of GF(2^PARAM_M).
* @returns a^2
@@ -134,6 +143,8 @@ uint16_t PQCLEAN_HQC128_CLEAN_gf_square(uint16_t a) {
return gf_reduce(s, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Computes the inverse of an element of GF(2^PARAM_M),
* using the addition chain 1 2 3 4 7 11 15 30 60 120 127 254
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/gf.h b/src/kem/hqc/pqclean_hqc-128_clean/gf.h
index 1de735168..61a303424 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/gf.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/gf.h
@@ -1,6 +1,7 @@
#ifndef GF_H
#define GF_H
+
/**
* @file gf.h
* @brief Header file of gf.c
@@ -8,6 +9,7 @@
#include
+
/**
* Powers of the root alpha of 1 + x^2 + x^3 + x^4 + x^8.
* The last two elements are needed by the PQCLEAN_HQC128_CLEAN_gf_mul function
@@ -15,16 +17,21 @@
*/
static const uint16_t gf_exp [258] = { 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1, 2, 4 };
+
+
/**
* Logarithm of elements of GF(2^8) to the base alpha (root of 1 + x^2 + x^3 + x^4 + x^8).
* The logarithm of 0 is set to 0 by convention.
*/
static const uint16_t gf_log [256] = { 0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166, 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136, 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64, 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61, 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24, 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46, 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97, 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162, 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246, 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90, 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215, 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175 };
+
+
uint16_t PQCLEAN_HQC128_CLEAN_gf_mul(uint16_t a, uint16_t b);
uint16_t PQCLEAN_HQC128_CLEAN_gf_square(uint16_t a);
uint16_t PQCLEAN_HQC128_CLEAN_gf_inverse(uint16_t a);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/gf2x.c b/src/kem/hqc/pqclean_hqc-128_clean/gf2x.c
index cd5a61048..c66d9f230 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/gf2x.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/gf2x.c
@@ -7,6 +7,7 @@
* @brief Implementation of multiplication of two polynomials
*/
+
/**
* @brief Caryless multiplication of two words of 64 bits
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/gf2x.h b/src/kem/hqc/pqclean_hqc-128_clean/gf2x.h
index d76999b06..8325bfca8 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/gf2x.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/gf2x.h
@@ -9,4 +9,5 @@
void PQCLEAN_HQC128_CLEAN_vect_mul(uint64_t *o, const uint64_t *v1, const uint64_t *v2);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/hqc.c b/src/kem/hqc/pqclean_hqc-128_clean/hqc.c
index ab2641261..eae0ff825 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/hqc.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/hqc.c
@@ -12,6 +12,8 @@
* @brief Implementation of hqc.h
*/
+
+
/**
* @brief Keygen of the HQC_PKE IND_CPA scheme
*
@@ -59,6 +61,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_pke_keygen(uint8_t *pk, uint8_t *sk) {
PQCLEAN_HQC128_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Encryption of the HQC_PKE IND_CPA scheme
*
@@ -108,6 +112,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
PQCLEAN_HQC128_CLEAN_seedexpander_release(&vec_seedexpander);
}
+
+
/**
* @brief Decryption of the HQC_PKE IND_CPA scheme
*
@@ -132,6 +138,7 @@ uint8_t PQCLEAN_HQC128_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const u
PQCLEAN_HQC128_CLEAN_vect_mul(tmp2, y, u);
PQCLEAN_HQC128_CLEAN_vect_add(tmp2, tmp1, tmp2, VEC_N_SIZE_64);
+
// Compute m by decoding v - u.y
PQCLEAN_HQC128_CLEAN_code_decode(m, tmp2);
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/hqc.h b/src/kem/hqc/pqclean_hqc-128_clean/hqc.h
index dc563fe5d..7e96ee8f9 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/hqc.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/hqc.h
@@ -1,6 +1,7 @@
#ifndef HQC_H
#define HQC_H
+
/**
* @file hqc.h
* @brief Functions of the HQC_PKE IND_CPA scheme
@@ -14,4 +15,5 @@ void PQCLEAN_HQC128_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
uint8_t PQCLEAN_HQC128_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const uint64_t *u, const uint64_t *v, const unsigned char *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/kem.c b/src/kem/hqc/pqclean_hqc-128_clean/kem.c
index c722a7578..e0a4681fd 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/kem.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/kem.c
@@ -14,6 +14,8 @@
* @brief Implementation of api.h
*/
+
+
/**
* @brief Keygen of the HQC_KEM IND_CAA2 scheme
*
@@ -32,6 +34,8 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk) {
return 0;
}
+
+
/**
* @brief Encapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -71,9 +75,12 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
// Computing ciphertext
PQCLEAN_HQC128_CLEAN_hqc_ciphertext_to_string(ct, u, v, salt);
+
return 0;
}
+
+
/**
* @brief Decapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -126,5 +133,6 @@ int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
PQCLEAN_HQC128_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
PQCLEAN_HQC128_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
+
return (result & 1) - 1;
}
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/parameters.h b/src/kem/hqc/pqclean_hqc-128_clean/parameters.h
index ffda5bd02..f4ec3e806 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/parameters.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/parameters.h
@@ -1,12 +1,14 @@
#ifndef HQC_PARAMETERS_H
#define HQC_PARAMETERS_H
+
/**
* @file parameters.h
* @brief Parameters of the HQC_KEM IND-CCA2 scheme
*/
#include "api.h"
+
#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/
/*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/parsing.c b/src/kem/hqc/pqclean_hqc-128_clean/parsing.c
index c4f736db0..20dce664b 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/parsing.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/parsing.c
@@ -8,6 +8,7 @@
* @brief Functions to parse secret key, public key and ciphertext of the HQC scheme
*/
+
static uint64_t load8(const uint8_t *in) {
uint64_t ret = in[7];
@@ -71,6 +72,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *s
memcpy(sk + SEED_BYTES + VEC_K_SIZE_BYTES, pk, PUBLIC_KEY_BYTES);
}
+
+
/**
* @brief Parse a secret key from a string
*
@@ -95,6 +98,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, u
PQCLEAN_HQC128_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Parse a public key into a string
*
@@ -109,6 +114,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *p
PQCLEAN_HQC128_CLEAN_store8_arr(pk + SEED_BYTES, VEC_N_SIZE_BYTES, s, VEC_N_SIZE_64);
}
+
+
/**
* @brief Parse a public key from a string
*
@@ -129,6 +136,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, c
PQCLEAN_HQC128_CLEAN_seedexpander_release(&pk_seedexpander);
}
+
+
/**
* @brief Parse a ciphertext into a string
*
@@ -145,6 +154,8 @@ void PQCLEAN_HQC128_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *
memcpy(ct + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, salt, SALT_SIZE_BYTES);
}
+
+
/**
* @brief Parse a ciphertext from a string
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/parsing.h b/src/kem/hqc/pqclean_hqc-128_clean/parsing.h
index b83789b99..f0a0f1667 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/parsing.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/parsing.h
@@ -1,6 +1,7 @@
#ifndef PARSING_H
#define PARSING_H
+
/**
* @file parsing.h
* @brief Header file for parsing.c
@@ -13,16 +14,20 @@ void PQCLEAN_HQC128_CLEAN_load8_arr(uint64_t *out64, size_t outlen, const uint8_
void PQCLEAN_HQC128_CLEAN_store8_arr(uint8_t *out8, size_t outlen, const uint64_t *in64, size_t inlen);
+
void PQCLEAN_HQC128_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *sk_seed, const uint8_t *sigma, const uint8_t *pk);
void PQCLEAN_HQC128_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, uint8_t *sigma, uint8_t *pk, const uint8_t *sk);
+
void PQCLEAN_HQC128_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *pk_seed, const uint64_t *s);
void PQCLEAN_HQC128_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, const uint8_t *pk);
+
void PQCLEAN_HQC128_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *u, const uint64_t *v, const uint8_t *salt);
void PQCLEAN_HQC128_CLEAN_hqc_ciphertext_from_string(uint64_t *u, uint64_t *v, uint8_t *salt, const uint8_t *ct);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.c b/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.c
index ede96cbfd..695fc6b29 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.c
@@ -7,6 +7,7 @@
* @brief Constant time implementation of Reed-Muller code RM(1,7)
*/
+
// number of repeated code words
#define MULTIPLICITY CEIL_DIVIDE(PARAM_N2, 128)
@@ -52,6 +53,8 @@ static void encode(uint64_t *cword, uint8_t message) {
cword[1] |= first_word;
}
+
+
/**
* @brief Hadamard transform
*
@@ -80,6 +83,8 @@ static void hadamard(uint16_t src[128], uint16_t dst[128]) {
}
}
+
+
/**
* @brief Add multiple codewords into expanded codeword
*
@@ -110,6 +115,8 @@ static void expand_and_sum(uint16_t dest[128], const uint64_t src[2 * MULTIPLICI
}
}
+
+
/**
* @brief Finding the location of the highest value
*
@@ -137,6 +144,8 @@ static uint8_t find_peaks(const uint16_t transform[128]) {
return (uint8_t) pos;
}
+
+
/**
* @brief Encodes the received word
*
@@ -157,6 +166,8 @@ void PQCLEAN_HQC128_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg)
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.h b/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.h
index fe9e6872f..fb93fc7a0 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/reed_muller.h
@@ -1,6 +1,7 @@
#ifndef REED_MULLER_H
#define REED_MULLER_H
+
/**
* @file reed_muller.h
* @brief Header file of reed_muller.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC128_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC128_CLEAN_reed_muller_decode(uint8_t *msg, const uint64_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.c b/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.c
index 38abda9a3..70c78ef12 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.c
@@ -9,6 +9,7 @@
* @brief Constant time implementation of Reed-Solomon codes
*/
+
/**
* @brief Encodes a message message of PARAM_K bits to a Reed-Solomon codeword codeword of PARAM_N1 bytes
*
@@ -44,6 +45,8 @@ void PQCLEAN_HQC128_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg)
memcpy(cdw + PARAM_N1 - PARAM_K, msg, PARAM_K);
}
+
+
/**
* @brief Computes 2 * PARAM_DELTA syndromes
*
@@ -59,6 +62,8 @@ static void compute_syndromes(uint16_t *syndromes, uint8_t *cdw) {
}
}
+
+
/**
* @brief Computes the error locator polynomial (ELP) sigma
*
@@ -138,6 +143,8 @@ static uint16_t compute_elp(uint16_t *sigma, const uint16_t *syndromes) {
return deg_sigma;
}
+
+
/**
* @brief Computes the error polynomial error from the error locator polynomial sigma
*
@@ -154,6 +161,8 @@ static void compute_roots(uint8_t *error, uint16_t *sigma) {
PQCLEAN_HQC128_CLEAN_fft_retrieve_error_poly(error, w);
}
+
+
/**
* @brief Computes the polynomial z(x)
*
@@ -187,6 +196,8 @@ static void compute_z_poly(uint16_t *z, const uint16_t *sigma, uint16_t degree,
}
}
+
+
/**
* @brief Computes the error values
*
@@ -257,6 +268,8 @@ static void compute_error_values(uint16_t *error_values, const uint16_t *z, cons
}
}
+
+
/**
* @brief Correct the errors
*
@@ -270,6 +283,8 @@ static void correct_errors(uint8_t *cdw, const uint16_t *error_values) {
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.h b/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.h
index 0cc0b9de4..ad59774fd 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/reed_solomon.h
@@ -1,6 +1,7 @@
#ifndef REED_SOLOMON_H
#define REED_SOLOMON_H
+
/**
* @file reed_solomon.h
* @brief Header file of reed_solomon.c
@@ -14,4 +15,5 @@ void PQCLEAN_HQC128_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC128_CLEAN_reed_solomon_decode(uint8_t *msg, uint8_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.c b/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.c
index 0e7bc23b7..7e2f9234d 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.c
@@ -1,10 +1,13 @@
#include "shake_ds.h"
+
/**
* @file shake_ds.c
* @brief Implementation SHAKE-256 with incremental API and domain separation
*/
+
+
/**
* @brief SHAKE-256 with incremental API and domain separation
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.h b/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.h
index 2ed36586c..822a82dcc 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/shake_ds.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_DS_H
#define SHAKE_DS_H
+
/**
* @file shake_ds.h
* @brief Header file of shake_ds.c
@@ -11,4 +12,5 @@
void PQCLEAN_HQC128_CLEAN_shake256_512_ds(shake256incctx *state, uint8_t *output, const uint8_t *input, size_t inlen, uint8_t domain);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.c b/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.c
index a71278d47..39a2c12ca 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.c
@@ -7,6 +7,7 @@
* @brief Implementation of SHAKE-256 based seed expander
*/
+
/**
* @brief Initialise a SHAKE-256 based seed expander
*
@@ -24,6 +25,8 @@ void PQCLEAN_HQC128_CLEAN_seedexpander_init(seedexpander_state *state, const uin
shake256_inc_finalize(state);
}
+
+
/**
* @brief A SHAKE-256 based seed expander
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.h b/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.h
index e53dd9a08..7c9036fb4 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/shake_prng.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_PRNG_H
#define SHAKE_PRNG_H
+
/**
* @file shake_prng.h
* @brief Header file of shake_prng.c
@@ -17,4 +18,5 @@ void PQCLEAN_HQC128_CLEAN_seedexpander(seedexpander_state *state, uint8_t *outpu
void PQCLEAN_HQC128_CLEAN_seedexpander_release(seedexpander_state *state);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/vector.c b/src/kem/hqc/pqclean_hqc-128_clean/vector.c
index 7ec996aad..c3ff1b781 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/vector.c
+++ b/src/kem/hqc/pqclean_hqc-128_clean/vector.c
@@ -9,6 +9,7 @@
* @brief Implementation of vectors sampling and some utilities for the HQC scheme
*/
+
static uint32_t m_val[75] = { 243079, 243093, 243106, 243120, 243134, 243148, 243161, 243175, 243189, 243203, 243216, 243230, 243244, 243258, 243272, 243285, 243299, 243313, 243327, 243340, 243354, 243368, 243382, 243396, 243409, 243423, 243437, 243451, 243465, 243478, 243492, 243506, 243520, 243534, 243547, 243561, 243575, 243589, 243603, 243616, 243630, 243644, 243658, 243672, 243686, 243699, 243713, 243727, 243741, 243755, 243769, 243782, 243796, 243810, 243824, 243838, 243852, 243865, 243879, 243893, 243907, 243921, 243935, 243949, 243962, 243976, 243990, 244004, 244018, 244032, 244046, 244059, 244073, 244087, 244101 };
/**
@@ -110,6 +111,8 @@ void PQCLEAN_HQC128_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
}
}
+
+
/**
* @brief Generates a random vector of dimension PARAM_N
*
@@ -128,6 +131,8 @@ void PQCLEAN_HQC128_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v)
v[VEC_N_SIZE_64 - 1] &= RED_MASK;
}
+
+
/**
* @brief Adds two vectors
*
@@ -142,6 +147,8 @@ void PQCLEAN_HQC128_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64
}
}
+
+
/**
* @brief Compares two vectors
*
@@ -160,6 +167,8 @@ uint8_t PQCLEAN_HQC128_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2,
return (r - 1) >> 8;
}
+
+
/**
* @brief Resize a vector so that it contains size_o bits
*
diff --git a/src/kem/hqc/pqclean_hqc-128_clean/vector.h b/src/kem/hqc/pqclean_hqc-128_clean/vector.h
index a929fdd81..16b2c920e 100644
--- a/src/kem/hqc/pqclean_hqc-128_clean/vector.h
+++ b/src/kem/hqc/pqclean_hqc-128_clean/vector.h
@@ -1,6 +1,7 @@
#ifndef VECTOR_H
#define VECTOR_H
+
/**
* @file vector.h
* @brief Header file for vector.c
@@ -13,10 +14,12 @@ void PQCLEAN_HQC128_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
void PQCLEAN_HQC128_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v);
+
void PQCLEAN_HQC128_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64_t *v2, size_t size);
uint8_t PQCLEAN_HQC128_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2, size_t size);
void PQCLEAN_HQC128_CLEAN_vect_resize(uint64_t *o, uint32_t size_o, const uint64_t *v, uint32_t size_v);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/api.h b/src/kem/hqc/pqclean_hqc-192_clean/api.h
index 3467b5f39..573a771e4 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/api.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/api.h
@@ -23,4 +23,5 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/code.c b/src/kem/hqc/pqclean_hqc-192_clean/code.c
index 05f5c1efe..ba21fa20b 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/code.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/code.c
@@ -8,6 +8,8 @@
* @brief Implementation of concatenated code
*/
+
+
/**
*
* @brief Encoding the message m to a code word em using the concatenated code
@@ -26,6 +28,8 @@ void PQCLEAN_HQC192_CLEAN_code_encode(uint64_t *em, const uint8_t *m) {
}
+
+
/**
* @brief Decoding the code word em to a message m using the concatenated code
*
@@ -38,4 +42,5 @@ void PQCLEAN_HQC192_CLEAN_code_decode(uint8_t *m, const uint64_t *em) {
PQCLEAN_HQC192_CLEAN_reed_muller_decode(tmp, em);
PQCLEAN_HQC192_CLEAN_reed_solomon_decode(m, tmp);
+
}
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/code.h b/src/kem/hqc/pqclean_hqc-192_clean/code.h
index cdd16d0cc..1318bea39 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/code.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/code.h
@@ -1,6 +1,7 @@
#ifndef CODE_H
#define CODE_H
+
/**
* @file code.h
* @brief Header file of code.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC192_CLEAN_code_encode(uint64_t *em, const uint8_t *message);
void PQCLEAN_HQC192_CLEAN_code_decode(uint8_t *m, const uint64_t *em);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/domains.h b/src/kem/hqc/pqclean_hqc-192_clean/domains.h
index 86d0ef849..20c782cca 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/domains.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/domains.h
@@ -1,11 +1,13 @@
#ifndef DOMAINS_H
#define DOMAINS_H
+
/**
* @file domains.h
* @brief SHAKE-256 domains separation header grouping all domains to avoid collisions
*/
+
#define PRNG_DOMAIN 1
#define SEEDEXPANDER_DOMAIN 2
#define G_FCT_DOMAIN 3
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/fft.c b/src/kem/hqc/pqclean_hqc-192_clean/fft.c
index a43d2e3e8..1763a9422 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/fft.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/fft.c
@@ -14,6 +14,7 @@
* https://binary.cr.yp.to/mcbits-20130616.pdf
*/
+
static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_f);
/**
@@ -28,6 +29,8 @@ static void compute_fft_betas(uint16_t *betas) {
}
}
+
+
/**
* @brief Computes the subset sums of the given set
*
@@ -49,6 +52,8 @@ static void compute_subset_sums(uint16_t *subset_sums, const uint16_t *set, uint
}
}
+
+
/**
* @brief Computes the radix conversion of a polynomial f in GF(2^m)[x]
*
@@ -143,6 +148,8 @@ static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_
memcpy(f1 + n, Q1, 2 * n);
}
+
+
/**
* @brief Evaluates f at all subset sums of a given set
*
@@ -236,6 +243,8 @@ static void fft_rec(uint16_t *w, uint16_t *f, size_t f_coeffs, uint8_t m, uint32
}
}
+
+
/**
* @brief Evaluates f on all fields elements using an additive FFT algorithm
*
@@ -305,6 +314,8 @@ void PQCLEAN_HQC192_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs) {
}
}
+
+
/**
* @brief Retrieves the error polynomial error from the evaluations w of the ELP (Error Locator Polynomial) on all field elements.
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/fft.h b/src/kem/hqc/pqclean_hqc-192_clean/fft.h
index e8b06490f..8337c3ac9 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/fft.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/fft.h
@@ -1,6 +1,7 @@
#ifndef FFT_H
#define FFT_H
+
/**
* @file fft.h
* @brief Header file of fft.c
@@ -13,4 +14,5 @@ void PQCLEAN_HQC192_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs);
void PQCLEAN_HQC192_CLEAN_fft_retrieve_error_poly(uint8_t *error, const uint16_t *w);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/gf.c b/src/kem/hqc/pqclean_hqc-192_clean/gf.c
index da051ff23..517b76a84 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/gf.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/gf.c
@@ -7,6 +7,7 @@
* @brief Galois field implementation
*/
+
/**
* @brief Computes the number of trailing zero bits.
*
@@ -23,6 +24,8 @@ static uint16_t trailing_zero_bits_count(uint16_t a) {
return tmp;
}
+
+
/**
* Reduces polynomial x modulo primitive polynomial GF_POLY.
* @returns x mod GF_POLY
@@ -57,6 +60,8 @@ static uint16_t gf_reduce(uint64_t x, size_t deg_x) {
return (uint16_t)x;
}
+
+
/**
* Carryless multiplication of two polynomials a and b.
*
@@ -105,6 +110,8 @@ static void gf_carryless_mul(uint8_t c[2], uint8_t a, uint8_t b) {
c[1] = (uint8_t)h;
}
+
+
/**
* Multiplies two elements of GF(2^GF_M).
* @returns the product a*b
@@ -118,6 +125,8 @@ uint16_t PQCLEAN_HQC192_CLEAN_gf_mul(uint16_t a, uint16_t b) {
return gf_reduce(tmp, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Squares an element of GF(2^PARAM_M).
* @returns a^2
@@ -134,6 +143,8 @@ uint16_t PQCLEAN_HQC192_CLEAN_gf_square(uint16_t a) {
return gf_reduce(s, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Computes the inverse of an element of GF(2^PARAM_M),
* using the addition chain 1 2 3 4 7 11 15 30 60 120 127 254
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/gf.h b/src/kem/hqc/pqclean_hqc-192_clean/gf.h
index afbdb95ed..398547219 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/gf.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/gf.h
@@ -1,6 +1,7 @@
#ifndef GF_H
#define GF_H
+
/**
* @file gf.h
* @brief Header file of gf.c
@@ -8,6 +9,7 @@
#include
+
/**
* Powers of the root alpha of 1 + x^2 + x^3 + x^4 + x^8.
* The last two elements are needed by the PQCLEAN_HQC192_CLEAN_gf_mul function
@@ -15,16 +17,21 @@
*/
static const uint16_t gf_exp [258] = { 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1, 2, 4 };
+
+
/**
* Logarithm of elements of GF(2^8) to the base alpha (root of 1 + x^2 + x^3 + x^4 + x^8).
* The logarithm of 0 is set to 0 by convention.
*/
static const uint16_t gf_log [256] = { 0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166, 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136, 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64, 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61, 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24, 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46, 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97, 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162, 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246, 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90, 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215, 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175 };
+
+
uint16_t PQCLEAN_HQC192_CLEAN_gf_mul(uint16_t a, uint16_t b);
uint16_t PQCLEAN_HQC192_CLEAN_gf_square(uint16_t a);
uint16_t PQCLEAN_HQC192_CLEAN_gf_inverse(uint16_t a);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/gf2x.c b/src/kem/hqc/pqclean_hqc-192_clean/gf2x.c
index 6ea921738..255147cb0 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/gf2x.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/gf2x.c
@@ -7,6 +7,7 @@
* @brief Implementation of multiplication of two polynomials
*/
+
/**
* @brief Caryless multiplication of two words of 64 bits
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/gf2x.h b/src/kem/hqc/pqclean_hqc-192_clean/gf2x.h
index bf4f74b94..a7569d3f5 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/gf2x.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/gf2x.h
@@ -9,4 +9,5 @@
void PQCLEAN_HQC192_CLEAN_vect_mul(uint64_t *o, const uint64_t *v1, const uint64_t *v2);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/hqc.c b/src/kem/hqc/pqclean_hqc-192_clean/hqc.c
index fbe604126..7ef8d6ab4 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/hqc.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/hqc.c
@@ -12,6 +12,8 @@
* @brief Implementation of hqc.h
*/
+
+
/**
* @brief Keygen of the HQC_PKE IND_CPA scheme
*
@@ -59,6 +61,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_pke_keygen(uint8_t *pk, uint8_t *sk) {
PQCLEAN_HQC192_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Encryption of the HQC_PKE IND_CPA scheme
*
@@ -108,6 +112,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
PQCLEAN_HQC192_CLEAN_seedexpander_release(&vec_seedexpander);
}
+
+
/**
* @brief Decryption of the HQC_PKE IND_CPA scheme
*
@@ -132,6 +138,7 @@ uint8_t PQCLEAN_HQC192_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const u
PQCLEAN_HQC192_CLEAN_vect_mul(tmp2, y, u);
PQCLEAN_HQC192_CLEAN_vect_add(tmp2, tmp1, tmp2, VEC_N_SIZE_64);
+
// Compute m by decoding v - u.y
PQCLEAN_HQC192_CLEAN_code_decode(m, tmp2);
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/hqc.h b/src/kem/hqc/pqclean_hqc-192_clean/hqc.h
index f3458dbba..05cf6e80b 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/hqc.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/hqc.h
@@ -1,6 +1,7 @@
#ifndef HQC_H
#define HQC_H
+
/**
* @file hqc.h
* @brief Functions of the HQC_PKE IND_CPA scheme
@@ -14,4 +15,5 @@ void PQCLEAN_HQC192_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
uint8_t PQCLEAN_HQC192_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const uint64_t *u, const uint64_t *v, const unsigned char *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/kem.c b/src/kem/hqc/pqclean_hqc-192_clean/kem.c
index 95a0023d9..56be31149 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/kem.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/kem.c
@@ -14,6 +14,8 @@
* @brief Implementation of api.h
*/
+
+
/**
* @brief Keygen of the HQC_KEM IND_CAA2 scheme
*
@@ -32,6 +34,8 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk) {
return 0;
}
+
+
/**
* @brief Encapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -71,9 +75,12 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
// Computing ciphertext
PQCLEAN_HQC192_CLEAN_hqc_ciphertext_to_string(ct, u, v, salt);
+
return 0;
}
+
+
/**
* @brief Decapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -126,5 +133,6 @@ int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
PQCLEAN_HQC192_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
PQCLEAN_HQC192_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
+
return (result & 1) - 1;
}
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/parameters.h b/src/kem/hqc/pqclean_hqc-192_clean/parameters.h
index f1efa66ef..136e3d99d 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/parameters.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/parameters.h
@@ -1,12 +1,14 @@
#ifndef HQC_PARAMETERS_H
#define HQC_PARAMETERS_H
+
/**
* @file parameters.h
* @brief Parameters of the HQC_KEM IND-CCA2 scheme
*/
#include "api.h"
+
#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/
/*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/parsing.c b/src/kem/hqc/pqclean_hqc-192_clean/parsing.c
index e0d56728a..f3ef0064b 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/parsing.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/parsing.c
@@ -8,6 +8,7 @@
* @brief Functions to parse secret key, public key and ciphertext of the HQC scheme
*/
+
static uint64_t load8(const uint8_t *in) {
uint64_t ret = in[7];
@@ -71,6 +72,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *s
memcpy(sk + SEED_BYTES + VEC_K_SIZE_BYTES, pk, PUBLIC_KEY_BYTES);
}
+
+
/**
* @brief Parse a secret key from a string
*
@@ -95,6 +98,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, u
PQCLEAN_HQC192_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Parse a public key into a string
*
@@ -109,6 +114,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *p
PQCLEAN_HQC192_CLEAN_store8_arr(pk + SEED_BYTES, VEC_N_SIZE_BYTES, s, VEC_N_SIZE_64);
}
+
+
/**
* @brief Parse a public key from a string
*
@@ -129,6 +136,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, c
PQCLEAN_HQC192_CLEAN_seedexpander_release(&pk_seedexpander);
}
+
+
/**
* @brief Parse a ciphertext into a string
*
@@ -145,6 +154,8 @@ void PQCLEAN_HQC192_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *
memcpy(ct + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, salt, SALT_SIZE_BYTES);
}
+
+
/**
* @brief Parse a ciphertext from a string
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/parsing.h b/src/kem/hqc/pqclean_hqc-192_clean/parsing.h
index 93169b8d9..f3e6c726f 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/parsing.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/parsing.h
@@ -1,6 +1,7 @@
#ifndef PARSING_H
#define PARSING_H
+
/**
* @file parsing.h
* @brief Header file for parsing.c
@@ -13,16 +14,20 @@ void PQCLEAN_HQC192_CLEAN_load8_arr(uint64_t *out64, size_t outlen, const uint8_
void PQCLEAN_HQC192_CLEAN_store8_arr(uint8_t *out8, size_t outlen, const uint64_t *in64, size_t inlen);
+
void PQCLEAN_HQC192_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *sk_seed, const uint8_t *sigma, const uint8_t *pk);
void PQCLEAN_HQC192_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, uint8_t *sigma, uint8_t *pk, const uint8_t *sk);
+
void PQCLEAN_HQC192_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *pk_seed, const uint64_t *s);
void PQCLEAN_HQC192_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, const uint8_t *pk);
+
void PQCLEAN_HQC192_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *u, const uint64_t *v, const uint8_t *salt);
void PQCLEAN_HQC192_CLEAN_hqc_ciphertext_from_string(uint64_t *u, uint64_t *v, uint8_t *salt, const uint8_t *ct);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.c b/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.c
index 29160c570..a23994a54 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.c
@@ -7,6 +7,7 @@
* @brief Constant time implementation of Reed-Muller code RM(1,7)
*/
+
// number of repeated code words
#define MULTIPLICITY CEIL_DIVIDE(PARAM_N2, 128)
@@ -52,6 +53,8 @@ static void encode(uint64_t *cword, uint8_t message) {
cword[1] |= first_word;
}
+
+
/**
* @brief Hadamard transform
*
@@ -80,6 +83,8 @@ static void hadamard(uint16_t src[128], uint16_t dst[128]) {
}
}
+
+
/**
* @brief Add multiple codewords into expanded codeword
*
@@ -110,6 +115,8 @@ static void expand_and_sum(uint16_t dest[128], const uint64_t src[2 * MULTIPLICI
}
}
+
+
/**
* @brief Finding the location of the highest value
*
@@ -137,6 +144,8 @@ static uint8_t find_peaks(const uint16_t transform[128]) {
return (uint8_t) pos;
}
+
+
/**
* @brief Encodes the received word
*
@@ -157,6 +166,8 @@ void PQCLEAN_HQC192_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg)
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.h b/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.h
index 94c8b1e30..b7ea4ecaf 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/reed_muller.h
@@ -1,6 +1,7 @@
#ifndef REED_MULLER_H
#define REED_MULLER_H
+
/**
* @file reed_muller.h
* @brief Header file of reed_muller.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC192_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC192_CLEAN_reed_muller_decode(uint8_t *msg, const uint64_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.c b/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.c
index b172e380f..ce1275230 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.c
@@ -9,6 +9,7 @@
* @brief Constant time implementation of Reed-Solomon codes
*/
+
/**
* @brief Encodes a message message of PARAM_K bits to a Reed-Solomon codeword codeword of PARAM_N1 bytes
*
@@ -44,6 +45,8 @@ void PQCLEAN_HQC192_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg)
memcpy(cdw + PARAM_N1 - PARAM_K, msg, PARAM_K);
}
+
+
/**
* @brief Computes 2 * PARAM_DELTA syndromes
*
@@ -59,6 +62,8 @@ static void compute_syndromes(uint16_t *syndromes, uint8_t *cdw) {
}
}
+
+
/**
* @brief Computes the error locator polynomial (ELP) sigma
*
@@ -138,6 +143,8 @@ static uint16_t compute_elp(uint16_t *sigma, const uint16_t *syndromes) {
return deg_sigma;
}
+
+
/**
* @brief Computes the error polynomial error from the error locator polynomial sigma
*
@@ -154,6 +161,8 @@ static void compute_roots(uint8_t *error, uint16_t *sigma) {
PQCLEAN_HQC192_CLEAN_fft_retrieve_error_poly(error, w);
}
+
+
/**
* @brief Computes the polynomial z(x)
*
@@ -187,6 +196,8 @@ static void compute_z_poly(uint16_t *z, const uint16_t *sigma, uint16_t degree,
}
}
+
+
/**
* @brief Computes the error values
*
@@ -257,6 +268,8 @@ static void compute_error_values(uint16_t *error_values, const uint16_t *z, cons
}
}
+
+
/**
* @brief Correct the errors
*
@@ -270,6 +283,8 @@ static void correct_errors(uint8_t *cdw, const uint16_t *error_values) {
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.h b/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.h
index 896b24e1e..aae642121 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/reed_solomon.h
@@ -1,6 +1,7 @@
#ifndef REED_SOLOMON_H
#define REED_SOLOMON_H
+
/**
* @file reed_solomon.h
* @brief Header file of reed_solomon.c
@@ -14,4 +15,5 @@ void PQCLEAN_HQC192_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC192_CLEAN_reed_solomon_decode(uint8_t *msg, uint8_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.c b/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.c
index a8c43e388..f85d7c740 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.c
@@ -1,10 +1,13 @@
#include "shake_ds.h"
+
/**
* @file shake_ds.c
* @brief Implementation SHAKE-256 with incremental API and domain separation
*/
+
+
/**
* @brief SHAKE-256 with incremental API and domain separation
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.h b/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.h
index 8c33cc067..1adff58c4 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/shake_ds.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_DS_H
#define SHAKE_DS_H
+
/**
* @file shake_ds.h
* @brief Header file of shake_ds.c
@@ -11,4 +12,5 @@
void PQCLEAN_HQC192_CLEAN_shake256_512_ds(shake256incctx *state, uint8_t *output, const uint8_t *input, size_t inlen, uint8_t domain);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.c b/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.c
index 9fea9723a..13d7776bc 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.c
@@ -7,6 +7,7 @@
* @brief Implementation of SHAKE-256 based seed expander
*/
+
/**
* @brief Initialise a SHAKE-256 based seed expander
*
@@ -24,6 +25,8 @@ void PQCLEAN_HQC192_CLEAN_seedexpander_init(seedexpander_state *state, const uin
shake256_inc_finalize(state);
}
+
+
/**
* @brief A SHAKE-256 based seed expander
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.h b/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.h
index 96a6efe75..ac535e32a 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/shake_prng.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_PRNG_H
#define SHAKE_PRNG_H
+
/**
* @file shake_prng.h
* @brief Header file of shake_prng.c
@@ -17,4 +18,5 @@ void PQCLEAN_HQC192_CLEAN_seedexpander(seedexpander_state *state, uint8_t *outpu
void PQCLEAN_HQC192_CLEAN_seedexpander_release(seedexpander_state *state);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/vector.c b/src/kem/hqc/pqclean_hqc-192_clean/vector.c
index 3aa6b8fae..aa27d8ecb 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/vector.c
+++ b/src/kem/hqc/pqclean_hqc-192_clean/vector.c
@@ -9,6 +9,7 @@
* @brief Implementation of vectors sampling and some utilities for the HQC scheme
*/
+
static uint32_t m_val[114] = { 119800, 119803, 119807, 119810, 119813, 119817, 119820, 119823, 119827, 119830, 119833, 119837, 119840, 119843, 119847, 119850, 119853, 119857, 119860, 119864, 119867, 119870, 119874, 119877, 119880, 119884, 119887, 119890, 119894, 119897, 119900, 119904, 119907, 119910, 119914, 119917, 119920, 119924, 119927, 119930, 119934, 119937, 119941, 119944, 119947, 119951, 119954, 119957, 119961, 119964, 119967, 119971, 119974, 119977, 119981, 119984, 119987, 119991, 119994, 119997, 120001, 120004, 120008, 120011, 120014, 120018, 120021, 120024, 120028, 120031, 120034, 120038, 120041, 120044, 120048, 120051, 120054, 120058, 120061, 120065, 120068, 120071, 120075, 120078, 120081, 120085, 120088, 120091, 120095, 120098, 120101, 120105, 120108, 120112, 120115, 120118, 120122, 120125, 120128, 120132, 120135, 120138, 120142, 120145, 120149, 120152, 120155, 120159, 120162, 120165, 120169, 120172, 120175, 120179 };
/**
@@ -110,6 +111,8 @@ void PQCLEAN_HQC192_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
}
}
+
+
/**
* @brief Generates a random vector of dimension PARAM_N
*
@@ -128,6 +131,8 @@ void PQCLEAN_HQC192_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v)
v[VEC_N_SIZE_64 - 1] &= RED_MASK;
}
+
+
/**
* @brief Adds two vectors
*
@@ -142,6 +147,8 @@ void PQCLEAN_HQC192_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64
}
}
+
+
/**
* @brief Compares two vectors
*
@@ -160,6 +167,8 @@ uint8_t PQCLEAN_HQC192_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2,
return (r - 1) >> 8;
}
+
+
/**
* @brief Resize a vector so that it contains size_o bits
*
diff --git a/src/kem/hqc/pqclean_hqc-192_clean/vector.h b/src/kem/hqc/pqclean_hqc-192_clean/vector.h
index 6376c71c5..6a5107c39 100644
--- a/src/kem/hqc/pqclean_hqc-192_clean/vector.h
+++ b/src/kem/hqc/pqclean_hqc-192_clean/vector.h
@@ -1,6 +1,7 @@
#ifndef VECTOR_H
#define VECTOR_H
+
/**
* @file vector.h
* @brief Header file for vector.c
@@ -13,10 +14,12 @@ void PQCLEAN_HQC192_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
void PQCLEAN_HQC192_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v);
+
void PQCLEAN_HQC192_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64_t *v2, size_t size);
uint8_t PQCLEAN_HQC192_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2, size_t size);
void PQCLEAN_HQC192_CLEAN_vect_resize(uint64_t *o, uint32_t size_o, const uint64_t *v, uint32_t size_v);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/api.h b/src/kem/hqc/pqclean_hqc-256_clean/api.h
index e9288656f..ec63b50c2 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/api.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/api.h
@@ -23,4 +23,5 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/code.c b/src/kem/hqc/pqclean_hqc-256_clean/code.c
index 8437a4775..0bb4e697a 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/code.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/code.c
@@ -8,6 +8,8 @@
* @brief Implementation of concatenated code
*/
+
+
/**
*
* @brief Encoding the message m to a code word em using the concatenated code
@@ -26,6 +28,8 @@ void PQCLEAN_HQC256_CLEAN_code_encode(uint64_t *em, const uint8_t *m) {
}
+
+
/**
* @brief Decoding the code word em to a message m using the concatenated code
*
@@ -38,4 +42,5 @@ void PQCLEAN_HQC256_CLEAN_code_decode(uint8_t *m, const uint64_t *em) {
PQCLEAN_HQC256_CLEAN_reed_muller_decode(tmp, em);
PQCLEAN_HQC256_CLEAN_reed_solomon_decode(m, tmp);
+
}
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/code.h b/src/kem/hqc/pqclean_hqc-256_clean/code.h
index 7c496bfcc..6c3f238aa 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/code.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/code.h
@@ -1,6 +1,7 @@
#ifndef CODE_H
#define CODE_H
+
/**
* @file code.h
* @brief Header file of code.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC256_CLEAN_code_encode(uint64_t *em, const uint8_t *message);
void PQCLEAN_HQC256_CLEAN_code_decode(uint8_t *m, const uint64_t *em);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/domains.h b/src/kem/hqc/pqclean_hqc-256_clean/domains.h
index 86d0ef849..20c782cca 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/domains.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/domains.h
@@ -1,11 +1,13 @@
#ifndef DOMAINS_H
#define DOMAINS_H
+
/**
* @file domains.h
* @brief SHAKE-256 domains separation header grouping all domains to avoid collisions
*/
+
#define PRNG_DOMAIN 1
#define SEEDEXPANDER_DOMAIN 2
#define G_FCT_DOMAIN 3
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/fft.c b/src/kem/hqc/pqclean_hqc-256_clean/fft.c
index 9b38b8a1f..dae220952 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/fft.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/fft.c
@@ -14,6 +14,7 @@
* https://binary.cr.yp.to/mcbits-20130616.pdf
*/
+
static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_f);
/**
@@ -28,6 +29,8 @@ static void compute_fft_betas(uint16_t *betas) {
}
}
+
+
/**
* @brief Computes the subset sums of the given set
*
@@ -49,6 +52,8 @@ static void compute_subset_sums(uint16_t *subset_sums, const uint16_t *set, uint
}
}
+
+
/**
* @brief Computes the radix conversion of a polynomial f in GF(2^m)[x]
*
@@ -143,6 +148,8 @@ static void radix_big(uint16_t *f0, uint16_t *f1, const uint16_t *f, uint32_t m_
memcpy(f1 + n, Q1, 2 * n);
}
+
+
/**
* @brief Evaluates f at all subset sums of a given set
*
@@ -236,6 +243,8 @@ static void fft_rec(uint16_t *w, uint16_t *f, size_t f_coeffs, uint8_t m, uint32
}
}
+
+
/**
* @brief Evaluates f on all fields elements using an additive FFT algorithm
*
@@ -305,6 +314,8 @@ void PQCLEAN_HQC256_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs) {
}
}
+
+
/**
* @brief Retrieves the error polynomial error from the evaluations w of the ELP (Error Locator Polynomial) on all field elements.
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/fft.h b/src/kem/hqc/pqclean_hqc-256_clean/fft.h
index 6fb827d07..723203aba 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/fft.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/fft.h
@@ -1,6 +1,7 @@
#ifndef FFT_H
#define FFT_H
+
/**
* @file fft.h
* @brief Header file of fft.c
@@ -13,4 +14,5 @@ void PQCLEAN_HQC256_CLEAN_fft(uint16_t *w, const uint16_t *f, size_t f_coeffs);
void PQCLEAN_HQC256_CLEAN_fft_retrieve_error_poly(uint8_t *error, const uint16_t *w);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/gf.c b/src/kem/hqc/pqclean_hqc-256_clean/gf.c
index 1cbf15080..0c4eb6750 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/gf.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/gf.c
@@ -7,6 +7,7 @@
* @brief Galois field implementation
*/
+
/**
* @brief Computes the number of trailing zero bits.
*
@@ -23,6 +24,8 @@ static uint16_t trailing_zero_bits_count(uint16_t a) {
return tmp;
}
+
+
/**
* Reduces polynomial x modulo primitive polynomial GF_POLY.
* @returns x mod GF_POLY
@@ -57,6 +60,8 @@ static uint16_t gf_reduce(uint64_t x, size_t deg_x) {
return (uint16_t)x;
}
+
+
/**
* Carryless multiplication of two polynomials a and b.
*
@@ -105,6 +110,8 @@ static void gf_carryless_mul(uint8_t c[2], uint8_t a, uint8_t b) {
c[1] = (uint8_t)h;
}
+
+
/**
* Multiplies two elements of GF(2^GF_M).
* @returns the product a*b
@@ -118,6 +125,8 @@ uint16_t PQCLEAN_HQC256_CLEAN_gf_mul(uint16_t a, uint16_t b) {
return gf_reduce(tmp, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Squares an element of GF(2^PARAM_M).
* @returns a^2
@@ -134,6 +143,8 @@ uint16_t PQCLEAN_HQC256_CLEAN_gf_square(uint16_t a) {
return gf_reduce(s, 2 * (PARAM_M - 1));
}
+
+
/**
* @brief Computes the inverse of an element of GF(2^PARAM_M),
* using the addition chain 1 2 3 4 7 11 15 30 60 120 127 254
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/gf.h b/src/kem/hqc/pqclean_hqc-256_clean/gf.h
index bf9319dca..06c55a246 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/gf.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/gf.h
@@ -1,6 +1,7 @@
#ifndef GF_H
#define GF_H
+
/**
* @file gf.h
* @brief Header file of gf.c
@@ -8,6 +9,7 @@
#include
+
/**
* Powers of the root alpha of 1 + x^2 + x^3 + x^4 + x^8.
* The last two elements are needed by the PQCLEAN_HQC256_CLEAN_gf_mul function
@@ -15,16 +17,21 @@
*/
static const uint16_t gf_exp [258] = { 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1, 2, 4 };
+
+
/**
* Logarithm of elements of GF(2^8) to the base alpha (root of 1 + x^2 + x^3 + x^4 + x^8).
* The logarithm of 0 is set to 0 by convention.
*/
static const uint16_t gf_log [256] = { 0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166, 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136, 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64, 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61, 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24, 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46, 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97, 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162, 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246, 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90, 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215, 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175 };
+
+
uint16_t PQCLEAN_HQC256_CLEAN_gf_mul(uint16_t a, uint16_t b);
uint16_t PQCLEAN_HQC256_CLEAN_gf_square(uint16_t a);
uint16_t PQCLEAN_HQC256_CLEAN_gf_inverse(uint16_t a);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/gf2x.c b/src/kem/hqc/pqclean_hqc-256_clean/gf2x.c
index 695ffa8e4..713f276b6 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/gf2x.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/gf2x.c
@@ -7,6 +7,7 @@
* @brief Implementation of multiplication of two polynomials
*/
+
/**
* @brief Caryless multiplication of two words of 64 bits
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/gf2x.h b/src/kem/hqc/pqclean_hqc-256_clean/gf2x.h
index bd00b2a16..0088672fd 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/gf2x.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/gf2x.h
@@ -9,4 +9,5 @@
void PQCLEAN_HQC256_CLEAN_vect_mul(uint64_t *o, const uint64_t *v1, const uint64_t *v2);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/hqc.c b/src/kem/hqc/pqclean_hqc-256_clean/hqc.c
index cb3b2f128..dfa4787de 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/hqc.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/hqc.c
@@ -12,6 +12,8 @@
* @brief Implementation of hqc.h
*/
+
+
/**
* @brief Keygen of the HQC_PKE IND_CPA scheme
*
@@ -59,6 +61,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_pke_keygen(uint8_t *pk, uint8_t *sk) {
PQCLEAN_HQC256_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Encryption of the HQC_PKE IND_CPA scheme
*
@@ -108,6 +112,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
PQCLEAN_HQC256_CLEAN_seedexpander_release(&vec_seedexpander);
}
+
+
/**
* @brief Decryption of the HQC_PKE IND_CPA scheme
*
@@ -132,6 +138,7 @@ uint8_t PQCLEAN_HQC256_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const u
PQCLEAN_HQC256_CLEAN_vect_mul(tmp2, y, u);
PQCLEAN_HQC256_CLEAN_vect_add(tmp2, tmp1, tmp2, VEC_N_SIZE_64);
+
// Compute m by decoding v - u.y
PQCLEAN_HQC256_CLEAN_code_decode(m, tmp2);
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/hqc.h b/src/kem/hqc/pqclean_hqc-256_clean/hqc.h
index bd229d251..34dd4cfad 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/hqc.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/hqc.h
@@ -1,6 +1,7 @@
#ifndef HQC_H
#define HQC_H
+
/**
* @file hqc.h
* @brief Functions of the HQC_PKE IND_CPA scheme
@@ -14,4 +15,5 @@ void PQCLEAN_HQC256_CLEAN_hqc_pke_encrypt(uint64_t *u, uint64_t *v, uint8_t *m,
uint8_t PQCLEAN_HQC256_CLEAN_hqc_pke_decrypt(uint8_t *m, uint8_t *sigma, const uint64_t *u, const uint64_t *v, const unsigned char *sk);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/kem.c b/src/kem/hqc/pqclean_hqc-256_clean/kem.c
index d4c6a08fa..2929ba08e 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/kem.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/kem.c
@@ -14,6 +14,8 @@
* @brief Implementation of api.h
*/
+
+
/**
* @brief Keygen of the HQC_KEM IND_CAA2 scheme
*
@@ -32,6 +34,8 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk) {
return 0;
}
+
+
/**
* @brief Encapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -71,9 +75,12 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t
// Computing ciphertext
PQCLEAN_HQC256_CLEAN_hqc_ciphertext_to_string(ct, u, v, salt);
+
return 0;
}
+
+
/**
* @brief Decapsulation of the HQC_KEM IND_CAA2 scheme
*
@@ -126,5 +133,6 @@ int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const ui
PQCLEAN_HQC256_CLEAN_store8_arr(mc + VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES, VEC_N1N2_SIZE_BYTES, v, VEC_N1N2_SIZE_64);
PQCLEAN_HQC256_CLEAN_shake256_512_ds(&shake256state, ss, mc, VEC_K_SIZE_BYTES + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, K_FCT_DOMAIN);
+
return (result & 1) - 1;
}
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/parameters.h b/src/kem/hqc/pqclean_hqc-256_clean/parameters.h
index 6ab60adb9..725ff3758 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/parameters.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/parameters.h
@@ -1,12 +1,14 @@
#ifndef HQC_PARAMETERS_H
#define HQC_PARAMETERS_H
+
/**
* @file parameters.h
* @brief Parameters of the HQC_KEM IND-CCA2 scheme
*/
#include "api.h"
+
#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/
/*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/parsing.c b/src/kem/hqc/pqclean_hqc-256_clean/parsing.c
index 3ad6088ea..fb34da7ab 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/parsing.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/parsing.c
@@ -8,6 +8,7 @@
* @brief Functions to parse secret key, public key and ciphertext of the HQC scheme
*/
+
static uint64_t load8(const uint8_t *in) {
uint64_t ret = in[7];
@@ -71,6 +72,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *s
memcpy(sk + SEED_BYTES + VEC_K_SIZE_BYTES, pk, PUBLIC_KEY_BYTES);
}
+
+
/**
* @brief Parse a secret key from a string
*
@@ -95,6 +98,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, u
PQCLEAN_HQC256_CLEAN_seedexpander_release(&sk_seedexpander);
}
+
+
/**
* @brief Parse a public key into a string
*
@@ -109,6 +114,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *p
PQCLEAN_HQC256_CLEAN_store8_arr(pk + SEED_BYTES, VEC_N_SIZE_BYTES, s, VEC_N_SIZE_64);
}
+
+
/**
* @brief Parse a public key from a string
*
@@ -129,6 +136,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, c
PQCLEAN_HQC256_CLEAN_seedexpander_release(&pk_seedexpander);
}
+
+
/**
* @brief Parse a ciphertext into a string
*
@@ -145,6 +154,8 @@ void PQCLEAN_HQC256_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *
memcpy(ct + VEC_N_SIZE_BYTES + VEC_N1N2_SIZE_BYTES, salt, SALT_SIZE_BYTES);
}
+
+
/**
* @brief Parse a ciphertext from a string
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/parsing.h b/src/kem/hqc/pqclean_hqc-256_clean/parsing.h
index 965558873..b00abe4fa 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/parsing.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/parsing.h
@@ -1,6 +1,7 @@
#ifndef PARSING_H
#define PARSING_H
+
/**
* @file parsing.h
* @brief Header file for parsing.c
@@ -13,16 +14,20 @@ void PQCLEAN_HQC256_CLEAN_load8_arr(uint64_t *out64, size_t outlen, const uint8_
void PQCLEAN_HQC256_CLEAN_store8_arr(uint8_t *out8, size_t outlen, const uint64_t *in64, size_t inlen);
+
void PQCLEAN_HQC256_CLEAN_hqc_secret_key_to_string(uint8_t *sk, const uint8_t *sk_seed, const uint8_t *sigma, const uint8_t *pk);
void PQCLEAN_HQC256_CLEAN_hqc_secret_key_from_string(uint64_t *x, uint64_t *y, uint8_t *sigma, uint8_t *pk, const uint8_t *sk);
+
void PQCLEAN_HQC256_CLEAN_hqc_public_key_to_string(uint8_t *pk, const uint8_t *pk_seed, const uint64_t *s);
void PQCLEAN_HQC256_CLEAN_hqc_public_key_from_string(uint64_t *h, uint64_t *s, const uint8_t *pk);
+
void PQCLEAN_HQC256_CLEAN_hqc_ciphertext_to_string(uint8_t *ct, const uint64_t *u, const uint64_t *v, const uint8_t *salt);
void PQCLEAN_HQC256_CLEAN_hqc_ciphertext_from_string(uint64_t *u, uint64_t *v, uint8_t *salt, const uint8_t *ct);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.c b/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.c
index 29ab7d0b8..9e8101cd1 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.c
@@ -7,6 +7,7 @@
* @brief Constant time implementation of Reed-Muller code RM(1,7)
*/
+
// number of repeated code words
#define MULTIPLICITY CEIL_DIVIDE(PARAM_N2, 128)
@@ -52,6 +53,8 @@ static void encode(uint64_t *cword, uint8_t message) {
cword[1] |= first_word;
}
+
+
/**
* @brief Hadamard transform
*
@@ -80,6 +83,8 @@ static void hadamard(uint16_t src[128], uint16_t dst[128]) {
}
}
+
+
/**
* @brief Add multiple codewords into expanded codeword
*
@@ -110,6 +115,8 @@ static void expand_and_sum(uint16_t dest[128], const uint64_t src[2 * MULTIPLICI
}
}
+
+
/**
* @brief Finding the location of the highest value
*
@@ -137,6 +144,8 @@ static uint8_t find_peaks(const uint16_t transform[128]) {
return (uint8_t) pos;
}
+
+
/**
* @brief Encodes the received word
*
@@ -157,6 +166,8 @@ void PQCLEAN_HQC256_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg)
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.h b/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.h
index db665d2e1..00b83b066 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/reed_muller.h
@@ -1,6 +1,7 @@
#ifndef REED_MULLER_H
#define REED_MULLER_H
+
/**
* @file reed_muller.h
* @brief Header file of reed_muller.c
@@ -12,4 +13,5 @@ void PQCLEAN_HQC256_CLEAN_reed_muller_encode(uint64_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC256_CLEAN_reed_muller_decode(uint8_t *msg, const uint64_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.c b/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.c
index 654c202bc..7d742dee7 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.c
@@ -9,6 +9,7 @@
* @brief Constant time implementation of Reed-Solomon codes
*/
+
/**
* @brief Encodes a message message of PARAM_K bits to a Reed-Solomon codeword codeword of PARAM_N1 bytes
*
@@ -44,6 +45,8 @@ void PQCLEAN_HQC256_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg)
memcpy(cdw + PARAM_N1 - PARAM_K, msg, PARAM_K);
}
+
+
/**
* @brief Computes 2 * PARAM_DELTA syndromes
*
@@ -59,6 +62,8 @@ static void compute_syndromes(uint16_t *syndromes, uint8_t *cdw) {
}
}
+
+
/**
* @brief Computes the error locator polynomial (ELP) sigma
*
@@ -138,6 +143,8 @@ static uint16_t compute_elp(uint16_t *sigma, const uint16_t *syndromes) {
return deg_sigma;
}
+
+
/**
* @brief Computes the error polynomial error from the error locator polynomial sigma
*
@@ -154,6 +161,8 @@ static void compute_roots(uint8_t *error, uint16_t *sigma) {
PQCLEAN_HQC256_CLEAN_fft_retrieve_error_poly(error, w);
}
+
+
/**
* @brief Computes the polynomial z(x)
*
@@ -187,6 +196,8 @@ static void compute_z_poly(uint16_t *z, const uint16_t *sigma, uint16_t degree,
}
}
+
+
/**
* @brief Computes the error values
*
@@ -257,6 +268,8 @@ static void compute_error_values(uint16_t *error_values, const uint16_t *z, cons
}
}
+
+
/**
* @brief Correct the errors
*
@@ -270,6 +283,8 @@ static void correct_errors(uint8_t *cdw, const uint16_t *error_values) {
}
}
+
+
/**
* @brief Decodes the received word
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.h b/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.h
index 2618e9025..522a98c52 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/reed_solomon.h
@@ -1,6 +1,7 @@
#ifndef REED_SOLOMON_H
#define REED_SOLOMON_H
+
/**
* @file reed_solomon.h
* @brief Header file of reed_solomon.c
@@ -14,4 +15,5 @@ void PQCLEAN_HQC256_CLEAN_reed_solomon_encode(uint8_t *cdw, const uint8_t *msg);
void PQCLEAN_HQC256_CLEAN_reed_solomon_decode(uint8_t *msg, uint8_t *cdw);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.c b/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.c
index 233244a7c..3b80cc74e 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.c
@@ -1,10 +1,13 @@
#include "shake_ds.h"
+
/**
* @file shake_ds.c
* @brief Implementation SHAKE-256 with incremental API and domain separation
*/
+
+
/**
* @brief SHAKE-256 with incremental API and domain separation
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.h b/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.h
index b9e2c5a1d..eac52bfe2 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/shake_ds.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_DS_H
#define SHAKE_DS_H
+
/**
* @file shake_ds.h
* @brief Header file of shake_ds.c
@@ -11,4 +12,5 @@
void PQCLEAN_HQC256_CLEAN_shake256_512_ds(shake256incctx *state, uint8_t *output, const uint8_t *input, size_t inlen, uint8_t domain);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.c b/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.c
index 225ea0117..10ee0900a 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.c
@@ -7,6 +7,7 @@
* @brief Implementation of SHAKE-256 based seed expander
*/
+
/**
* @brief Initialise a SHAKE-256 based seed expander
*
@@ -24,6 +25,8 @@ void PQCLEAN_HQC256_CLEAN_seedexpander_init(seedexpander_state *state, const uin
shake256_inc_finalize(state);
}
+
+
/**
* @brief A SHAKE-256 based seed expander
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.h b/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.h
index 918080a79..f07fed6fb 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/shake_prng.h
@@ -1,6 +1,7 @@
#ifndef SHAKE_PRNG_H
#define SHAKE_PRNG_H
+
/**
* @file shake_prng.h
* @brief Header file of shake_prng.c
@@ -17,4 +18,5 @@ void PQCLEAN_HQC256_CLEAN_seedexpander(seedexpander_state *state, uint8_t *outpu
void PQCLEAN_HQC256_CLEAN_seedexpander_release(seedexpander_state *state);
+
#endif
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/vector.c b/src/kem/hqc/pqclean_hqc-256_clean/vector.c
index 119e1c83b..08a78ffec 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/vector.c
+++ b/src/kem/hqc/pqclean_hqc-256_clean/vector.c
@@ -9,6 +9,7 @@
* @brief Implementation of vectors sampling and some utilities for the HQC scheme
*/
+
static uint32_t m_val[149] = { 74517, 74518, 74520, 74521, 74522, 74524, 74525, 74526, 74527, 74529, 74530, 74531, 74533, 74534, 74535, 74536, 74538, 74539, 74540, 74542, 74543, 74544, 74545, 74547, 74548, 74549, 74551, 74552, 74553, 74555, 74556, 74557, 74558, 74560, 74561, 74562, 74564, 74565, 74566, 74567, 74569, 74570, 74571, 74573, 74574, 74575, 74577, 74578, 74579, 74580, 74582, 74583, 74584, 74586, 74587, 74588, 74590, 74591, 74592, 74593, 74595, 74596, 74597, 74599, 74600, 74601, 74602, 74604, 74605, 74606, 74608, 74609, 74610, 74612, 74613, 74614, 74615, 74617, 74618, 74619, 74621, 74622, 74623, 74625, 74626, 74627, 74628, 74630, 74631, 74632, 74634, 74635, 74636, 74637, 74639, 74640, 74641, 74643, 74644, 74645, 74647, 74648, 74649, 74650, 74652, 74653, 74654, 74656, 74657, 74658, 74660, 74661, 74662, 74663, 74665, 74666, 74667, 74669, 74670, 74671, 74673, 74674, 74675, 74676, 74678, 74679, 74680, 74682, 74683, 74684, 74685, 74687, 74688, 74689, 74691, 74692, 74693, 74695, 74696, 74697, 74698, 74700, 74701, 74702, 74704, 74705, 74706, 74708, 74709 };
/**
@@ -110,6 +111,8 @@ void PQCLEAN_HQC256_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
}
}
+
+
/**
* @brief Generates a random vector of dimension PARAM_N
*
@@ -128,6 +131,8 @@ void PQCLEAN_HQC256_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v)
v[VEC_N_SIZE_64 - 1] &= RED_MASK;
}
+
+
/**
* @brief Adds two vectors
*
@@ -142,6 +147,8 @@ void PQCLEAN_HQC256_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64
}
}
+
+
/**
* @brief Compares two vectors
*
@@ -160,6 +167,8 @@ uint8_t PQCLEAN_HQC256_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2,
return (r - 1) >> 8;
}
+
+
/**
* @brief Resize a vector so that it contains size_o bits
*
diff --git a/src/kem/hqc/pqclean_hqc-256_clean/vector.h b/src/kem/hqc/pqclean_hqc-256_clean/vector.h
index 5e3b6aa3d..9067320d0 100644
--- a/src/kem/hqc/pqclean_hqc-256_clean/vector.h
+++ b/src/kem/hqc/pqclean_hqc-256_clean/vector.h
@@ -1,6 +1,7 @@
#ifndef VECTOR_H
#define VECTOR_H
+
/**
* @file vector.h
* @brief Header file for vector.c
@@ -13,10 +14,12 @@ void PQCLEAN_HQC256_CLEAN_vect_set_random_fixed_weight(seedexpander_state *ctx,
void PQCLEAN_HQC256_CLEAN_vect_set_random(seedexpander_state *ctx, uint64_t *v);
+
void PQCLEAN_HQC256_CLEAN_vect_add(uint64_t *o, const uint64_t *v1, const uint64_t *v2, size_t size);
uint8_t PQCLEAN_HQC256_CLEAN_vect_compare(const uint8_t *v1, const uint8_t *v2, size_t size);
void PQCLEAN_HQC256_CLEAN_vect_resize(uint64_t *o, uint32_t size_o, const uint64_t *v, uint32_t size_v);
+
#endif