summaryrefslogtreecommitdiff
path: root/crypto/ppccap.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2021-04-14 14:31:58 +1000
committerPauli <pauli@openssl.org>2021-05-08 20:39:29 +1000
commit0d40ca47bd86e74a95c3a2f5fb6c67cdbee93c79 (patch)
treed5939a2a1b410da4a696461e7724da37bfa9697e /crypto/ppccap.c
parent531df8185ff4a083aca550b2c8a56d7993b2c60d (diff)
downloadopenssl-new-0d40ca47bd86e74a95c3a2f5fb6c67cdbee93c79.tar.gz
bn: Add fixed length (n=6), unrolled PPC Montgomery Multiplication
Overall improvement for p384 of ~18% on Power 9, compared to existing Power assembling code. See comment in code for more details. Multiple unrolled versions could be generated for values other than 6. However, for TLS 1.3 the only other ECC algorithms that might use Montgomery Multiplication are p256 and p521, but these have custom algorithms that don't use Montgomery Multiplication. Non-ECC algorithms are likely to use larger key lengths that won't fit into the n <= 10 length limitation of this code. Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> Signed-off-by: Alastair D'Silva <alastair@d-silva.org> Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15175)
Diffstat (limited to 'crypto/ppccap.c')
-rw-r--r--crypto/ppccap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/ppccap.c b/crypto/ppccap.c
index 9ed1d80db5..a504bc59b0 100644
--- a/crypto/ppccap.c
+++ b/crypto/ppccap.c
@@ -47,6 +47,12 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
const BN_ULONG *np, const BN_ULONG *n0, int num);
int bn_mul4x_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
const BN_ULONG *np, const BN_ULONG *n0, int num);
+ int bn_mul_mont_fixed_n6(BN_ULONG *rp, const BN_ULONG *ap,
+ const BN_ULONG *bp, const BN_ULONG *np,
+ const BN_ULONG *n0, int num);
+ int bn_mul_mont_300_fixed_n6(BN_ULONG *rp, const BN_ULONG *ap,
+ const BN_ULONG *bp, const BN_ULONG *np,
+ const BN_ULONG *n0, int num);
if (num < 4)
return 0;
@@ -62,6 +68,12 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
* no opportunity to figure it out...
*/
+ if (num == 6)
+ if (OPENSSL_ppccap_P & PPC_MADD300)
+ return bn_mul_mont_300_fixed_n6(rp, ap, bp, np, n0, num);
+ else
+ return bn_mul_mont_fixed_n6(rp, ap, bp, np, n0, num);
+
return bn_mul_mont_int(rp, ap, bp, np, n0, num);
}
#endif