From 6dbe806d026a9b65d3decbcd23fb9b70559bf259 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Thu, 14 Aug 2025 15:15:04 +0000 Subject: Add special handling for multiplication and squaring of BNs with six words. In these cases make use of bn_mul_comba6() or bn_sqr_comba6(), which are faster than the normal path. ok tb@ --- src/lib/libcrypto/bn/bn_mul.c | 4 +++- src/lib/libcrypto/bn/bn_sqr.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c index 70f6534b8f..a30d05fb02 100644 --- a/src/lib/libcrypto/bn/bn_mul.c +++ b/src/lib/libcrypto/bn/bn_mul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mul.c,v 1.42 2025/08/05 15:06:13 jsing Exp $ */ +/* $OpenBSD: bn_mul.c,v 1.43 2025/08/14 15:15:04 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -407,6 +407,8 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) if (a->top == 4 && b->top == 4) { bn_mul_comba4(rr->d, a->d, b->d); + } else if (a->top == 6 && b->top == 6) { + bn_mul_comba6(rr->d, a->d, b->d); } else if (a->top == 8 && b->top == 8) { bn_mul_comba8(rr->d, a->d, b->d); } else { diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c index ab1282e3b1..2f7f71f819 100644 --- a/src/lib/libcrypto/bn/bn_sqr.c +++ b/src/lib/libcrypto/bn/bn_sqr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqr.c,v 1.37 2025/08/05 15:08:13 jsing Exp $ */ +/* $OpenBSD: bn_sqr.c,v 1.38 2025/08/14 15:15:04 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -326,6 +326,8 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) if (a->top == 4) { bn_sqr_comba4(rr->d, a->d); + } else if (a->top == 6) { + bn_sqr_comba6(rr->d, a->d); } else if (a->top == 8) { bn_sqr_comba8(rr->d, a->d); } else { -- cgit v1.2.3-55-g6feb