2 * Copyright 2009-2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/crypto.h>
11 #include <openssl/bn.h>
12 #include "crypto/ppc_arch.h"
15 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
16 const BN_ULONG *np, const BN_ULONG *n0, int num)
18 int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
19 const BN_ULONG *np, const BN_ULONG *n0, int num);
20 int bn_mul4x_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
21 const BN_ULONG *np, const BN_ULONG *n0, int num);
22 int bn_mul_mont_fixed_n6(BN_ULONG *rp, const BN_ULONG *ap,
23 const BN_ULONG *bp, const BN_ULONG *np,
24 const BN_ULONG *n0, int num);
25 int bn_mul_mont_300_fixed_n6(BN_ULONG *rp, const BN_ULONG *ap,
26 const BN_ULONG *bp, const BN_ULONG *np,
27 const BN_ULONG *n0, int num);
33 return bn_mul4x_mont_int(rp, ap, bp, np, n0, num);
36 * There used to be [optional] call to bn_mul_mont_fpu64 here,
37 * but above subroutine is faster on contemporary processors.
38 * Formulation means that there might be old processors where
39 * FPU code path would be faster, POWER6 perhaps, but there was
40 * no opportunity to figure it out...
43 #if defined(_ARCH_PPC64) && !defined(__ILP32__)
45 if (OPENSSL_ppccap_P & PPC_MADD300)
46 return bn_mul_mont_300_fixed_n6(rp, ap, bp, np, n0, num);
48 return bn_mul_mont_fixed_n6(rp, ap, bp, np, n0, num);
52 return bn_mul_mont_int(rp, ap, bp, np, n0, num);