98 lines
3.2 KiB
HTML
98 lines
3.2 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_num_bytes</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="#notes">NOTES</a></li>
|
||
|
<li><a href="#see_also">SEE ALSO</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_num_bits, BN_num_bytes, BN_num_bits_word - get BIGNUM size</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
||
|
<pre>
|
||
|
#include <openssl/bn.h></pre>
|
||
|
<pre>
|
||
|
int BN_num_bytes(const BIGNUM *a);</pre>
|
||
|
<pre>
|
||
|
int BN_num_bits(const BIGNUM *a);</pre>
|
||
|
<pre>
|
||
|
int BN_num_bits_word(BN_ULONG w);</pre>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="description">DESCRIPTION</a></h1>
|
||
|
<p><code>BN_num_bytes()</code> returns the size of a <strong>BIGNUM</strong> in bytes.</p>
|
||
|
<p><code>BN_num_bits_word()</code> returns the number of significant bits in a word.
|
||
|
If we take 0x00000432 as an example, it returns 11, not 16, not 32.
|
||
|
Basically, except for a zero, it returns <em>floor(log2(w))+1</em>.</p>
|
||
|
<p><code>BN_num_bits()</code> returns the number of significant bits in a <strong>BIGNUM</strong>,
|
||
|
following the same principle as <code>BN_num_bits_word()</code>.</p>
|
||
|
<p><code>BN_num_bytes()</code> is a macro.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
||
|
<p>The size.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="notes">NOTES</a></h1>
|
||
|
<p>Some have tried using <code>BN_num_bits()</code> on individual numbers in RSA keys,
|
||
|
DH keys and DSA keys, and found that they don't always come up with
|
||
|
the number of bits they expected (something like 512, 1024, 2048,
|
||
|
...). This is because generating a number with some specific number
|
||
|
of bits doesn't always set the highest bits, thereby making the number
|
||
|
of <em>significant</em> bits a little lower. If you want to know the "key
|
||
|
size" of such a key, either use functions like <code>RSA_size()</code>, <code>DH_size()</code>
|
||
|
and <code>DSA_size()</code>, or use <code>BN_num_bytes()</code> and multiply with 8 (although
|
||
|
there's no real guarantee that will match the "key size", just a lot
|
||
|
more probability).</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
||
|
<p><em>DH_size(3)</em>, <em>DSA_size(3)</em>,
|
||
|
<em>RSA_size(3)</em></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>
|