From: jsing Date: Sat, 21 Jan 2023 17:29:56 +0000 (+0000) Subject: Provide an implementation of bn_sqr() that calls s2n-bignum's bignum_sqr(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=08a9f633eaa74d2eada016331ccd7cdfd52a205f;p=openbsd Provide an implementation of bn_sqr() that calls s2n-bignum's bignum_sqr(). ok tb@ --- diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 9f223f5977c..451a48091c8 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.92 2023/01/20 10:04:33 jsing Exp $ +# $OpenBSD: Makefile,v 1.93 2023/01/21 17:29:56 jsing Exp $ LIB= crypto LIBREBUILD=y @@ -733,13 +733,14 @@ SRCS+= x509spki.c SRCS+= x509type.c SRCS+= x_all.c -.PATH: ${.CURDIR}/arch/${MACHINE_CPU} \ +.PATH: ${LCRYPTO_SRC}/arch/${MACHINE_CPU} \ ${LCRYPTO_SRC} \ ${LCRYPTO_SRC}/aes \ ${LCRYPTO_SRC}/asn1 \ ${LCRYPTO_SRC}/bf \ ${LCRYPTO_SRC}/bio \ ${LCRYPTO_SRC}/bn \ + ${LCRYPTO_SRC}/bn/arch/${MACHINE_CPU} \ ${LCRYPTO_SRC}/bn/asm \ ${LCRYPTO_SRC}/buffer \ ${LCRYPTO_SRC}/bytestring \ diff --git a/lib/libcrypto/arch/amd64/Makefile.inc b/lib/libcrypto/arch/amd64/Makefile.inc index dc615ece1c3..1fd9f689197 100644 --- a/lib/libcrypto/arch/amd64/Makefile.inc +++ b/lib/libcrypto/arch/amd64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.9 2023/01/14 15:45:43 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.10 2023/01/21 17:29:56 jsing Exp $ # amd64-specific libcrypto build rules @@ -26,6 +26,11 @@ CFLAGS+= -DOPENSSL_BN_ASM_MONT5 SSLASM+= bn x86_64-mont5 CFLAGS+= -DOPENSSL_BN_ASM_GF2m SSLASM+= bn x86_64-gf2m + +# bn s2n-bignum +SRCS += bn_arch.c +SRCS += bignum_sqr.S + # camellia SRCS+= cmll_misc.c SSLASM+= camellia cmll-x86_64 diff --git a/lib/libcrypto/bn/arch/amd64/bn_arch.c b/lib/libcrypto/bn/arch/amd64/bn_arch.c new file mode 100644 index 00000000000..240575955ce --- /dev/null +++ b/lib/libcrypto/bn/arch/amd64/bn_arch.c @@ -0,0 +1,32 @@ +/* $OpenBSD: bn_arch.c,v 1.1 2023/01/21 17:29:56 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "bn_arch.h" +#include "bn_local.h" +#include "s2n_bignum.h" + +#ifdef HAVE_BN_SQR +int +bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) +{ + bignum_sqr(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d); + + return 1; +} +#endif