From: Matt Caswell Date: Tue, 5 Dec 2017 17:09:39 +0000 (+0000) Subject: Merge f_field.h into field.h X-Git-Tag: OpenSSL_1_1_1-pre2~91 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=001a0934191319f4617c02eb2b2857dd80e7464a;p=oweals%2Fopenssl.git Merge f_field.h into field.h Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/5105) --- diff --git a/crypto/ec/curve448/arch_32/f_impl.c b/crypto/ec/curve448/arch_32/f_impl.c index 8189e1e53e..ef01e49a66 100644 --- a/crypto/ec/curve448/arch_32/f_impl.c +++ b/crypto/ec/curve448/arch_32/f_impl.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" #if (defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) && !I_HATE_UNROLLED_LOOPS) \ || defined(C448_FORCE_UNROLL) diff --git a/crypto/ec/curve448/arch_arm_32/f_impl.c b/crypto/ec/curve448/arch_arm_32/f_impl.c index 5956d6ceba..b96c60602d 100644 --- a/crypto/ec/curve448/arch_arm_32/f_impl.c +++ b/crypto/ec/curve448/arch_arm_32/f_impl.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" static inline void __attribute__ ((gnu_inline, always_inline)) smlal(uint64_t *acc, const uint32_t a, const uint32_t b) diff --git a/crypto/ec/curve448/arch_neon/f_impl.c b/crypto/ec/curve448/arch_neon/f_impl.c index 7f6fda24f9..27193288d0 100644 --- a/crypto/ec/curve448/arch_neon/f_impl.c +++ b/crypto/ec/curve448/arch_neon/f_impl.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" static __inline__ uint64x2_t __attribute__((gnu_inline,always_inline,unused)) xx_vaddup_u64(uint64x2_t x) diff --git a/crypto/ec/curve448/arch_ref64/f_impl.c b/crypto/ec/curve448/arch_ref64/f_impl.c index 8df448c8dc..cacc61bcf8 100644 --- a/crypto/ec/curve448/arch_ref64/f_impl.c +++ b/crypto/ec/curve448/arch_ref64/f_impl.c @@ -9,7 +9,7 @@ * * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" void gf_mul(gf_s * __restrict__ cs, const gf as, const gf bs) { diff --git a/crypto/ec/curve448/arch_x86_64/f_impl.c b/crypto/ec/curve448/arch_x86_64/f_impl.c index 86572f6da0..a1d8753807 100644 --- a/crypto/ec/curve448/arch_x86_64/f_impl.c +++ b/crypto/ec/curve448/arch_x86_64/f_impl.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "f_field.h" +#include "field.h" void gf_mul(gf_s * __restrict__ cs, const gf as, const gf bs) { diff --git a/crypto/ec/curve448/f_field.h b/crypto/ec/curve448/f_field.h deleted file mode 100644 index c2a151fdd7..0000000000 --- a/crypto/ec/curve448/f_field.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. - * Copyright 2015-2016 Cryptography Research, Inc. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - * - * Originally written by Mike Hamburg - */ - -#ifndef __P448_F_FIELD_H__ -# define __P448_F_FIELD_H__ 1 - -# include "constant_time.h" -# include -# include - -# include "word.h" - -# define NLIMBS (64/sizeof(word_t)) -# define X_SER_BYTES 56 -# define SER_BYTES 56 -typedef struct gf_s { - word_t limb[NLIMBS]; -} __attribute__ ((aligned(32))) gf_s, gf[1]; - -/* RFC 7748 support */ -# define X_PUBLIC_BYTES X_SER_BYTES -# define X_PRIVATE_BYTES X_PUBLIC_BYTES -# define X_PRIVATE_BITS 448 - -# define INLINE_UNUSED __inline__ __attribute__((unused,always_inline)) - -#ifdef __cplusplus -extern "C" { -#endif - -/* Defined below in f_impl.h */ -static INLINE_UNUSED void gf_copy(gf out, const gf a) -{ - *out = *a; -} - -static INLINE_UNUSED void gf_add_RAW(gf out, const gf a, const gf b); -static INLINE_UNUSED void gf_sub_RAW(gf out, const gf a, const gf b); -static INLINE_UNUSED void gf_bias(gf inout, int amount); -static INLINE_UNUSED void gf_weak_reduce(gf inout); - -void gf_strong_reduce(gf inout); -void gf_add(gf out, const gf a, const gf b); -void gf_sub(gf out, const gf a, const gf b); -void gf_mul(gf_s * __restrict__ out, const gf a, const gf b); -void gf_mulw_unsigned(gf_s * __restrict__ out, const gf a, uint32_t b); -void gf_sqr(gf_s * __restrict__ out, const gf a); -mask_t gf_isr(gf a, const gf x); /** a^2 x = 1, QNR, or 0 if x=0. Return true if successful */ -mask_t gf_eq(const gf x, const gf y); -mask_t gf_lobit(const gf x); -mask_t gf_hibit(const gf x); - -void gf_serialize(uint8_t *serial, const gf x, int with_highbit); -mask_t gf_deserialize(gf x, const uint8_t serial[SER_BYTES], int with_hibit, - uint8_t hi_nmask); - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -# include "f_impl.h" /* Bring in the inline implementations */ - -# ifndef LIMBPERM -# define LIMBPERM(i) (i) -# endif -# define LIMB_MASK(i) (((1)< +# include +# include "word.h" + +# define NLIMBS (64/sizeof(word_t)) +# define X_SER_BYTES 56 +# define SER_BYTES 56 +typedef struct gf_s { + word_t limb[NLIMBS]; +} __attribute__ ((aligned(32))) gf_s, gf[1]; + +/* RFC 7748 support */ +# define X_PUBLIC_BYTES X_SER_BYTES +# define X_PRIVATE_BYTES X_PUBLIC_BYTES +# define X_PRIVATE_BITS 448 + +# define INLINE_UNUSED __inline__ __attribute__((unused,always_inline)) + +static INLINE_UNUSED void gf_copy(gf out, const gf a) +{ + *out = *a; +} + +static INLINE_UNUSED void gf_add_RAW(gf out, const gf a, const gf b); +static INLINE_UNUSED void gf_sub_RAW(gf out, const gf a, const gf b); +static INLINE_UNUSED void gf_bias(gf inout, int amount); +static INLINE_UNUSED void gf_weak_reduce(gf inout); + +void gf_strong_reduce(gf inout); +void gf_add(gf out, const gf a, const gf b); +void gf_sub(gf out, const gf a, const gf b); +void gf_mul(gf_s * __restrict__ out, const gf a, const gf b); +void gf_mulw_unsigned(gf_s * __restrict__ out, const gf a, uint32_t b); +void gf_sqr(gf_s * __restrict__ out, const gf a); +mask_t gf_isr(gf a, const gf x); /** a^2 x = 1, QNR, or 0 if x=0. Return true if successful */ +mask_t gf_eq(const gf x, const gf y); +mask_t gf_lobit(const gf x); +mask_t gf_hibit(const gf x); + +void gf_serialize(uint8_t *serial, const gf x, int with_highbit); +mask_t gf_deserialize(gf x, const uint8_t serial[SER_BYTES], int with_hibit, + uint8_t hi_nmask); + +# include "f_impl.h" /* Bring in the inline implementations */ + +# ifndef LIMBPERM +# define LIMBPERM(i) (i) +# endif +# define LIMB_MASK(i) (((1)<