Skip to content

Commit

Permalink
Run copy_from_upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Wilson <[email protected]>
  • Loading branch information
SWilson4 committed Dec 10, 2024
1 parent 7cc7725 commit cbb4f97
Show file tree
Hide file tree
Showing 89 changed files with 402 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/algorithms/kem/classic_mceliece.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- **Authors' website**: https://classic.mceliece.org
- **Specification version**: SUPERCOP-20221025.
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
- **Source**: https://github.com/PQClean/PQClean/commit/99630892b15a1d7af18e057a933b31a8d0ece242
- **Implementation license (SPDX-Identifier)**: Public domain
- **Ancestors of primary source**:
- SUPERCOP-20221025 "clean" and "avx2" implementations
Expand Down
2 changes: 1 addition & 1 deletion docs/algorithms/kem/classic_mceliece.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/99630892b15a1d7af18e057a933b31a8d0ece242
2 changes: 1 addition & 1 deletion docs/algorithms/kem/hqc.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- **Authors' website**: https://pqc-hqc.org/
- **Specification version**: 2023-04-30.
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789 with copy_from_upstream patches
- **Source**: https://github.com/PQClean/PQClean/commit/99630892b15a1d7af18e057a933b31a8d0ece242
- **Implementation license (SPDX-Identifier)**: Public domain
- **Ancestors of primary source**:
- https://github.com/SWilson4/package-pqclean/tree/8db1b24b/hqc, which takes it from:
Expand Down
3 changes: 1 addition & 2 deletions docs/algorithms/kem/hqc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/99630892b15a1d7af18e057a933b31a8d0ece242
4 changes: 2 additions & 2 deletions docs/algorithms/sig/falcon.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
- **Authors' website**: https://falcon-sign.info
- **Specification version**: 20211101.
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
- **Source**: https://github.com/PQClean/PQClean/commit/99630892b15a1d7af18e057a933b31a8d0ece242
- **Implementation license (SPDX-Identifier)**: MIT
- **Optimized Implementation sources**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789
- **Optimized Implementation sources**: https://github.com/PQClean/PQClean/commit/99630892b15a1d7af18e057a933b31a8d0ece242
- **pqclean-aarch64**:<a name="pqclean-aarch64"></a>
- **Source**: https://github.com/PQClean/PQClean/commit/7707d1bcc8ae7f9ffd296dd13b1d76d2767d14f8
- **Implementation license (SPDX-Identifier)**: Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion docs/algorithms/sig/falcon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/99630892b15a1d7af18e057a933b31a8d0ece242
spdx-license-identifier: MIT
upstream-ancestors:
- https://www.falcon-sign.info
Expand Down
2 changes: 1 addition & 1 deletion docs/algorithms/sig/sphincs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- **Authors' website**: https://sphincs.org/
- **Specification version**: NIST Round 3 submission, v3.1 (June 10, 2022).
- **Primary Source**<a name="primary-source"></a>:
- **Source**: https://github.com/PQClean/PQClean/commit/8e221ae797b229858a0b0d784577a8cb149d5789 with copy_from_upstream patches
- **Source**: https://github.com/PQClean/PQClean/commit/99630892b15a1d7af18e057a933b31a8d0ece242 with copy_from_upstream patches
- **Implementation license (SPDX-Identifier)**: CC0-1.0


Expand Down
2 changes: 1 addition & 1 deletion docs/algorithms/sig/sphincs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/99630892b15a1d7af18e057a933b31a8d0ece242
with copy_from_upstream patches
spdx-license-identifier: CC0-1.0
upstream-ancestors:
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_128.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_192.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_256.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @brief Implementation of concatenated code
*/



/**
*
* @brief Encoding the message m to a code word em using the concatenated code
Expand All @@ -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
*
Expand All @@ -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);


}
2 changes: 2 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/code.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef CODE_H
#define CODE_H


/**
* @file code.h
* @brief Header file of code.c
Expand All @@ -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
2 changes: 2 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/domains.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand All @@ -28,6 +29,8 @@ static void compute_fft_betas(uint16_t *betas) {
}
}



/**
* @brief Computes the subset sums of the given set
*
Expand All @@ -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]
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/fft.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef FFT_H
#define FFT_H


/**
* @file fft.h
* @brief Header file of fft.c
Expand All @@ -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
11 changes: 11 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @brief Galois field implementation
*/


/**
* @brief Computes the number of trailing zero bits.
*
Expand All @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/gf.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
#ifndef GF_H
#define GF_H


/**
* @file gf.h
* @brief Header file of gf.c
*/

#include <stdint.h>


/**
* 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
* (for example if both elements to multiply are zero).
*/
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
1 change: 1 addition & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/gf2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @brief Implementation of multiplication of two polynomials
*/


/**
* @brief Caryless multiplication of two words of 64 bits
*
Expand Down
1 change: 1 addition & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/gf2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

void PQCLEAN_HQC128_CLEAN_vect_mul(uint64_t *o, const uint64_t *v1, const uint64_t *v2);


#endif
7 changes: 7 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/hqc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @brief Implementation of hqc.h
*/



/**
* @brief Keygen of the HQC_PKE IND_CPA scheme
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand All @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/kem/hqc/pqclean_hqc-128_clean/hqc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef HQC_H
#define HQC_H


/**
* @file hqc.h
* @brief Functions of the HQC_PKE IND_CPA scheme
Expand All @@ -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
Loading

0 comments on commit cbb4f97

Please sign in to comment.