From: schwarze Date: Tue, 21 Dec 2021 11:14:07 +0000 (+0000) Subject: document BN_MONT_CTX_set_locked(3) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3de09c26cd5c245ac3554c58b815a64a4ee34f8c;p=openbsd document BN_MONT_CTX_set_locked(3) --- diff --git a/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/lib/libcrypto/man/BN_mod_mul_montgomery.3 index 963ba8fcd46..7b22efd7f59 100644 --- a/lib/libcrypto/man/BN_mod_mul_montgomery.3 +++ b/lib/libcrypto/man/BN_mod_mul_montgomery.3 @@ -1,7 +1,25 @@ -.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.13 2021/12/06 19:45:27 schwarze Exp $ -.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 +.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.14 2021/12/21 11:14:07 schwarze Exp $ +.\" full merge up to: OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 +.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" -.\" This file was written by Ulf Moeller . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2021 Ingo Schwarze +.\" +.\" 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. +.\" +.\" The original file was written by Ulf Moeller . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -48,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 6 2021 $ +.Dd $Mdocdate: December 21 2021 $ .Dt BN_MOD_MUL_MONTGOMERY 3 .Os .Sh NAME @@ -56,6 +74,7 @@ .Nm BN_MONT_CTX_init , .Nm BN_MONT_CTX_free , .Nm BN_MONT_CTX_set , +.Nm BN_MONT_CTX_set_locked , .Nm BN_MONT_CTX_copy , .Nm BN_mod_mul_montgomery , .Nm BN_from_montgomery , @@ -82,6 +101,13 @@ .Fa "BN_CTX *ctx" .Fc .Ft BN_MONT_CTX * +.Fo BN_MONT_CTX_set_locked +.Fa "BN_MONT_CTX **pmont" +.Fa "int lock" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Ft BN_MONT_CTX * .Fo BN_MONT_CTX_copy .Fa "BN_MONT_CTX *to" .Fa "BN_MONT_CTX *from" @@ -133,6 +159,37 @@ structure from the modulus .Fa m by precomputing its inverse and a value R. .Pp +.Fn BN_MONT_CTX_set_locked +is a wrapper around +.Fn BN_MONT_CTX_new +and +.Fn BN_MONT_CTX_set +that is useful if more than one thread intends to use the same +.Vt BN_MONT_CTX +and none of these threads is exclusively responsible for creating +and initializing the context. +.Fn BN_MONT_CTX_set_locked +first acquires the specified +.Fa lock +using +.Xr CRYPTO_lock 3 . +If +.Pf * Fa pmont +already differs from +.Dv NULL , +no action occurs. +Otherwise, a new +.Vt BN_MONT_CTX +is allocated with +.Fn BN_MONT_CTX_new , +set up with +.Fn BN_MONT_CTX_set , +and a pointer to it is stored in +.Pf * Fa pmont . +Finally, the +.Fa lock +is released. +.Pp .Fn BN_MONT_CTX_copy copies the .Vt BN_MONT_CTX @@ -207,13 +264,19 @@ or .Dv NULL on error. .Pp +.Fn BN_MONT_CTX_set_locked +returns a pointer to the existing or newly created context or +.Dv NULL +on error. +.Pp For the other functions, 1 is returned for success or 0 on error. The error codes can be obtained by .Xr ERR_get_error 3 . .Sh SEE ALSO .Xr BN_add 3 , .Xr BN_CTX_new 3 , -.Xr BN_new 3 +.Xr BN_new 3 , +.Xr CRYPTO_lock 3 .Sh HISTORY .Fn BN_MONT_CTX_new , .Fn BN_MONT_CTX_free , @@ -230,6 +293,10 @@ and .Fn BN_MONT_CTX_copy first appeared in SSLeay 0.9.1 and have been available since .Ox 2.6 . +.Pp +.Fn BN_MONT_CTX_set_locked +first appeared in OpenSSL 0.9.8 and has been available since +.Ox 4.0 . .Sh CAVEATS .Fn BN_MONT_CTX_init must not be called on a context that was used previously, or