Open p0syd0n opened 3 months ago
diff --git a/src/poly.h b/src/poly.h
index 8ca4be6..eac24ff 100644
--- a/src/poly.h
+++ b/src/poly.h
@@ -16,5 +16,5 @@
* @param modulus
*/
-uint8_t ntruprime_mult_poly(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t modulus);
+extern uint8_t ntruprime_mult_poly(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t modulus);
/**
@@ -28,5 +28,5 @@ uint8_t ntruprime_mult_poly(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint
* @return 1 for success, 0 for failure
*/
-uint8_t ntruprime_rand_tern(uint16_t N, NtruIntPoly *poly, NtruRandContext *rand_ctx);
+extern uint8_t ntruprime_rand_tern(uint16_t N, NtruIntPoly *poly, NtruRandContext *rand_ctx);
/**
@@ -41,8 +41,8 @@ uint8_t ntruprime_rand_tern(uint16_t N, NtruIntPoly *poly, NtruRandContext *rand
* @return 1 for success, 0 for failure
*/
-uint8_t ntruprime_rand_tern_t(uint16_t N, uint16_t t, NtruIntPoly *poly, NtruRandContext *rand_ctx);
+extern uint8_t ntruprime_rand_tern_t(uint16_t N, uint16_t t, NtruIntPoly *poly, NtruRandContext *rand_ctx);
/* Multiplies a polynomial by an integer, modulo another integer */
-void ntruprime_mult_mod(NtruIntPoly *a, uint16_t factor, uint16_t modulus);
+extern void ntruprime_mult_mod(NtruIntPoly *a, uint16_t factor, uint16_t modulus);
/**
@@ -55,5 +55,5 @@ void ntruprime_mult_mod(NtruIntPoly *a, uint16_t factor, uint16_t modulus);
* @return the inverse of a
*/
-uint16_t ntruprime_inv_int(uint16_t a, uint16_t modulus);
+extern uint16_t ntruprime_inv_int(uint16_t a, uint16_t modulus);
/**
@@ -68,5 +68,5 @@ uint16_t ntruprime_inv_int(uint16_t a, uint16_t modulus);
* @return 1 if a is invertible, 0 otherwise
*/
-uint8_t ntruprime_inv_poly(NtruIntPoly *a, NtruIntPoly *b, uint16_t modulus);
+extern uint8_t ntruprime_inv_poly(NtruIntPoly *a, NtruIntPoly *b, uint16_t modulus);
/**
@@ -82,5 +82,5 @@ uint8_t ntruprime_inv_poly(NtruIntPoly *a, NtruIntPoly *b, uint16_t modulus);
* @return 1 for success, 0 for failure
*/
-uint8_t ntru_rand_tern(uint16_t N, uint16_t num_ones, uint16_t num_neg_ones, NtruTernPoly *poly, NtruRandContext *rand_ctx);
+extern uint8_t ntru_rand_tern(uint16_t N, uint16_t num_ones, uint16_t num_neg_ones, NtruTernPoly *poly, NtruRandContext *rand_ctx);
#ifndef NTRU_AVOID_HAMMING_WT_PATENT
@@ -99,5 +99,5 @@ uint8_t ntru_rand_tern(uint16_t N, uint16_t num_ones, uint16_t num_neg_ones, Ntr
* @return 1 for success, 0 for failure
*/
-uint8_t ntru_rand_prod(uint16_t N, uint16_t df1, uint16_t df2, uint16_t df3_ones, uint16_t df3_neg_ones, NtruProdPoly *poly, NtruRandContext *rand_ctx);
+extern uint8_t ntru_rand_prod(uint16_t N, uint16_t df1, uint16_t df2, uint16_t df3_ones, uint16_t df3_neg_ones, NtruProdPoly *poly, NtruRandContext *rand_ctx);
#endif /* NTRU_AVOID_HAMMING_WT_PATENT */
@@ -111,5 +111,5 @@ uint8_t ntru_rand_prod(uint16_t N, uint16_t df1, uint16_t df2, uint16_t df3_ones
* @param b a polynomial to add to the polynomial a
*/
-void ntru_add(NtruIntPoly *a, NtruIntPoly *b);
+extern void ntru_add(NtruIntPoly *a, NtruIntPoly *b);
/**
@@ -122,5 +122,5 @@ void ntru_add(NtruIntPoly *a, NtruIntPoly *b);
* @param b a polynomial to subtract from the polynomial a
*/
-void ntru_sub(NtruIntPoly *a, NtruIntPoly *b);
+extern void ntru_sub(NtruIntPoly *a, NtruIntPoly *b);
/**
@@ -136,5 +136,5 @@ void ntru_sub(NtruIntPoly *a, NtruIntPoly *b);
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t (*ntru_mult_tern)(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t (*ntru_mult_tern)(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -151,5 +151,5 @@ uint8_t (*ntru_mult_tern)(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint1
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_tern_32(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_tern_32(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -166,5 +166,5 @@ uint8_t ntru_mult_tern_32(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint1
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_tern_64(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_tern_64(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint16_t mod_mask);
#ifndef NTRU_AVOID_HAMMING_WT_PATENT
@@ -181,5 +181,5 @@ uint8_t ntru_mult_tern_64(NtruIntPoly *a, NtruTernPoly *b, NtruIntPoly *c, uint1
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_prod(NtruIntPoly *a, NtruProdPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_prod(NtruIntPoly *a, NtruProdPoly *b, NtruIntPoly *c, uint16_t mod_mask);
#endif /* NTRU_AVOID_HAMMING_WT_PATENT */
@@ -197,5 +197,5 @@ uint8_t ntru_mult_prod(NtruIntPoly *a, NtruProdPoly *b, NtruIntPoly *c, uint16_t
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_priv(NtruPrivPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_priv(NtruPrivPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -211,5 +211,5 @@ uint8_t ntru_mult_priv(NtruPrivPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t
* No extra room is needed at the end.
*/
-void ntru_to_arr_32(NtruIntPoly *p, uint16_t q, uint8_t *a);
+extern void ntru_to_arr_32(NtruIntPoly *p, uint16_t q, uint8_t *a);
/**
@@ -225,5 +225,5 @@ void ntru_to_arr_32(NtruIntPoly *p, uint16_t q, uint8_t *a);
* Must accommodate at least 7 more bytes than the result takes up.
*/
-void ntru_to_arr_64(NtruIntPoly *p, uint16_t q, uint8_t *a);
+extern void ntru_to_arr_64(NtruIntPoly *p, uint16_t q, uint8_t *a);
/**
@@ -237,5 +237,5 @@ void ntru_to_arr_64(NtruIntPoly *p, uint16_t q, uint8_t *a);
* @param a output parameter; a pointer to store the encoded polynomial
*/
-void (*ntru_to_arr)(NtruIntPoly *p, uint16_t q, uint8_t *a);
+extern void (*ntru_to_arr)(NtruIntPoly *p, uint16_t q, uint8_t *a);
/**
@@ -248,7 +248,7 @@ void (*ntru_to_arr)(NtruIntPoly *p, uint16_t q, uint8_t *a);
* @param arr output parameter; a pointer to store the encoded polynomial
*/
-void ntru_to_arr4(NtruIntPoly *p, uint8_t *arr);
+extern void ntru_to_arr4(NtruIntPoly *p, uint8_t *arr);
-void ntru_from_arr(uint8_t *arr, uint16_t N, uint16_t q, NtruIntPoly *p);
+extern void ntru_from_arr(uint8_t *arr, uint16_t N, uint16_t q, NtruIntPoly *p);
/**
@@ -260,5 +260,5 @@ void ntru_from_arr(uint8_t *arr, uint16_t N, uint16_t q, NtruIntPoly *p);
* @param factor the factor to multiply by
*/
-void ntru_mult_fac(NtruIntPoly *a, int16_t factor);
+extern void ntru_mult_fac(NtruIntPoly *a, int16_t factor);
/**
@@ -274,5 +274,5 @@ void ntru_mult_fac(NtruIntPoly *a, int16_t factor);
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t (*ntru_mult_int)(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t (*ntru_mult_int)(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -289,5 +289,5 @@ uint8_t (*ntru_mult_int)(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_int_16(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_int_16(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -304,5 +304,5 @@ uint8_t ntru_mult_int_16(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_
* @return 0 if the number of coefficients differ, 1 otherwise
*/
-uint8_t ntru_mult_int_64(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
+extern uint8_t ntru_mult_int_64(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t mod_mask);
/**
@@ -314,5 +314,5 @@ uint8_t ntru_mult_int_64(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_
* @param mod_mask an AND mask to apply to the coefficients of c
*/
-void (*ntru_mod_mask)(NtruIntPoly *p, uint16_t mod_mask);
+extern void (*ntru_mod_mask)(NtruIntPoly *p, uint16_t mod_mask);
/**
@@ -324,5 +324,5 @@ void (*ntru_mod_mask)(NtruIntPoly *p, uint16_t mod_mask);
* @param p input and output parameter; coefficients are overwritten
*/
-void ntru_mod3(NtruIntPoly *p);
+extern void ntru_mod3(NtruIntPoly *p);
/**
@@ -335,5 +335,5 @@ void ntru_mod3(NtruIntPoly *p);
* @param modulus the modulus to apply to the coefficients of p
*/
-void ntru_mod_center(NtruIntPoly *p, uint16_t modulus);
+extern void ntru_mod_center(NtruIntPoly *p, uint16_t modulus);
/**
@@ -346,5 +346,5 @@ void ntru_mod_center(NtruIntPoly *p, uint16_t modulus);
* @return 1 iff all coefficients are equal
*/
-uint8_t ntru_equals_int(NtruIntPoly *a, NtruIntPoly *b);
+extern uint8_t ntru_equals_int(NtruIntPoly *a, NtruIntPoly *b);
/**
@@ -356,5 +356,5 @@ uint8_t ntru_equals_int(NtruIntPoly *a, NtruIntPoly *b);
* @param p a polynomial
*/
-void ntru_clear_priv(NtruPrivPoly *p);
+extern void ntru_clear_priv(NtruPrivPoly *p);
/**
@@ -365,5 +365,5 @@ void ntru_clear_priv(NtruPrivPoly *p);
* @param p a polynomial
*/
-void ntru_clear_int(NtruIntPoly *p);
+extern void ntru_clear_int(NtruIntPoly *p);
/**
@@ -380,5 +380,5 @@ void ntru_clear_int(NtruIntPoly *p);
* @return 1 if a is invertible, 0 otherwise
*/
-uint8_t (*ntru_invert)(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
+extern uint8_t (*ntru_invert)(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
/**
@@ -396,5 +396,5 @@ uint8_t (*ntru_invert)(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
* @return 1 if a is invertible, 0 otherwise
*/
-uint8_t ntru_invert_32(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
+extern uint8_t ntru_invert_32(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
/**
@@ -412,5 +412,5 @@ uint8_t ntru_invert_32(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
* @return 1 if a is invertible, 0 otherwise
*/
-uint8_t ntru_invert_64(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
+extern uint8_t ntru_invert_64(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
/**
@@ -420,5 +420,5 @@ uint8_t ntru_invert_64(NtruPrivPoly *a, uint16_t mod_mask, NtruIntPoly *Fq);
* variant is used.
*/
-void ntru_set_optimized_impl_poly();
+extern void ntru_set_optimized_impl_poly();
#endif /* NTRU_POLY_H */
Just apply this patch, and it should compile successfully.
During make, errors fly all over the place: