From a5307b10e852ebc817004b921cfba307224eb6a4 Mon Sep 17 00:00:00 2001 From: jsing Date: Fri, 20 Jan 2023 04:49:48 +0000 Subject: [PATCH] Reorder functions for easier maintenance. No functional change. --- lib/libcrypto/bn/bn_add.c | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/libcrypto/bn/bn_add.c b/lib/libcrypto/bn/bn_add.c index aec7f1ee9ad..3352e0e1d5c 100644 --- a/lib/libcrypto/bn/bn_add.c +++ b/lib/libcrypto/bn/bn_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_add.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: bn_add.c,v 1.17 2023/01/20 04:49:48 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,35 +62,6 @@ #include "bn_local.h" -int -BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) -{ - int ret, r_neg; - - - if (a->neg == b->neg) { - r_neg = a->neg; - ret = BN_uadd(r, a, b); - } else { - int cmp = BN_ucmp(a, b); - - if (cmp > 0) { - r_neg = a->neg; - ret = BN_usub(r, a, b); - } else if (cmp < 0) { - r_neg = b->neg; - ret = BN_usub(r, b, a); - } else { - r_neg = 0; - BN_zero(r); - ret = 1; - } - } - - r->neg = r_neg; - return ret; -} - int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { @@ -182,6 +153,35 @@ BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) return 1; } +int +BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) +{ + int ret, r_neg; + + + if (a->neg == b->neg) { + r_neg = a->neg; + ret = BN_uadd(r, a, b); + } else { + int cmp = BN_ucmp(a, b); + + if (cmp > 0) { + r_neg = a->neg; + ret = BN_usub(r, a, b); + } else if (cmp < 0) { + r_neg = b->neg; + ret = BN_usub(r, b, a); + } else { + r_neg = 0; + BN_zero(r); + ret = 1; + } + } + + r->neg = r_neg; + return ret; +} + int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { -- 2.20.1