mirror of git://anongit.mindrot.org/openssh.git
upstream: remove whitespace at EOL from code extracted from SUPERCOP
OpenBSD-Commit-ID: 1ec524ff2fbb9387d731601437c82008f35a60f4
This commit is contained in:
parent
d888de06c5
commit
36b00d3183
44
sntrup761.c
44
sntrup761.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sntrup761.c,v 1.5 2021/01/08 02:33:13 dtucker Exp $ */
|
||||
/* $OpenBSD: sntrup761.c,v 1.6 2023/01/11 02:13:52 djm Exp $ */
|
||||
|
||||
/*
|
||||
* Public Domain, Authors:
|
||||
|
@ -119,7 +119,7 @@ This software is designed to take time independent of x.
|
|||
Time still varies depending on m; user must ensure that m is constant.
|
||||
Time also varies on CPUs where multiplication is variable-time.
|
||||
There could be more CPU issues.
|
||||
There could also be compiler issues.
|
||||
There could also be compiler issues.
|
||||
*/
|
||||
|
||||
static void uint32_divmod_uint14(uint32 *q,uint16 *r,uint32 x,uint16 m)
|
||||
|
@ -447,7 +447,7 @@ static Fq Fq_freeze(int32 x)
|
|||
#ifndef LPR
|
||||
|
||||
static Fq Fq_recip(Fq a1)
|
||||
{
|
||||
{
|
||||
int i = 1;
|
||||
Fq ai = a1;
|
||||
|
||||
|
@ -456,7 +456,7 @@ static Fq Fq_recip(Fq a1)
|
|||
i += 1;
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -525,11 +525,11 @@ static void R3_mult(small *h,const small *f,const small *g)
|
|||
|
||||
/* returns 0 if recip succeeded; else -1 */
|
||||
static int R3_recip(small *out,const small *in)
|
||||
{
|
||||
{
|
||||
small f[p+1],g[p+1],v[p+1],r[p+1];
|
||||
int i,loop,delta;
|
||||
int sign,swap,t;
|
||||
|
||||
|
||||
for (i = 0;i < p+1;++i) v[i] = 0;
|
||||
for (i = 0;i < p+1;++i) r[i] = 0;
|
||||
r[0] = 1;
|
||||
|
@ -537,35 +537,35 @@ static int R3_recip(small *out,const small *in)
|
|||
f[0] = 1; f[p-1] = f[p] = -1;
|
||||
for (i = 0;i < p;++i) g[p-1-i] = in[i];
|
||||
g[p] = 0;
|
||||
|
||||
delta = 1;
|
||||
|
||||
delta = 1;
|
||||
|
||||
for (loop = 0;loop < 2*p-1;++loop) {
|
||||
for (i = p;i > 0;--i) v[i] = v[i-1];
|
||||
v[0] = 0;
|
||||
|
||||
|
||||
sign = -g[0]*f[0];
|
||||
swap = int16_negative_mask(-delta) & int16_nonzero_mask(g[0]);
|
||||
delta ^= swap&(delta^-delta);
|
||||
delta += 1;
|
||||
|
||||
|
||||
for (i = 0;i < p+1;++i) {
|
||||
t = swap&(f[i]^g[i]); f[i] ^= t; g[i] ^= t;
|
||||
t = swap&(v[i]^r[i]); v[i] ^= t; r[i] ^= t;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0;i < p+1;++i) g[i] = F3_freeze(g[i]+sign*f[i]);
|
||||
for (i = 0;i < p+1;++i) r[i] = F3_freeze(r[i]+sign*v[i]);
|
||||
|
||||
for (i = 0;i < p;++i) g[i] = g[i+1];
|
||||
g[p] = 0;
|
||||
}
|
||||
|
||||
|
||||
sign = f[0];
|
||||
for (i = 0;i < p;++i) out[i] = sign*v[p-1-i];
|
||||
|
||||
|
||||
return int16_nonzero_mask(delta);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -603,14 +603,14 @@ static void Rq_mult_small(Fq *h,const Fq *f,const small *g)
|
|||
static void Rq_mult3(Fq *h,const Fq *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0;i < p;++i) h[i] = Fq_freeze(3*f[i]);
|
||||
}
|
||||
|
||||
/* out = 1/(3*in) in Rq */
|
||||
/* returns 0 if recip succeeded; else -1 */
|
||||
static int Rq_recip3(Fq *out,const small *in)
|
||||
{
|
||||
{
|
||||
Fq f[p+1],g[p+1],v[p+1],r[p+1];
|
||||
int i,loop,delta;
|
||||
int swap,t;
|
||||
|
@ -739,7 +739,7 @@ static void KeyGen(Fq *h,small *f,small *ginv)
|
|||
{
|
||||
small g[p];
|
||||
Fq finv[p];
|
||||
|
||||
|
||||
for (;;) {
|
||||
Small_random(g);
|
||||
if (R3_recip(ginv,g) == 0) break;
|
||||
|
@ -777,7 +777,7 @@ static void Decrypt(small *r,const Fq *c,const small *f,const small *ginv)
|
|||
for (i = 0;i < w;++i) r[i] = ((ev[i]^1)&~mask)^1;
|
||||
for (i = w;i < p;++i) r[i] = ev[i]&~mask;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* ----- NTRU LPRime Core */
|
||||
|
@ -817,7 +817,7 @@ static void Decrypt(int8 *r,const Fq *B,const int8 *T,const small *a)
|
|||
for (i = 0;i < I;++i)
|
||||
r[i] = -int16_negative_mask(Fq_freeze(Right(T[i])-aB[i]+4*w+1));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* ----- encoding I-bit inputs */
|
||||
|
@ -898,7 +898,7 @@ static void HashShort(small *out,const Inputs r)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* ----- NTRU LPRime Expand */
|
||||
|
||||
#ifdef LPR
|
||||
|
@ -974,7 +974,7 @@ static void Rq_encode(unsigned char *s,const Fq *r)
|
|||
{
|
||||
uint16 R[p],M[p];
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0;i < p;++i) R[i] = r[i]+q12;
|
||||
for (i = 0;i < p;++i) M[i] = q;
|
||||
Encode(s,R,M,p);
|
||||
|
@ -989,7 +989,7 @@ static void Rq_decode(Fq *r,const unsigned char *s)
|
|||
Decode(R,s,M,p);
|
||||
for (i = 0;i < p;++i) r[i] = ((Fq)R[i])-q12;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* ----- encoding rounded polynomials */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
# $OpenBSD: sntrup761.sh,v 1.6 2022/12/26 19:16:03 jmc Exp $
|
||||
# $OpenBSD: sntrup761.sh,v 1.7 2023/01/11 02:13:52 djm Exp $
|
||||
# Placed in the Public Domain.
|
||||
#
|
||||
AUTHOR="supercop-20201130/crypto_kem/sntrup761/ref/implementors"
|
||||
|
@ -54,6 +54,7 @@ for i in $FILES; do
|
|||
-e "/^extern /d" \
|
||||
-e '/CRYPTO_NAMESPACE/d' \
|
||||
-e "/^#define int32 crypto_int32/d" \
|
||||
-e 's/[ ]*$//' \
|
||||
$i | \
|
||||
case "$i" in
|
||||
# Use int64_t for intermediate values in int32_MINMAX to prevent signed
|
||||
|
|
Loading…
Reference in New Issue