diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/arch/amd64/Makefile.inc | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bn_arch.c | 80 |
2 files changed, 90 insertions, 3 deletions
diff --git a/src/lib/libcrypto/arch/amd64/Makefile.inc b/src/lib/libcrypto/arch/amd64/Makefile.inc index 1fd9f68919..5e433b572d 100644 --- a/src/lib/libcrypto/arch/amd64/Makefile.inc +++ b/src/lib/libcrypto/arch/amd64/Makefile.inc | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.10 2023/01/21 17:29:56 jsing Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.11 2023/01/29 14:00:41 jsing Exp $ |
2 | 2 | ||
3 | # amd64-specific libcrypto build rules | 3 | # amd64-specific libcrypto build rules |
4 | 4 | ||
@@ -29,7 +29,16 @@ SSLASM+= bn x86_64-gf2m | |||
29 | 29 | ||
30 | # bn s2n-bignum | 30 | # bn s2n-bignum |
31 | SRCS += bn_arch.c | 31 | SRCS += bn_arch.c |
32 | SRCS += bignum_add.S | ||
33 | SRCS += bignum_cmadd.S | ||
34 | SRCS += bignum_cmul.S | ||
35 | SRCS += bignum_mul.S | ||
36 | SRCS += bignum_mul_4_8_alt.S | ||
37 | SRCS += bignum_mul_8_16_alt.S | ||
32 | SRCS += bignum_sqr.S | 38 | SRCS += bignum_sqr.S |
39 | SRCS += bignum_sqr_4_8_alt.S | ||
40 | SRCS += bignum_sqr_8_16_alt.S | ||
41 | SRCS += bignum_sub.S | ||
33 | 42 | ||
34 | # camellia | 43 | # camellia |
35 | SRCS+= cmll_misc.c | 44 | SRCS+= cmll_misc.c |
@@ -75,7 +84,7 @@ ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl ${EXTRA_PL} | |||
75 | .endfor | 84 | .endfor |
76 | 85 | ||
77 | CFLAGS+= -DOPENSSL_CPUID_OBJ | 86 | CFLAGS+= -DOPENSSL_CPUID_OBJ |
78 | SRCS+= x86_64cpuid.S x86_64-gcc.c | 87 | SRCS+= x86_64cpuid.S |
79 | GENERATED+=x86_64cpuid.S | 88 | GENERATED+=x86_64cpuid.S |
80 | 89 | ||
81 | x86_64cpuid.S: ${LCRYPTO_SRC}/x86_64cpuid.pl ${EXTRA_PL} | 90 | x86_64cpuid.S: ${LCRYPTO_SRC}/x86_64cpuid.pl ${EXTRA_PL} |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c index 240575955c..aedefc76e2 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c +++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.c,v 1.1 2023/01/21 17:29:56 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.c,v 1.2 2023/01/29 14:00:41 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -21,6 +21,58 @@ | |||
21 | #include "bn_local.h" | 21 | #include "bn_local.h" |
22 | #include "s2n_bignum.h" | 22 | #include "s2n_bignum.h" |
23 | 23 | ||
24 | #ifdef HAVE_BN_ADD_WORDS | ||
25 | BN_ULONG | ||
26 | bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) | ||
27 | { | ||
28 | return bignum_add(n, (uint64_t *)rd, n, (uint64_t *)ad, n, | ||
29 | (uint64_t *)bd); | ||
30 | } | ||
31 | #endif | ||
32 | |||
33 | #ifdef HAVE_BN_SUB_WORDS | ||
34 | BN_ULONG | ||
35 | bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) | ||
36 | { | ||
37 | return bignum_sub(n, (uint64_t *)rd, n, (uint64_t *)ad, n, | ||
38 | (uint64_t *)bd); | ||
39 | } | ||
40 | #endif | ||
41 | |||
42 | #ifdef HAVE_BN_MUL_ADD_WORDS | ||
43 | BN_ULONG | ||
44 | bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) | ||
45 | { | ||
46 | return bignum_cmadd(num, (uint64_t *)rd, w, num, (uint64_t *)ad); | ||
47 | } | ||
48 | #endif | ||
49 | |||
50 | #ifdef HAVE_BN_MUL_WORDS | ||
51 | BN_ULONG | ||
52 | bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) | ||
53 | { | ||
54 | return bignum_cmul(num, (uint64_t *)rd, w, num, (uint64_t *)ad); | ||
55 | } | ||
56 | #endif | ||
57 | |||
58 | #ifdef HAVE_BN_MUL_COMBA4 | ||
59 | void | ||
60 | bn_mul_comba4(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) | ||
61 | { | ||
62 | /* XXX - consider using non-alt on CPUs that have the ADX extension. */ | ||
63 | bignum_mul_4_8_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); | ||
64 | } | ||
65 | #endif | ||
66 | |||
67 | #ifdef HAVE_BN_MUL_COMBA8 | ||
68 | void | ||
69 | bn_mul_comba8(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) | ||
70 | { | ||
71 | /* XXX - consider using non-alt on CPUs that have the ADX extension. */ | ||
72 | bignum_mul_8_16_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); | ||
73 | } | ||
74 | #endif | ||
75 | |||
24 | #ifdef HAVE_BN_SQR | 76 | #ifdef HAVE_BN_SQR |
25 | int | 77 | int |
26 | bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) | 78 | bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) |
@@ -30,3 +82,29 @@ bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) | |||
30 | return 1; | 82 | return 1; |
31 | } | 83 | } |
32 | #endif | 84 | #endif |
85 | |||
86 | #ifdef HAVE_BN_SQR_COMBA4 | ||
87 | void | ||
88 | bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad) | ||
89 | { | ||
90 | /* XXX - consider using non-alt on CPUs that have the ADX extension. */ | ||
91 | bignum_sqr_4_8_alt((uint64_t *)rd, (uint64_t *)ad); | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | #ifdef HAVE_BN_SQR_COMBA8 | ||
96 | void | ||
97 | bn_sqr_comba8(BN_ULONG *rd, const BN_ULONG *ad) | ||
98 | { | ||
99 | /* XXX - consider using non-alt on CPUs that have the ADX extension. */ | ||
100 | bignum_sqr_8_16_alt((uint64_t *)rd, (uint64_t *)ad); | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | #ifdef HAVE_BN_SQR_WORDS | ||
105 | void | ||
106 | bn_sqr_words(BN_ULONG *rd, const BN_ULONG *ad, int num) | ||
107 | { | ||
108 | bignum_sqr(num, (uint64_t *)rd, num, (uint64_t *)ad); | ||
109 | } | ||
110 | #endif | ||