Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed...
details: https://anonhg.NetBSD.org/src/rev/4d4edc7277cd
branches: trunk
changeset: 937496:4d4edc7277cd
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Aug 20 21:20:47 2020 +0000
description:
Split ge25519_scalarmult up in order to reduce stack usage.
diffstat:
sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c | 32 +++++++--
1 files changed, 23 insertions(+), 9 deletions(-)
diffs (59 lines):
diff -r 68c756007fd8 -r 4d4edc7277cd sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
--- a/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Thu Aug 20 21:20:37 2020 +0000
+++ b/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Thu Aug 20 21:20:47 2020 +0000
@@ -748,18 +748,11 @@
p is public
*/
-void
-ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a, const ge25519_p3 *p)
+static void __noinline
+ge25519_scalarmult_cache(ge25519_cached pi[static 8], const ge25519_p3 *p)
{
- signed char e[64];
- signed char carry;
- ge25519_p1p1 r;
- ge25519_p2 s;
ge25519_p1p1 t1;
ge25519_p3 p2, p3, p4, pt;
- ge25519_cached pi[8];
- ge25519_cached t;
- int i;
ge25519_p3_to_cached(&pi[1 - 1], p); /* p */
@@ -790,6 +783,18 @@
ge25519_p3_dbl(&t1, &p4);
ge25519_p1p1_to_p3(&pt, &t1);
ge25519_p3_to_cached(&pi[8 - 1], &pt); /* 8p = 2*4p */
+}
+
+static void __noinline
+ge25519_scalarmult_cached(ge25519_p3 *h, const unsigned char *a,
+ const ge25519_p3 *p, const ge25519_cached pi[static 8])
+{
+ signed char e[64];
+ signed char carry;
+ ge25519_p1p1 r;
+ ge25519_p2 s;
+ ge25519_cached t;
+ int i;
for (i = 0; i < 32; ++i) {
e[2 * i + 0] = (a[i] >> 0) & 15;
@@ -831,6 +836,15 @@
ge25519_p1p1_to_p3(h, &r);
}
+void
+ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a, const ge25519_p3 *p)
+{
+ ge25519_cached pi[8];
+
+ ge25519_scalarmult_cache(pi, p);
+ ge25519_scalarmult_cached(h, a, p, pi);
+}
+
/*
h = a * B (with precomputation)
where a = a[0]+256*a[1]+...+256^31 a[31]
Home |
Main Index |
Thread Index |
Old Index