/usr/share/doc/libbotan-2-doc/manual/bigint.html is in libbotan-2-doc 2.4.0-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BigInt — Botan</title>
<link rel="stylesheet" href="_static/agogo.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.4.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Key Derivation Functions" href="kdf.html" />
<link rel="prev" title="Credentials Manager" href="credentials_manager.html" />
</head>
<body>
<div class="header-wrapper">
<div class="header">
<h1>Botan</h1>
</div>
</div>
<div class="content-wrapper">
<div class="content">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="bigint">
<h1>BigInt<a class="headerlink" href="#bigint" title="Permalink to this headline">¶</a></h1>
<p><code class="docutils literal"><span class="pre">BigInt</span></code> is Botan’s implementation of a multiple-precision
integer. Thanks to C++’s operator overloading features, using
<code class="docutils literal"><span class="pre">BigInt</span></code> is often quite similar to using a native integer type. The
number of functions related to <code class="docutils literal"><span class="pre">BigInt</span></code> is quite large. You can find
most of them in <code class="docutils literal"><span class="pre">botan/bigint.h</span></code> and <code class="docutils literal"><span class="pre">botan/numthry.h</span></code>.</p>
<div class="section" id="encoding-functions">
<h2>Encoding Functions<a class="headerlink" href="#encoding-functions" title="Permalink to this headline">¶</a></h2>
<p>These transform the normal representation of a <code class="docutils literal"><span class="pre">BigInt</span></code> into some
other form, such as a decimal string:</p>
<dl class="function">
<dt id="_CPPv2N6BigInt6encodeERK6BigInt8Encoding">
<span id="BigInt::encode__BigIntCR.Encoding"></span>secure_vector<uint8_t> <code class="descclassname">BigInt::</code><code class="descname">encode</code><span class="sig-paren">(</span><em class="property">const</em> BigInt &<em>n</em>, Encoding <em>enc</em> = Binary<span class="sig-paren">)</span><a class="headerlink" href="#_CPPv2N6BigInt6encodeERK6BigInt8Encoding" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>This function encodes the BigInt n into a memory
vector. <code class="docutils literal"><span class="pre">Encoding</span></code> is an enum that has values <code class="docutils literal"><span class="pre">Binary</span></code>,
<code class="docutils literal"><span class="pre">Decimal</span></code>, and <code class="docutils literal"><span class="pre">Hexadecimal</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv2N6BigInt6decodeERKNSt6vectorI7uint8_tEE8Encoding">
<span id="BigInt::decode__std::vector:uint8_t:CR.Encoding"></span>BigInt <code class="descclassname">BigInt::</code><code class="descname">decode</code><span class="sig-paren">(</span><em class="property">const</em> std::vector<uint8_t> &<em>vec</em>, Encoding <em>enc</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv2N6BigInt6decodeERKNSt6vectorI7uint8_tEE8Encoding" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Decode the integer from <code class="docutils literal"><span class="pre">vec</span></code> using the encoding specified.</p>
</dd></dl>
<p>These functions are static member functions, so they would be called
like this:</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="n">BigInt</span> <span class="n">n1</span> <span class="o">=</span> <span class="p">...;</span> <span class="c1">// some number</span>
<span class="n">secure_vector</span><span class="o"><</span><span class="kt">uint8_t</span><span class="o">></span> <span class="n">n1_encoded</span> <span class="o">=</span> <span class="n">BigInt</span><span class="o">::</span><span class="n">encode</span><span class="p">(</span><span class="n">n1</span><span class="p">);</span>
<span class="n">BigInt</span> <span class="n">n2</span> <span class="o">=</span> <span class="n">BigInt</span><span class="o">::</span><span class="n">decode</span><span class="p">(</span><span class="n">n1_encoded</span><span class="p">);</span>
<span class="n">assert</span><span class="p">(</span><span class="n">n1</span> <span class="o">==</span> <span class="n">n2</span><span class="p">);</span>
</pre></div>
</div>
<p>There are also C++-style I/O operators defined for use with
<code class="docutils literal"><span class="pre">BigInt</span></code>. The input operator understands negative numbers and
hexadecimal numbers (marked with a leading “0x”). The ‘-‘ must come
before the “0x” marker. The output operator will never adorn the
output; for example, when printing a hexadecimal number, there will
not be a leading “0x” (though a leading ‘-‘ will be printed if the
number is negative). If you want such things, you’ll have to do them
yourself.</p>
<p><code class="docutils literal"><span class="pre">BigInt</span></code> has constructors that can create a <code class="docutils literal"><span class="pre">BigInt</span></code> from an
unsigned integer or a string. You can also decode an array (a <code class="docutils literal"><span class="pre">byte</span></code>
pointer plus a length) into a <code class="docutils literal"><span class="pre">BigInt</span></code> using a constructor.</p>
</div>
<div class="section" id="number-theory">
<h2>Number Theory<a class="headerlink" href="#number-theory" title="Permalink to this headline">¶</a></h2>
<p>Number theoretic functions available include:</p>
<dl class="function">
<dt id="_CPPv23gcd6BigInt6BigInt">
<span id="gcd__BigInt.BigInt"></span>BigInt <code class="descclassname"></code><code class="descname">gcd</code><span class="sig-paren">(</span>BigInt <em>x</em>, BigInt <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv23gcd6BigInt6BigInt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Returns the greatest common divisor of x and y</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv23lcm6BigInt6BigInt">
<span id="lcm__BigInt.BigInt"></span>BigInt <code class="descclassname"></code><code class="descname">lcm</code><span class="sig-paren">(</span>BigInt <em>x</em>, BigInt <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv23lcm6BigInt6BigInt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Returns an integer z which is the smallest integer such that z % x
== 0 and z % y == 0</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv211inverse_mod6BigInt6BigInt">
<span id="inverse_mod__BigInt.BigInt"></span>BigInt <code class="descclassname"></code><code class="descname">inverse_mod</code><span class="sig-paren">(</span>BigInt <em>x</em>, BigInt <em>m</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv211inverse_mod6BigInt6BigInt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Returns the modular inverse of x modulo m, that is, an integer
y such that (x*y) % m == 1. If no such y exists, returns zero.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv29power_mod6BigInt6BigInt6BigInt">
<span id="power_mod__BigInt.BigInt.BigInt"></span>BigInt <code class="descclassname"></code><code class="descname">power_mod</code><span class="sig-paren">(</span>BigInt <em>b</em>, BigInt <em>x</em>, BigInt <em>m</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv29power_mod6BigInt6BigInt6BigInt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Returns b to the xth power modulo m. If you are doing many
exponentiations with a single fixed modulus, it is faster to use a
<code class="docutils literal"><span class="pre">Power_Mod</span></code> implementation.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv26ressol6BigInt6BigInt">
<span id="ressol__BigInt.BigInt"></span>BigInt <code class="descclassname"></code><code class="descname">ressol</code><span class="sig-paren">(</span>BigInt <em>x</em>, BigInt <em>p</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv26ressol6BigInt6BigInt" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Returns the square root modulo a prime, that is, returns a number y
such that (y*y) % p == x. Returns -1 if no such integer exists.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv28is_prime6BigIntR21RandomNumberGenerator6size_td">
<span id="is_prime__BigInt.RandomNumberGeneratorR.s.double"></span>bool <code class="descclassname"></code><code class="descname">is_prime</code><span class="sig-paren">(</span>BigInt <em>n</em>, RandomNumberGenerator &<em>rng</em>, size_t <em>prob</em> = 56, double <em>is_random</em> = false<span class="sig-paren">)</span><a class="headerlink" href="#_CPPv28is_prime6BigIntR21RandomNumberGenerator6size_td" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Test <em>n</em> for primality using a probablistic algorithm (Miller-Rabin). With
this algorithm, there is some non-zero probability that true will be returned
even if <em>n</em> is actually composite. Modifying <em>prob</em> allows you to decrease the
chance of such a false positive, at the cost of increased runtime. Sufficient
tests will be run such that the chance <em>n</em> is composite is no more than 1 in
2<sup>prob</sup>. Set <em>is_random</em> to true if (and only if) <em>n</em> was randomly
chosen (ie, there is no danger it was chosen maliciously) as far fewer tests
are needed in that case.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv217quick_check_prime6BigIntR21RandomNumberGenerator">
<span id="quick_check_prime__BigInt.RandomNumberGeneratorR"></span>bool <code class="descclassname"></code><code class="descname">quick_check_prime</code><span class="sig-paren">(</span>BigInt <em>n</em>, RandomNumberGenerator &<em>rng</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv217quick_check_prime6BigIntR21RandomNumberGenerator" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>
<dl class="function">
<dt id="_CPPv211check_prime6BigIntR21RandomNumberGenerator">
<span id="check_prime__BigInt.RandomNumberGeneratorR"></span>bool <code class="descclassname"></code><code class="descname">check_prime</code><span class="sig-paren">(</span>BigInt <em>n</em>, RandomNumberGenerator &<em>rng</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv211check_prime6BigIntR21RandomNumberGenerator" title="Permalink to this definition">¶</a><br /></dt>
<dd></dd></dl>
<dl class="function">
<dt id="_CPPv212verify_prime6BigIntR21RandomNumberGenerator">
<span id="verify_prime__BigInt.RandomNumberGeneratorR"></span>bool <code class="descclassname"></code><code class="descname">verify_prime</code><span class="sig-paren">(</span>BigInt <em>n</em>, RandomNumberGenerator &<em>rng</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv212verify_prime6BigIntR21RandomNumberGenerator" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Three variations on <em>is_prime</em>, with probabilities set to 32, 56, and 80
respectively.</p>
</dd></dl>
<dl class="function">
<dt id="_CPPv212random_primeR21RandomNumberGenerator6size_t6BigInt6size_t6size_t">
<span id="random_prime__RandomNumberGeneratorR.s.BigInt.s.s"></span>BigInt <code class="descclassname"></code><code class="descname">random_prime</code><span class="sig-paren">(</span>RandomNumberGenerator &<em>rng</em>, size_t <em>bits</em>, BigInt <em>coprime</em> = 1, size_t <em>equiv</em> = 1, size_t <em>equiv_mod</em> = 2<span class="sig-paren">)</span><a class="headerlink" href="#_CPPv212random_primeR21RandomNumberGenerator6size_t6BigInt6size_t6size_t" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Return a random prime number of <code class="docutils literal"><span class="pre">bits</span></code> bits long that is
relatively prime to <code class="docutils literal"><span class="pre">coprime</span></code>, and equivalent to <code class="docutils literal"><span class="pre">equiv</span></code> modulo
<code class="docutils literal"><span class="pre">equiv_mod</span></code>.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar">
<h3>Table Of Contents</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="goals.html">Project Goals</a></li>
<li class="toctree-l1"><a class="reference internal" href="support.html">Support Information</a></li>
<li class="toctree-l1"><a class="reference internal" href="building.html">Building The Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="versions.html">Versioning</a></li>
<li class="toctree-l1"><a class="reference internal" href="secmem.html">Memory container</a></li>
<li class="toctree-l1"><a class="reference internal" href="rng.html">Random Number Generators</a></li>
<li class="toctree-l1"><a class="reference internal" href="hash.html">Hash Functions and Checksums</a></li>
<li class="toctree-l1"><a class="reference internal" href="block_cipher.html">Block Ciphers</a></li>
<li class="toctree-l1"><a class="reference internal" href="stream_ciphers.html">Stream Ciphers</a></li>
<li class="toctree-l1"><a class="reference internal" href="message_auth_codes.html">Message Authentication Codes (MAC)</a></li>
<li class="toctree-l1"><a class="reference internal" href="cipher_modes.html">Cipher Modes</a></li>
<li class="toctree-l1"><a class="reference internal" href="pubkey.html">Public Key Cryptography</a></li>
<li class="toctree-l1"><a class="reference internal" href="x509.html">X.509 Certificates and CRLs</a></li>
<li class="toctree-l1"><a class="reference internal" href="tls.html">Transport Layer Security (TLS)</a></li>
<li class="toctree-l1"><a class="reference internal" href="credentials_manager.html">Credentials Manager</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">BigInt</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#encoding-functions">Encoding Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#number-theory">Number Theory</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="kdf.html">Key Derivation Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pbkdf.html">PBKDF Algorithms</a></li>
<li class="toctree-l1"><a class="reference internal" href="keywrap.html">AES Key Wrapping</a></li>
<li class="toctree-l1"><a class="reference internal" href="passhash.html">Password Hashing</a></li>
<li class="toctree-l1"><a class="reference internal" href="cryptobox.html">Cryptobox</a></li>
<li class="toctree-l1"><a class="reference internal" href="srp.html">Secure Remote Password</a></li>
<li class="toctree-l1"><a class="reference internal" href="psk_db.html">PSK Database</a></li>
<li class="toctree-l1"><a class="reference internal" href="filters.html">Pipe/Filter Message Processing</a></li>
<li class="toctree-l1"><a class="reference internal" href="fpe.html">Format Preserving Encryption</a></li>
<li class="toctree-l1"><a class="reference internal" href="compression.html">Lossless Data Compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="pkcs11.html">PKCS#11</a></li>
<li class="toctree-l1"><a class="reference internal" href="tpm.html">Trusted Platform Module (TPM)</a></li>
<li class="toctree-l1"><a class="reference internal" href="otp.html">One Time Passwords</a></li>
<li class="toctree-l1"><a class="reference internal" href="ffi.html">FFI (C89) Interface</a></li>
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Binding</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli.html">botan</a></li>
<li class="toctree-l1"><a class="reference internal" href="side_channels.html">Side Channels</a></li>
<li class="toctree-l1"><a class="reference internal" href="packaging.html">Notes for Distributors</a></li>
<li class="toctree-l1"><a class="reference internal" href="fuzzing.html">Fuzzing The Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="deprecated.html">Deprecated Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="abi.html">ABI Stability</a></li>
</ul>
<div role="search">
<h3 style="margin-top: 1.5em;">Search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div class="footer-wrapper">
<div class="footer">
<div class="left">
<div role="navigation" aria-label="related navigaton">
<a href="credentials_manager.html" title="Credentials Manager"
accesskey="P">previous</a> |
<a href="kdf.html" title="Key Derivation Functions"
accesskey="N">next</a> |
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |
<a href="genindex.html" title="General Index"
accesskey="I">index</a>
</div>
<div role="note" aria-label="source link">
</div>
</div>
<div class="right">
<div class="footer" role="contentinfo">
Last updated on 2018-04-08.
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</body>
</html>
|