diff options
author | Matt Caswell <matt@openssl.org> | 2017-12-05 18:09:39 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-02-20 13:59:30 +0100 |
commit | 001a0934191319f4617c02eb2b2857dd80e7464a (patch) | |
tree | 72906014c1d01e2bb9a5044958fbbff185c97bf5 /crypto/ec/curve448/field.h | |
parent | Merge f_arithmetic.c into f_generic.c (diff) | |
download | openssl-001a0934191319f4617c02eb2b2857dd80e7464a.tar.xz openssl-001a0934191319f4617c02eb2b2857dd80e7464a.zip |
Merge f_field.h into field.h
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5105)
Diffstat (limited to '')
-rw-r--r-- | crypto/ec/curve448/field.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/crypto/ec/curve448/field.h b/crypto/ec/curve448/field.h index b895847f76..e66447e485 100644 --- a/crypto/ec/curve448/field.h +++ b/crypto/ec/curve448/field.h @@ -14,8 +14,57 @@ # define __GF_H__ # include "constant_time.h" -# include "f_field.h" # include <string.h> +# include <assert.h> +# 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)<<LIMB_PLACE_VALUE(i))-1) + +static const gf ZERO = {{{0}}}, ONE = {{{1}}}; /* Square x, n times. */ static ossl_inline void gf_sqrn(gf_s * __restrict__ y, const gf x, int n) |