X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fec%2Fcurve448%2Farch_32%2Ff_impl.h;h=217f9947e9b5f797f341a469e6e266b75b7b807e;hp=c3687888c02d4e0524255c76f4e3d7839f8b239e;hb=9fd3c858b4ceea7ff0b176c7c0a2438475898598;hpb=abcd22bf621b25e5db724b0ad9bcb4bcc189b1d3 diff --git a/crypto/ec/curve448/arch_32/f_impl.h b/crypto/ec/curve448/arch_32/f_impl.h index c3687888c0..217f9947e9 100644 --- a/crypto/ec/curve448/arch_32/f_impl.h +++ b/crypto/ec/curve448/arch_32/f_impl.h @@ -1,40 +1,62 @@ -/* Copyright (c) 2014-2016 Cryptography Research, Inc. - * Released under the MIT License. See LICENSE.txt for license information. +/* + * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-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 */ -#define GF_HEADROOM 2 -#define LIMB(x) (x##ull)&((1ull<<28)-1), (x##ull)>>28 -#define FIELD_LITERAL(a,b,c,d,e,f,g,h) \ +#ifndef HEADER_ARCH_32_F_IMPL_H +# define HEADER_ARCH_32_F_IMPL_H + +# define GF_HEADROOM 2 +# define LIMB(x) (x)&((1<<28)-1), (x)>>28 +# define FIELD_LITERAL(a,b,c,d,e,f,g,h) \ {{LIMB(a),LIMB(b),LIMB(c),LIMB(d),LIMB(e),LIMB(f),LIMB(g),LIMB(h)}} - -#define LIMB_PLACE_VALUE(i) 28 -void gf_add_RAW (gf out, const gf a, const gf b) { - for (unsigned int i=0; ilimb[0]); i++) { +# define LIMB_PLACE_VALUE(i) 28 + +void gf_add_RAW(gf out, const gf a, const gf b) +{ + unsigned int i; + + for (i = 0; i < NLIMBS; i++) { out->limb[i] = a->limb[i] + b->limb[i]; } } -void gf_sub_RAW (gf out, const gf a, const gf b) { - for (unsigned int i=0; ilimb[0]); i++) { +void gf_sub_RAW(gf out, const gf a, const gf b) +{ + unsigned int i; + + for (i = 0; i < NLIMBS; i++) { out->limb[i] = a->limb[i] - b->limb[i]; } } -void gf_bias (gf a, int amt) { - uint32_t co1 = ((1ull<<28)-1)*amt, co2 = co1-amt; - for (unsigned int i=0; ilimb[0]); i++) { - a->limb[i] += (i==sizeof(*a)/sizeof(a->limb[0])/2) ? co2 : co1; - } +void gf_bias(gf a, int amt) +{ + unsigned int i; + uint32_t co1 = ((1 << 28) - 1) * amt, co2 = co1 - amt; + + for (i = 0; i < NLIMBS; i++) + a->limb[i] += (i == sizeof(*a) / sizeof(a->limb[0]) / 2) ? co2 : co1; } -void gf_weak_reduce (gf a) { - uint32_t mask = (1ull<<28) - 1; +void gf_weak_reduce(gf a) +{ + uint32_t mask = (1 << 28) - 1; uint32_t tmp = a->limb[15] >> 28; + unsigned int i; + a->limb[8] += tmp; - for (unsigned int i=15; i>0; i--) { - a->limb[i] = (a->limb[i] & mask) + (a->limb[i-1]>>28); - } + for (i = 15; i > 0; i--) + a->limb[i] = (a->limb[i] & mask) + (a->limb[i - 1] >> 28); a->limb[0] = (a->limb[0] & mask) + tmp; } +#endif /* HEADER_ARCH_32_F_IMPL_H */