109 lines
4.0 KiB
HTML
Executable File
109 lines
4.0 KiB
HTML
Executable File
<?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_reciprocal</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="#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_reciprocal, BN_div_recp, BN_RECP_CTX_new,
|
|
BN_RECP_CTX_free, BN_RECP_CTX_set - modular multiplication using
|
|
reciprocal</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
<pre>
|
|
#include <openssl/bn.h></pre>
|
|
<pre>
|
|
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
|
void BN_RECP_CTX_free(BN_RECP_CTX *recp);</pre>
|
|
<pre>
|
|
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);</pre>
|
|
<pre>
|
|
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *a, BN_RECP_CTX *recp,
|
|
BN_CTX *ctx);</pre>
|
|
<pre>
|
|
int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
|
|
BN_RECP_CTX *recp, BN_CTX *ctx);</pre>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
<p><code>BN_mod_mul_reciprocal()</code> can be used to perform an efficient
|
|
<em>BN_mod_mul(3)</em> operation when the operation will be performed
|
|
repeatedly with the same modulus. It computes <strong>r</strong>=(<strong>a</strong>*<strong>b</strong>)%<strong>m</strong>
|
|
using <strong>recp</strong>=1/<strong>m</strong>, which is set as described below. <strong>ctx</strong> is a
|
|
previously allocated <strong>BN_CTX</strong> used for temporary variables.</p>
|
|
<p><code>BN_RECP_CTX_new()</code> allocates and initializes a <strong>BN_RECP</strong> structure.</p>
|
|
<p><code>BN_RECP_CTX_free()</code> frees the components of the <strong>BN_RECP</strong>, and, if it
|
|
was created by <code>BN_RECP_CTX_new()</code>, also the structure itself.
|
|
If <strong>recp</strong> is NULL, nothing is done.</p>
|
|
<p><code>BN_RECP_CTX_set()</code> stores <strong>m</strong> in <strong>recp</strong> and sets it up for computing
|
|
1/<strong>m</strong> and shifting it left by BN_num_bits(<strong>m</strong>)+1 to make it an
|
|
integer. The result and the number of bits it was shifted left will
|
|
later be stored in <strong>recp</strong>.</p>
|
|
<p><code>BN_div_recp()</code> divides <strong>a</strong> by <strong>m</strong> using <strong>recp</strong>. It places the quotient
|
|
in <strong>dv</strong> and the remainder in <strong>rem</strong>.</p>
|
|
<p>The <strong>BN_RECP_CTX</strong> structure cannot be shared between threads.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
|
<p><code>BN_RECP_CTX_new()</code> returns the newly allocated <strong>BN_RECP_CTX</strong>, and NULL
|
|
on error.</p>
|
|
<p><code>BN_RECP_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="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_RECP_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>
|