summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn
diff options
context:
space:
mode:
authortb <>2022-11-26 16:08:57 +0000
committertb <>2022-11-26 16:08:57 +0000
commitd0a21970fdc0fbbfc7ad31bc135f5a8fde1d3d49 (patch)
tree556ebf909e81599dc3d8da585217d1576eabe0e4 /src/lib/libcrypto/bn
parentbcbac728558eebfaa4404c405e7dc22769585345 (diff)
downloadopenbsd-d0a21970fdc0fbbfc7ad31bc135f5a8fde1d3d49.tar.gz
openbsd-d0a21970fdc0fbbfc7ad31bc135f5a8fde1d3d49.tar.bz2
openbsd-d0a21970fdc0fbbfc7ad31bc135f5a8fde1d3d49.zip
Make internal header file names consistent
Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names used for internal headers. Move all these headers we inherited from OpenSSL to *_local.h, reserving the name *_internal.h for our own code. Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h. constant_time_locl.h is moved to constant_time.h since it's special. Adjust all .c files in libcrypto, libssl and regress. The diff is mechanical with the exception of tls13_quic.c, where #include <ssl_locl.h> was fixed manually. discussed with jsing, no objection bcook
Diffstat (limited to 'src/lib/libcrypto/bn')
-rw-r--r--src/lib/libcrypto/bn/asm/x86_64-gcc.c4
-rw-r--r--src/lib/libcrypto/bn/bn_add.c4
-rw-r--r--src/lib/libcrypto/bn/bn_asm.c4
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c4
-rw-r--r--src/lib/libcrypto/bn/bn_bpsw.c4
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c4
-rw-r--r--src/lib/libcrypto/bn/bn_depr.c4
-rw-r--r--src/lib/libcrypto/bn/bn_div.c4
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c6
-rw-r--r--src/lib/libcrypto/bn/bn_exp2.c4
-rw-r--r--src/lib/libcrypto/bn/bn_gcd.c4
-rw-r--r--src/lib/libcrypto/bn/bn_gf2m.c4
-rw-r--r--src/lib/libcrypto/bn/bn_isqrt.c4
-rw-r--r--src/lib/libcrypto/bn/bn_kron.c4
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c4
-rw-r--r--src/lib/libcrypto/bn/bn_local.h567
-rw-r--r--src/lib/libcrypto/bn/bn_mod.c4
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c4
-rw-r--r--src/lib/libcrypto/bn/bn_mpi.c4
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c4
-rw-r--r--src/lib/libcrypto/bn/bn_nist.c4
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c4
-rw-r--r--src/lib/libcrypto/bn/bn_print.c4
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c4
-rw-r--r--src/lib/libcrypto/bn/bn_recp.c4
-rw-r--r--src/lib/libcrypto/bn/bn_shift.c4
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c4
-rw-r--r--src/lib/libcrypto/bn/bn_sqrt.c4
-rw-r--r--src/lib/libcrypto/bn/bn_word.c4
-rw-r--r--src/lib/libcrypto/bn/bn_x931p.c4
30 files changed, 626 insertions, 59 deletions
diff --git a/src/lib/libcrypto/bn/asm/x86_64-gcc.c b/src/lib/libcrypto/bn/asm/x86_64-gcc.c
index bd068cfb51..e98ffe41e5 100644
--- a/src/lib/libcrypto/bn/asm/x86_64-gcc.c
+++ b/src/lib/libcrypto/bn/asm/x86_64-gcc.c
@@ -1,5 +1,5 @@
1/* $OpenBSD: x86_64-gcc.c,v 1.6 2015/09/12 09:04:12 miod Exp $ */ 1/* $OpenBSD: x86_64-gcc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */
2#include "../bn_lcl.h" 2#include "../bn_local.h"
3/* 3/*
4 * x86_64 BIGNUM accelerator version 0.1, December 2002. 4 * x86_64 BIGNUM accelerator version 0.1, December 2002.
5 * 5 *
diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c
index a81dd0ce75..aec7f1ee9a 100644
--- a/src/lib/libcrypto/bn/bn_add.c
+++ b/src/lib/libcrypto/bn/bn_add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_add.c,v 1.15 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_add.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,7 +60,7 @@
60 60
61#include <openssl/err.h> 61#include <openssl/err.h>
62 62
63#include "bn_lcl.h" 63#include "bn_local.h"
64 64
65int 65int
66BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) 66BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
diff --git a/src/lib/libcrypto/bn/bn_asm.c b/src/lib/libcrypto/bn/bn_asm.c
index 993fbb3dc5..fd1990e5ed 100644
--- a/src/lib/libcrypto/bn/bn_asm.c
+++ b/src/lib/libcrypto/bn/bn_asm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_asm.c,v 1.15 2017/05/02 03:59:44 deraadt Exp $ */ 1/* $OpenBSD: bn_asm.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -66,7 +66,7 @@
66 66
67#include <openssl/opensslconf.h> 67#include <openssl/opensslconf.h>
68 68
69#include "bn_lcl.h" 69#include "bn_local.h"
70 70
71#if defined(BN_LLONG) || defined(BN_UMULT_HIGH) 71#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
72 72
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c
index 412338ec02..fbcdf1c6e7 100644
--- a/src/lib/libcrypto/bn/bn_blind.c
+++ b/src/lib/libcrypto/bn/bn_blind.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_blind.c,v 1.18 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_blind.c,v 1.19 2022/11/26 16:08:51 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -115,7 +115,7 @@
115 115
116#include <openssl/err.h> 116#include <openssl/err.h>
117 117
118#include "bn_lcl.h" 118#include "bn_local.h"
119 119
120#define BN_BLINDING_COUNTER 32 120#define BN_BLINDING_COUNTER 32
121 121
diff --git a/src/lib/libcrypto/bn/bn_bpsw.c b/src/lib/libcrypto/bn/bn_bpsw.c
index 2f8cbba342..9220339f19 100644
--- a/src/lib/libcrypto/bn/bn_bpsw.c
+++ b/src/lib/libcrypto/bn/bn_bpsw.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_bpsw.c,v 1.7 2022/08/31 21:34:14 tb Exp $ */ 1/* $OpenBSD: bn_bpsw.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Martin Grenouilloux <martin.grenouilloux@lse.epita.fr> 3 * Copyright (c) 2022 Martin Grenouilloux <martin.grenouilloux@lse.epita.fr>
4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
@@ -18,7 +18,7 @@
18 18
19#include <openssl/bn.h> 19#include <openssl/bn.h>
20 20
21#include "bn_lcl.h" 21#include "bn_local.h"
22#include "bn_prime.h" 22#include "bn_prime.h"
23 23
24/* 24/*
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
index 8ac1685a00..606db82f24 100644
--- a/src/lib/libcrypto/bn/bn_ctx.c
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_ctx.c,v 1.17 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_ctx.c,v 1.18 2022/11/26 16:08:51 tb Exp $ */
2/* Written by Ulf Moeller for the OpenSSL project. */ 2/* Written by Ulf Moeller for the OpenSSL project. */
3/* ==================================================================== 3/* ====================================================================
4 * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. 4 * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved.
@@ -67,7 +67,7 @@
67 67
68#include <openssl/err.h> 68#include <openssl/err.h>
69 69
70#include "bn_lcl.h" 70#include "bn_local.h"
71 71
72/* TODO list 72/* TODO list
73 * 73 *
diff --git a/src/lib/libcrypto/bn/bn_depr.c b/src/lib/libcrypto/bn/bn_depr.c
index dc5c2abee0..0e9f622586 100644
--- a/src/lib/libcrypto/bn/bn_depr.c
+++ b/src/lib/libcrypto/bn/bn_depr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_depr.c,v 1.7 2014/10/18 17:20:40 jsing Exp $ */ 1/* $OpenBSD: bn_depr.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -61,7 +61,7 @@
61 61
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63
64#include "bn_lcl.h" 64#include "bn_local.h"
65 65
66#ifndef OPENSSL_NO_DEPRECATED 66#ifndef OPENSSL_NO_DEPRECATED
67BIGNUM * 67BIGNUM *
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index 288ec92ef4..a62e74da5d 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_div.c,v 1.27 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_div.c,v 1.28 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,7 +63,7 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/err.h> 64#include <openssl/err.h>
65 65
66#include "bn_lcl.h" 66#include "bn_local.h"
67 67
68#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \ 68#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
69 && !defined(BN_DIV3W) 69 && !defined(BN_DIV3W)
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index 3bb0dd1304..e36eeff6bf 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp.c,v 1.34 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_exp.c,v 1.35 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -114,8 +114,8 @@
114 114
115#include <openssl/err.h> 115#include <openssl/err.h>
116 116
117#include "bn_lcl.h" 117#include "bn_local.h"
118#include "constant_time_locl.h" 118#include "constant_time.h"
119 119
120/* maximum precomputation table size for *variable* sliding windows */ 120/* maximum precomputation table size for *variable* sliding windows */
121#define TABLE_SIZE 32 121#define TABLE_SIZE 32
diff --git a/src/lib/libcrypto/bn/bn_exp2.c b/src/lib/libcrypto/bn/bn_exp2.c
index b2fd53e971..03f99414cd 100644
--- a/src/lib/libcrypto/bn/bn_exp2.c
+++ b/src/lib/libcrypto/bn/bn_exp2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp2.c,v 1.14 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_exp2.c,v 1.15 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -113,7 +113,7 @@
113 113
114#include <openssl/err.h> 114#include <openssl/err.h>
115 115
116#include "bn_lcl.h" 116#include "bn_local.h"
117 117
118#define TABLE_SIZE 32 118#define TABLE_SIZE 32
119 119
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c
index 3d92a43cef..4661b35571 100644
--- a/src/lib/libcrypto/bn/bn_gcd.c
+++ b/src/lib/libcrypto/bn/bn_gcd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_gcd.c,v 1.17 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_gcd.c,v 1.18 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -111,7 +111,7 @@
111 111
112#include <openssl/err.h> 112#include <openssl/err.h>
113 113
114#include "bn_lcl.h" 114#include "bn_local.h"
115 115
116static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); 116static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
117static BIGNUM *BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, 117static BIGNUM *BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n,
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c
index 8adbbeb040..e5818ca18d 100644
--- a/src/lib/libcrypto/bn/bn_gf2m.c
+++ b/src/lib/libcrypto/bn/bn_gf2m.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_gf2m.c,v 1.27 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_gf2m.c,v 1.28 2022/11/26 16:08:51 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -95,7 +95,7 @@
95 95
96#include <openssl/err.h> 96#include <openssl/err.h>
97 97
98#include "bn_lcl.h" 98#include "bn_local.h"
99 99
100#ifndef OPENSSL_NO_EC2M 100#ifndef OPENSSL_NO_EC2M
101 101
diff --git a/src/lib/libcrypto/bn/bn_isqrt.c b/src/lib/libcrypto/bn/bn_isqrt.c
index cc6f722679..7becbd6706 100644
--- a/src/lib/libcrypto/bn/bn_isqrt.c
+++ b/src/lib/libcrypto/bn/bn_isqrt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_isqrt.c,v 1.3 2022/10/11 13:52:23 tb Exp $ */ 1/* $OpenBSD: bn_isqrt.c,v 1.4 2022/11/26 16:08:51 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -21,7 +21,7 @@
21#include <openssl/bn.h> 21#include <openssl/bn.h>
22#include <openssl/err.h> 22#include <openssl/err.h>
23 23
24#include "bn_lcl.h" 24#include "bn_local.h"
25 25
26#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ 26#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
27 __attribute__((__unused__)) 27 __attribute__((__unused__))
diff --git a/src/lib/libcrypto/bn/bn_kron.c b/src/lib/libcrypto/bn/bn_kron.c
index 8629892a72..c991cd2f61 100644
--- a/src/lib/libcrypto/bn/bn_kron.c
+++ b/src/lib/libcrypto/bn/bn_kron.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_kron.c,v 1.11 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_kron.c,v 1.12 2022/11/26 16:08:51 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -53,7 +53,7 @@
53 * 53 *
54 */ 54 */
55 55
56#include "bn_lcl.h" 56#include "bn_local.h"
57 57
58/* 58/*
59 * Kronecker symbol, implemented according to Henri Cohen, "A Course in 59 * Kronecker symbol, implemented according to Henri Cohen, "A Course in
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index a3b6811986..97e8f27043 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.62 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.63 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -70,7 +70,7 @@
70 70
71#include <openssl/err.h> 71#include <openssl/err.h>
72 72
73#include "bn_lcl.h" 73#include "bn_local.h"
74 74
75BIGNUM * 75BIGNUM *
76BN_new(void) 76BN_new(void)
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h
new file mode 100644
index 0000000000..73d1f0a215
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_local.h
@@ -0,0 +1,567 @@
1/* $OpenBSD: bn_local.h,v 1.1 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#ifndef HEADER_BN_LCL_H
113#define HEADER_BN_LCL_H
114
115#include <openssl/opensslconf.h>
116
117#include <openssl/bn.h>
118
119__BEGIN_HIDDEN_DECLS
120
121struct bignum_st {
122 BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
123 int top; /* Index of last used d +1. */
124 /* The next are internal book keeping for bn_expand. */
125 int dmax; /* Size of the d array. */
126 int neg; /* one if the number is negative */
127 int flags;
128};
129
130/* Used for montgomery multiplication */
131struct bn_mont_ctx_st {
132 int ri; /* number of bits in R */
133 BIGNUM RR; /* used to convert to montgomery form */
134 BIGNUM N; /* The modulus */
135 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
136 * (Ni is only stored for bignum algorithm) */
137 BN_ULONG n0[2];/* least significant word(s) of Ni;
138 (type changed with 0.9.9, was "BN_ULONG n0;" before) */
139 int flags;
140};
141
142/* Used for reciprocal division/mod functions
143 * It cannot be shared between threads
144 */
145struct bn_recp_ctx_st {
146 BIGNUM N; /* the divisor */
147 BIGNUM Nr; /* the reciprocal */
148 int num_bits;
149 int shift;
150 int flags;
151};
152
153/* Used for slow "generation" functions. */
154struct bn_gencb_st {
155 unsigned int ver; /* To handle binary (in)compatibility */
156 void *arg; /* callback-specific data */
157 union {
158 /* if(ver==1) - handles old style callbacks */
159 void (*cb_1)(int, int, void *);
160 /* if(ver==2) - new callback style */
161 int (*cb_2)(int, int, BN_GENCB *);
162 } cb;
163};
164
165/*
166 * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
167 *
168 *
169 * For window size 'w' (w >= 2) and a random 'b' bits exponent,
170 * the number of multiplications is a constant plus on average
171 *
172 * 2^(w-1) + (b-w)/(w+1);
173 *
174 * here 2^(w-1) is for precomputing the table (we actually need
175 * entries only for windows that have the lowest bit set), and
176 * (b-w)/(w+1) is an approximation for the expected number of
177 * w-bit windows, not counting the first one.
178 *
179 * Thus we should use
180 *
181 * w >= 6 if b > 671
182 * w = 5 if 671 > b > 239
183 * w = 4 if 239 > b > 79
184 * w = 3 if 79 > b > 23
185 * w <= 2 if 23 > b
186 *
187 * (with draws in between). Very small exponents are often selected
188 * with low Hamming weight, so we use w = 1 for b <= 23.
189 */
190#define BN_window_bits_for_exponent_size(b) \
191 ((b) > 671 ? 6 : \
192 (b) > 239 ? 5 : \
193 (b) > 79 ? 4 : \
194 (b) > 23 ? 3 : 1)
195
196
197/* BN_mod_exp_mont_consttime is based on the assumption that the
198 * L1 data cache line width of the target processor is at least
199 * the following value.
200 */
201#define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
202#define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
203
204/* Window sizes optimized for fixed window size modular exponentiation
205 * algorithm (BN_mod_exp_mont_consttime).
206 *
207 * To achieve the security goals of BN_mode_exp_mont_consttime, the
208 * maximum size of the window must not exceed
209 * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH).
210 *
211 * Window size thresholds are defined for cache line sizes of 32 and 64,
212 * cache line sizes where log_2(32)=5 and log_2(64)=6 respectively. A
213 * window size of 7 should only be used on processors that have a 128
214 * byte or greater cache line size.
215 */
216#if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
217
218# define BN_window_bits_for_ctime_exponent_size(b) \
219 ((b) > 937 ? 6 : \
220 (b) > 306 ? 5 : \
221 (b) > 89 ? 4 : \
222 (b) > 22 ? 3 : 1)
223# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
224
225#elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
226
227# define BN_window_bits_for_ctime_exponent_size(b) \
228 ((b) > 306 ? 5 : \
229 (b) > 89 ? 4 : \
230 (b) > 22 ? 3 : 1)
231# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
232
233#endif
234
235
236/* Pentium pro 16,16,16,32,64 */
237/* Alpha 16,16,16,16.64 */
238#define BN_MULL_SIZE_NORMAL (16) /* 32 */
239#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */
240#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */
241#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
242#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
243
244#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
245/*
246 * BN_UMULT_HIGH section.
247 *
248 * No, I'm not trying to overwhelm you when stating that the
249 * product of N-bit numbers is 2*N bits wide:-) No, I don't expect
250 * you to be impressed when I say that if the compiler doesn't
251 * support 2*N integer type, then you have to replace every N*N
252 * multiplication with 4 (N/2)*(N/2) accompanied by some shifts
253 * and additions which unavoidably results in severe performance
254 * penalties. Of course provided that the hardware is capable of
255 * producing 2*N result... That's when you normally start
256 * considering assembler implementation. However! It should be
257 * pointed out that some CPUs (most notably Alpha, PowerPC and
258 * upcoming IA-64 family:-) provide *separate* instruction
259 * calculating the upper half of the product placing the result
260 * into a general purpose register. Now *if* the compiler supports
261 * inline assembler, then it's not impossible to implement the
262 * "bignum" routines (and have the compiler optimize 'em)
263 * exhibiting "native" performance in C. That's what BN_UMULT_HIGH
264 * macro is about:-)
265 *
266 * <appro@fy.chalmers.se>
267 */
268# if defined(__alpha)
269# if defined(__GNUC__) && __GNUC__>=2
270# define BN_UMULT_HIGH(a,b) ({ \
271 BN_ULONG ret; \
272 asm ("umulh %1,%2,%0" \
273 : "=r"(ret) \
274 : "r"(a), "r"(b)); \
275 ret; })
276# endif /* compiler */
277# elif defined(_ARCH_PPC) && defined(_LP64)
278# if defined(__GNUC__) && __GNUC__>=2
279# define BN_UMULT_HIGH(a,b) ({ \
280 BN_ULONG ret; \
281 asm ("mulhdu %0,%1,%2" \
282 : "=r"(ret) \
283 : "r"(a), "r"(b)); \
284 ret; })
285# endif /* compiler */
286# elif defined(__x86_64) || defined(__x86_64__)
287# if defined(__GNUC__) && __GNUC__>=2
288# define BN_UMULT_HIGH(a,b) ({ \
289 BN_ULONG ret,discard; \
290 asm ("mulq %3" \
291 : "=a"(discard),"=d"(ret) \
292 : "a"(a), "g"(b) \
293 : "cc"); \
294 ret; })
295# define BN_UMULT_LOHI(low,high,a,b) \
296 asm ("mulq %3" \
297 : "=a"(low),"=d"(high) \
298 : "a"(a),"g"(b) \
299 : "cc");
300# endif
301# elif defined(__mips) && defined(_LP64)
302# if defined(__GNUC__) && __GNUC__>=2
303# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) /* "h" constraint is no more since 4.4 */
304# define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64)
305# define BN_UMULT_LOHI(low,high,a,b) ({ \
306 __uint128_t ret=(__uint128_t)(a)*(b); \
307 (high)=ret>>64; (low)=ret; })
308# else
309# define BN_UMULT_HIGH(a,b) ({ \
310 BN_ULONG ret; \
311 asm ("dmultu %1,%2" \
312 : "=h"(ret) \
313 : "r"(a), "r"(b) : "l"); \
314 ret; })
315# define BN_UMULT_LOHI(low,high,a,b)\
316 asm ("dmultu %2,%3" \
317 : "=l"(low),"=h"(high) \
318 : "r"(a), "r"(b));
319# endif
320# endif
321# endif /* cpu */
322#endif /* OPENSSL_NO_ASM */
323
324/*************************************************************
325 * Using the long long type
326 */
327#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
328#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
329
330#ifdef BN_LLONG
331#define mul_add(r,a,w,c) { \
332 BN_ULLONG t; \
333 t=(BN_ULLONG)w * (a) + (r) + (c); \
334 (r)= Lw(t); \
335 (c)= Hw(t); \
336 }
337
338#define mul(r,a,w,c) { \
339 BN_ULLONG t; \
340 t=(BN_ULLONG)w * (a) + (c); \
341 (r)= Lw(t); \
342 (c)= Hw(t); \
343 }
344
345#define sqr(r0,r1,a) { \
346 BN_ULLONG t; \
347 t=(BN_ULLONG)(a)*(a); \
348 (r0)=Lw(t); \
349 (r1)=Hw(t); \
350 }
351
352#elif defined(BN_UMULT_LOHI)
353#define mul_add(r,a,w,c) { \
354 BN_ULONG high,low,ret,tmp=(a); \
355 ret = (r); \
356 BN_UMULT_LOHI(low,high,w,tmp); \
357 ret += (c); \
358 (c) = (ret<(c))?1:0; \
359 (c) += high; \
360 ret += low; \
361 (c) += (ret<low)?1:0; \
362 (r) = ret; \
363 }
364
365#define mul(r,a,w,c) { \
366 BN_ULONG high,low,ret,ta=(a); \
367 BN_UMULT_LOHI(low,high,w,ta); \
368 ret = low + (c); \
369 (c) = high; \
370 (c) += (ret<low)?1:0; \
371 (r) = ret; \
372 }
373
374#define sqr(r0,r1,a) { \
375 BN_ULONG tmp=(a); \
376 BN_UMULT_LOHI(r0,r1,tmp,tmp); \
377 }
378
379#elif defined(BN_UMULT_HIGH)
380#define mul_add(r,a,w,c) { \
381 BN_ULONG high,low,ret,tmp=(a); \
382 ret = (r); \
383 high= BN_UMULT_HIGH(w,tmp); \
384 ret += (c); \
385 low = (w) * tmp; \
386 (c) = (ret<(c))?1:0; \
387 (c) += high; \
388 ret += low; \
389 (c) += (ret<low)?1:0; \
390 (r) = ret; \
391 }
392
393#define mul(r,a,w,c) { \
394 BN_ULONG high,low,ret,ta=(a); \
395 low = (w) * ta; \
396 high= BN_UMULT_HIGH(w,ta); \
397 ret = low + (c); \
398 (c) = high; \
399 (c) += (ret<low)?1:0; \
400 (r) = ret; \
401 }
402
403#define sqr(r0,r1,a) { \
404 BN_ULONG tmp=(a); \
405 (r0) = tmp * tmp; \
406 (r1) = BN_UMULT_HIGH(tmp,tmp); \
407 }
408
409#else
410/*************************************************************
411 * No long long type
412 */
413
414#define LBITS(a) ((a)&BN_MASK2l)
415#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
416#define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
417
418#define mul64(l,h,bl,bh) \
419 { \
420 BN_ULONG m,m1,lt,ht; \
421 \
422 lt=l; \
423 ht=h; \
424 m =(bh)*(lt); \
425 lt=(bl)*(lt); \
426 m1=(bl)*(ht); \
427 ht =(bh)*(ht); \
428 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
429 ht+=HBITS(m); \
430 m1=L2HBITS(m); \
431 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
432 (l)=lt; \
433 (h)=ht; \
434 }
435
436#define sqr64(lo,ho,in) \
437 { \
438 BN_ULONG l,h,m; \
439 \
440 h=(in); \
441 l=LBITS(h); \
442 h=HBITS(h); \
443 m =(l)*(h); \
444 l*=l; \
445 h*=h; \
446 h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
447 m =(m&BN_MASK2l)<<(BN_BITS4+1); \
448 l=(l+m)&BN_MASK2; if (l < m) h++; \
449 (lo)=l; \
450 (ho)=h; \
451 }
452
453#define mul_add(r,a,bl,bh,c) { \
454 BN_ULONG l,h; \
455 \
456 h= (a); \
457 l=LBITS(h); \
458 h=HBITS(h); \
459 mul64(l,h,(bl),(bh)); \
460 \
461 /* non-multiply part */ \
462 l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
463 (c)=(r); \
464 l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
465 (c)=h&BN_MASK2; \
466 (r)=l; \
467 }
468
469#define mul(r,a,bl,bh,c) { \
470 BN_ULONG l,h; \
471 \
472 h= (a); \
473 l=LBITS(h); \
474 h=HBITS(h); \
475 mul64(l,h,(bl),(bh)); \
476 \
477 /* non-multiply part */ \
478 l+=(c); if ((l&BN_MASK2) < (c)) h++; \
479 (c)=h&BN_MASK2; \
480 (r)=l&BN_MASK2; \
481 }
482#endif /* !BN_LLONG */
483
484/* The least significant word of a BIGNUM. */
485#define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0])
486
487void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
488void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
489void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
490void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
491void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);
492void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);
493int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n);
494int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
495 int cl, int dl);
496void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
497 int dna, int dnb, BN_ULONG *t);
498void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
499 int n, int tna, int tnb, BN_ULONG *t);
500void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
501void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
502void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
503 BN_ULONG *t);
504void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
505 BN_ULONG *t);
506BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
507 int cl, int dl);
508BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
509 int cl, int dl);
510int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
511
512int bn_expand(BIGNUM *a, int bits);
513int bn_wexpand(BIGNUM *a, int words);
514
515#define bn_correct_top(a) \
516 { \
517 BN_ULONG *ftl; \
518 int tmp_top = (a)->top; \
519 if (tmp_top > 0) \
520 { \
521 for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
522 if (*(ftl--)) break; \
523 (a)->top = tmp_top; \
524 } \
525 }
526
527BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
528BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
529void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
530BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
531BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num);
532BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num);
533
534int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);
535int bn_rand_interval(BIGNUM *rnd, const BIGNUM *lower_inc, const BIGNUM *upper_exc);
536
537/* Explicitly const time / non-const time versions for internal use */
538int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
539 const BIGNUM *m, BN_CTX *ctx);
540int BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
541 const BIGNUM *m, BN_CTX *ctx);
542int BN_mod_exp_mont_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
543 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
544int BN_mod_exp_mont_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
545 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
546int BN_div_nonct(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
547 BN_CTX *ctx);
548int BN_div_ct(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
549 BN_CTX *ctx);
550#define BN_mod_ct(rem,m,d,ctx) BN_div_ct(NULL,(rem),(m),(d),(ctx))
551#define BN_mod_nonct(rem,m,d,ctx) BN_div_nonct(NULL,(rem),(m),(d),(ctx))
552BIGNUM *BN_mod_inverse_ct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,
553 BN_CTX *ctx);
554BIGNUM *BN_mod_inverse_nonct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,
555 BN_CTX *ctx);
556int BN_gcd_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
557int BN_gcd_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
558
559int BN_swap_ct(BN_ULONG swap, BIGNUM *a, BIGNUM *b, size_t nwords);
560
561int bn_isqrt(BIGNUM *out_sqrt, int *out_perfect, const BIGNUM *n, BN_CTX *ctx);
562int bn_is_perfect_square(int *out_perfect, const BIGNUM *n, BN_CTX *ctx);
563
564int bn_is_prime_bpsw(int *is_prime, const BIGNUM *n, BN_CTX *in_ctx);
565
566__END_HIDDEN_DECLS
567#endif
diff --git a/src/lib/libcrypto/bn/bn_mod.c b/src/lib/libcrypto/bn/bn_mod.c
index 5be8252f2d..cc8f8dea00 100644
--- a/src/lib/libcrypto/bn/bn_mod.c
+++ b/src/lib/libcrypto/bn/bn_mod.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mod.c,v 1.13 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_mod.c,v 1.14 2022/11/26 16:08:51 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. */ 3 * for the OpenSSL project. */
4/* ==================================================================== 4/* ====================================================================
@@ -113,7 +113,7 @@
113 113
114#include <openssl/err.h> 114#include <openssl/err.h>
115 115
116#include "bn_lcl.h" 116#include "bn_local.h"
117 117
118int 118int
119BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) 119BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index 24bc41e886..d4de5c2cc5 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mont.c,v 1.31 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_mont.c,v 1.32 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -119,7 +119,7 @@
119#include <stdio.h> 119#include <stdio.h>
120#include <stdint.h> 120#include <stdint.h>
121 121
122#include "bn_lcl.h" 122#include "bn_local.h"
123 123
124#define MONT_WORD /* use the faster word-based algorithm */ 124#define MONT_WORD /* use the faster word-based algorithm */
125 125
diff --git a/src/lib/libcrypto/bn/bn_mpi.c b/src/lib/libcrypto/bn/bn_mpi.c
index 75b34511fe..9ad28b96c9 100644
--- a/src/lib/libcrypto/bn/bn_mpi.c
+++ b/src/lib/libcrypto/bn/bn_mpi.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mpi.c,v 1.10 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_mpi.c,v 1.11 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,7 +60,7 @@
60 60
61#include <openssl/err.h> 61#include <openssl/err.h>
62 62
63#include "bn_lcl.h" 63#include "bn_local.h"
64 64
65int 65int
66BN_bn2mpi(const BIGNUM *a, unsigned char *d) 66BN_bn2mpi(const BIGNUM *a, unsigned char *d)
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index 0d8da8a6f6..fea5bb32d0 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mul.c,v 1.22 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_mul.c,v 1.23 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -67,7 +67,7 @@
67 67
68#include <openssl/opensslconf.h> 68#include <openssl/opensslconf.h>
69 69
70#include "bn_lcl.h" 70#include "bn_local.h"
71 71
72#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS) 72#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS)
73/* Here follows specialised variants of bn_add_words() and 73/* Here follows specialised variants of bn_add_words() and
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c
index 6b51bb10f0..227ff008ba 100644
--- a/src/lib/libcrypto/bn/bn_nist.c
+++ b/src/lib/libcrypto/bn/bn_nist.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_nist.c,v 1.22 2022/07/31 14:38:38 jsing Exp $ */ 1/* $OpenBSD: bn_nist.c,v 1.23 2022/11/26 16:08:51 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -60,7 +60,7 @@
60#include <stdint.h> 60#include <stdint.h>
61#include <string.h> 61#include <string.h>
62 62
63#include "bn_lcl.h" 63#include "bn_local.h"
64 64
65#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ 65#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
66 __attribute__((__unused__)) 66 __attribute__((__unused__))
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index 0ba288c46a..f5e4597f9b 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_prime.c,v 1.27 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_prime.c,v 1.28 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -114,7 +114,7 @@
114 114
115#include <openssl/err.h> 115#include <openssl/err.h>
116 116
117#include "bn_lcl.h" 117#include "bn_local.h"
118 118
119/* NB: these functions have been "upgraded", the deprecated versions (which are 119/* NB: these functions have been "upgraded", the deprecated versions (which are
120 * compatibility wrappers using these functions) are in bn_depr.c. 120 * compatibility wrappers using these functions) are in bn_depr.c.
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 4576e25f49..7251e4d831 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_print.c,v 1.36 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.37 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -66,7 +66,7 @@
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/err.h> 67#include <openssl/err.h>
68 68
69#include "bn_lcl.h" 69#include "bn_local.h"
70 70
71static const char Hex[]="0123456789ABCDEF"; 71static const char Hex[]="0123456789ABCDEF";
72 72
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 17f1868350..a03d70053b 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_rand.c,v 1.26 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_rand.c,v 1.27 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -116,7 +116,7 @@
116 116
117#include <openssl/err.h> 117#include <openssl/err.h>
118 118
119#include "bn_lcl.h" 119#include "bn_local.h"
120 120
121static int 121static int
122bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) 122bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c
index 8959f6bd3c..150b588b48 100644
--- a/src/lib/libcrypto/bn/bn_recp.c
+++ b/src/lib/libcrypto/bn/bn_recp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_recp.c,v 1.16 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_recp.c,v 1.17 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,7 +60,7 @@
60 60
61#include <openssl/err.h> 61#include <openssl/err.h>
62 62
63#include "bn_lcl.h" 63#include "bn_local.h"
64 64
65void 65void
66BN_RECP_CTX_init(BN_RECP_CTX *recp) 66BN_RECP_CTX_init(BN_RECP_CTX *recp)
diff --git a/src/lib/libcrypto/bn/bn_shift.c b/src/lib/libcrypto/bn/bn_shift.c
index 6dbaffb194..6f62d6488e 100644
--- a/src/lib/libcrypto/bn/bn_shift.c
+++ b/src/lib/libcrypto/bn/bn_shift.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_shift.c,v 1.16 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_shift.c,v 1.17 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,7 +61,7 @@
61 61
62#include <openssl/err.h> 62#include <openssl/err.h>
63 63
64#include "bn_lcl.h" 64#include "bn_local.h"
65 65
66int 66int
67BN_lshift1(BIGNUM *r, const BIGNUM *a) 67BN_lshift1(BIGNUM *r, const BIGNUM *a)
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 80070831ab..1104c0f2c2 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_sqr.c,v 1.15 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include "bn_lcl.h" 62#include "bn_local.h"
63 63
64/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ 64/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
65int 65int
diff --git a/src/lib/libcrypto/bn/bn_sqrt.c b/src/lib/libcrypto/bn/bn_sqrt.c
index e964c578e3..652dc2b5fc 100644
--- a/src/lib/libcrypto/bn/bn_sqrt.c
+++ b/src/lib/libcrypto/bn/bn_sqrt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_sqrt.c,v 1.13 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_sqrt.c,v 1.14 2022/11/26 16:08:51 tb Exp $ */
2/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * and Bodo Moeller for the OpenSSL project. */ 3 * and Bodo Moeller for the OpenSSL project. */
4/* ==================================================================== 4/* ====================================================================
@@ -57,7 +57,7 @@
57 57
58#include <openssl/err.h> 58#include <openssl/err.h>
59 59
60#include "bn_lcl.h" 60#include "bn_local.h"
61 61
62/* 62/*
63 * Returns 'ret' such that ret^2 == a (mod p), if it exists, using the 63 * Returns 'ret' such that ret^2 == a (mod p), if it exists, using the
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c
index 9719808520..4663237b05 100644
--- a/src/lib/libcrypto/bn/bn_word.c
+++ b/src/lib/libcrypto/bn/bn_word.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_word.c,v 1.15 2022/11/26 13:56:33 jsing Exp $ */ 1/* $OpenBSD: bn_word.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include "bn_lcl.h" 61#include "bn_local.h"
62 62
63BN_ULONG 63BN_ULONG
64BN_mod_word(const BIGNUM *a, BN_ULONG w) 64BN_mod_word(const BIGNUM *a, BN_ULONG w)
diff --git a/src/lib/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c
index 7fc3b5c2ad..b14e9810dd 100644
--- a/src/lib/libcrypto/bn/bn_x931p.c
+++ b/src/lib/libcrypto/bn/bn_x931p.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_x931p.c,v 1.13 2022/01/20 10:56:22 inoguchi Exp $ */ 1/* $OpenBSD: bn_x931p.c,v 1.14 2022/11/26 16:08:51 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/bn.h> 60#include <openssl/bn.h>
61 61
62#include "bn_lcl.h" 62#include "bn_local.h"
63 63
64/* X9.31 routines for prime derivation */ 64/* X9.31 routines for prime derivation */
65 65