122 lines
4.4 KiB
HTML
122 lines
4.4 KiB
HTML
|
<?xml version="1.0" ?>
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<title>BN_mod_mul_montgomery</title>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||
|
<link rev="made" href="mailto:root@localhost" />
|
||
|
</head>
|
||
|
|
||
|
<body style="background-color: white">
|
||
|
|
||
|
|
||
|
<!-- INDEX BEGIN -->
|
||
|
<div name="index">
|
||
|
<p><a name="__index__"></a></p>
|
||
|
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#name">NAME</a></li>
|
||
|
<li><a href="#synopsis">SYNOPSIS</a></li>
|
||
|
<li><a href="#description">DESCRIPTION</a></li>
|
||
|
<li><a href="#return_values">RETURN VALUES</a></li>
|
||
|
<li><a href="#warnings">WARNINGS</a></li>
|
||
|
<li><a href="#see_also">SEE ALSO</a></li>
|
||
|
<li><a href="#history">HISTORY</a></li>
|
||
|
<li><a href="#copyright">COPYRIGHT</a></li>
|
||
|
</ul>
|
||
|
|
||
|
<hr name="index" />
|
||
|
</div>
|
||
|
<!-- INDEX END -->
|
||
|
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="name">NAME</a></h1>
|
||
|
<p>BN_mod_mul_montgomery, BN_MONT_CTX_new,
|
||
|
BN_MONT_CTX_free, BN_MONT_CTX_set, BN_MONT_CTX_copy,
|
||
|
BN_from_montgomery, BN_to_montgomery - Montgomery multiplication</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
||
|
<pre>
|
||
|
#include <openssl/bn.h></pre>
|
||
|
<pre>
|
||
|
BN_MONT_CTX *BN_MONT_CTX_new(void);
|
||
|
void BN_MONT_CTX_free(BN_MONT_CTX *mont);</pre>
|
||
|
<pre>
|
||
|
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
|
||
|
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);</pre>
|
||
|
<pre>
|
||
|
int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
|
||
|
BN_MONT_CTX *mont, BN_CTX *ctx);</pre>
|
||
|
<pre>
|
||
|
int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
|
||
|
BN_CTX *ctx);</pre>
|
||
|
<pre>
|
||
|
int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
|
||
|
BN_CTX *ctx);</pre>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="description">DESCRIPTION</a></h1>
|
||
|
<p>These functions implement Montgomery multiplication. They are used
|
||
|
automatically when <em>BN_mod_exp(3)</em> is called with suitable input,
|
||
|
but they may be useful when several operations are to be performed
|
||
|
using the same modulus.</p>
|
||
|
<p><code>BN_MONT_CTX_new()</code> allocates and initializes a <strong>BN_MONT_CTX</strong> structure.</p>
|
||
|
<p><code>BN_MONT_CTX_set()</code> sets up the <em>mont</em> structure from the modulus <em>m</em>
|
||
|
by precomputing its inverse and a value R.</p>
|
||
|
<p><code>BN_MONT_CTX_copy()</code> copies the <strong>BN_MONT_CTX</strong> <em>from</em> to <em>to</em>.</p>
|
||
|
<p><code>BN_MONT_CTX_free()</code> frees the components of the <strong>BN_MONT_CTX</strong>, and, if
|
||
|
it was created by <code>BN_MONT_CTX_new()</code>, also the structure itself.
|
||
|
If <strong>mont</strong> is NULL, nothing is done.</p>
|
||
|
<p><code>BN_mod_mul_montgomery()</code> computes Mont(<em>a</em>,<em>b</em>):=<em>a</em>*<em>b</em>*R^-1 and places
|
||
|
the result in <em>r</em>.</p>
|
||
|
<p><code>BN_from_montgomery()</code> performs the Montgomery reduction <em>r</em> = <em>a</em>*R^-1.</p>
|
||
|
<p><code>BN_to_montgomery()</code> computes Mont(<em>a</em>,R^2), i.e. <em>a</em>*R.
|
||
|
Note that <em>a</em> must be non-negative and smaller than the modulus.</p>
|
||
|
<p>For all functions, <em>ctx</em> is a previously allocated <strong>BN_CTX</strong> used for
|
||
|
temporary variables.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
||
|
<p><code>BN_MONT_CTX_new()</code> returns the newly allocated <strong>BN_MONT_CTX</strong>, and NULL
|
||
|
on error.</p>
|
||
|
<p><code>BN_MONT_CTX_free()</code> has no return value.</p>
|
||
|
<p>For the other functions, 1 is returned for success, 0 on error.
|
||
|
The error codes can be obtained by <em>ERR_get_error(3)</em>.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="warnings">WARNINGS</a></h1>
|
||
|
<p>The inputs must be reduced modulo <strong>m</strong>, otherwise the result will be
|
||
|
outside the expected range.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
||
|
<p><em>ERR_get_error(3)</em>, <em>BN_add(3)</em>,
|
||
|
<em>BN_CTX_new(3)</em></p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="history">HISTORY</a></h1>
|
||
|
<p><code>BN_MONT_CTX_init()</code> was removed in OpenSSL 1.1.0</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
||
|
<p>Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.</p>
|
||
|
<p>Licensed under the Apache License 2.0 (the "License"). You may not use
|
||
|
this file except in compliance with the License. You can obtain a copy
|
||
|
in the file LICENSE in the source distribution or at
|
||
|
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|