summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2023-01-11 02:13:53 +0000
committerDamien Miller <djm@cvs.openbsd.org>2023-01-11 02:13:53 +0000
commit50d8c1577ccce52cb59f050dd4d4fa2b19a59180 (patch)
treef5a7ac9a7bd6e26b3e861afce4d91058c23b2262 /usr.bin
parent19d9b9820637a3d2e5b710841dbf3ab7eeefe8f8 (diff)
remove whitespace at EOL from code extracted from SUPERCOP
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sntrup761.c44
-rw-r--r--usr.bin/ssh/sntrup761.sh3
2 files changed, 24 insertions, 23 deletions
diff --git a/usr.bin/ssh/sntrup761.c b/usr.bin/ssh/sntrup761.c
index a2b88afff24..3ec225a0af4 100644
--- a/usr.bin/ssh/sntrup761.c
+++ b/usr.bin/ssh/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:
@@ -115,7 +115,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)
@@ -443,7 +443,7 @@ static Fq Fq_freeze(int32 x)
#ifndef LPR
static Fq Fq_recip(Fq a1)
-{
+{
int i = 1;
Fq ai = a1;
@@ -452,7 +452,7 @@ static Fq Fq_recip(Fq a1)
i += 1;
}
return ai;
-}
+}
#endif
@@ -521,11 +521,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;
@@ -533,35 +533,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
@@ -599,14 +599,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;
@@ -735,7 +735,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;
@@ -773,7 +773,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 */
@@ -813,7 +813,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 */
@@ -894,7 +894,7 @@ static void HashShort(small *out,const Inputs r)
}
#endif
-
+
/* ----- NTRU LPRime Expand */
#ifdef LPR
@@ -970,7 +970,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);
@@ -985,7 +985,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 */
diff --git a/usr.bin/ssh/sntrup761.sh b/usr.bin/ssh/sntrup761.sh
index f0a48435730..db4e9aed08a 100644
--- a/usr.bin/ssh/sntrup761.sh
+++ b/usr.bin/ssh/sntrup761.sh
@@ -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