summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-06-18 17:35:40 +0200
committerMatt Caswell <matt@openssl.org>2021-06-25 08:49:45 +0100
commit3d178db73b1ac13011e950baae5225837c587df1 (patch)
tree448200c4eb072c508064fa3da5dfac76a89829c9 /crypto/ec
parent991519aeb99b41e2239b20a254535436cad39553 (diff)
ppccap.c: Split out algorithm-specific functions
Fixes #13336 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15828)
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/build.info2
-rw-r--r--crypto/ec/ecp_nistp521.c2
-rw-r--r--crypto/ec/ecp_ppc.c34
3 files changed, 36 insertions, 2 deletions
diff --git a/crypto/ec/build.info b/crypto/ec/build.info
index 216139e596..9ee9842fec 100644
--- a/crypto/ec/build.info
+++ b/crypto/ec/build.info
@@ -30,7 +30,7 @@ IF[{- !$disabled{asm} -}]
$ECASM_parisc20_64=
$ECASM_ppc32=
- $ECASM_ppc64=ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s
+ $ECASM_ppc64=ecp_nistz256.c ecp_ppc.c ecp_nistz256-ppc64.s x25519-ppc64.s
$ECDEF_ppc64=ECP_NISTZ256_ASM X25519_ASM
IF[{- !$disabled{'ec_nistp_64_gcc_128'} -}]
$ECASM_ppc64=$ECASM_ppc64 ecp_nistp521-ppc64.s
diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c
index 338618ebca..31a97d7937 100644
--- a/crypto/ec/ecp_nistp521.c
+++ b/crypto/ec/ecp_nistp521.c
@@ -688,7 +688,7 @@ void p521_felem_square(largefelem out, const felem in);
void p521_felem_mul(largefelem out, const felem in1, const felem in2);
# if defined(_ARCH_PPC64)
-# include "ppc_arch.h"
+# include "crypto/ppc_arch.h"
# endif
void felem_select(void)
diff --git a/crypto/ec/ecp_ppc.c b/crypto/ec/ecp_ppc.c
new file mode 100644
index 0000000000..b2b9f772b8
--- /dev/null
+++ b/crypto/ec/ecp_ppc.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (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
+ */
+
+#include "internal/cryptlib.h"
+#include "crypto/ppc_arch.h"
+#include "ec_local.h"
+
+void ecp_nistz256_mul_mont(unsigned long res[4], const unsigned long a[4],
+ const unsigned long b[4]);
+
+void ecp_nistz256_to_mont(unsigned long res[4], const unsigned long in[4]);
+void ecp_nistz256_to_mont(unsigned long res[4], const unsigned long in[4])
+{
+ static const unsigned long RR[] = { 0x0000000000000003U,
+ 0xfffffffbffffffffU,
+ 0xfffffffffffffffeU,
+ 0x00000004fffffffdU };
+
+ ecp_nistz256_mul_mont(res, in, RR);
+}
+
+void ecp_nistz256_from_mont(unsigned long res[4], const unsigned long in[4]);
+void ecp_nistz256_from_mont(unsigned long res[4], const unsigned long in[4])
+{
+ static const unsigned long one[] = { 1, 0, 0, 0 };
+
+ ecp_nistz256_mul_mont(res, in, one);
+}