summaryrefslogtreecommitdiffstats
path: root/secure/lib/libcrypto/man/BN_num_bytes.3
diff options
context:
space:
mode:
Diffstat (limited to 'secure/lib/libcrypto/man/BN_num_bytes.3')
-rw-r--r--secure/lib/libcrypto/man/BN_num_bytes.366
1 files changed, 39 insertions, 27 deletions
diff --git a/secure/lib/libcrypto/man/BN_num_bytes.3 b/secure/lib/libcrypto/man/BN_num_bytes.3
index 674a5e0..6fe4ec8 100644
--- a/secure/lib/libcrypto/man/BN_num_bytes.3
+++ b/secure/lib/libcrypto/man/BN_num_bytes.3
@@ -1,8 +1,7 @@
-.\" Automatically generated by Pod::Man version 1.15
-.\" Wed Mar 17 09:38:31 2004
+.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
-.\" ======================================================================
+.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
@@ -15,12 +14,6 @@
.if t .sp .5v
.if n .sp
..
-.de Ip \" List item
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
.de Vb \" Begin verbatim text
.ft CW
.nf
@@ -28,15 +21,14 @@
..
.de Ve \" End verbatim text
.ft R
-
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
-.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
-.\" to do unbreakable dashes and therefore won't be available. \*(C` and
-.\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
+.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
+.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
+.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
@@ -56,10 +48,10 @@
. ds R" ''
'br\}
.\"
-.\" If the F register is turned on, we'll generate index entries on stderr
-.\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
-.\" index entries marked with X<> in POD. Of course, you'll have to process
-.\" the output yourself in some meaningful fashion.
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD. Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
@@ -68,14 +60,13 @@
. rr F
.\}
.\"
-.\" For nroff, turn off justification. Always turn off hyphenation; it
-.\" makes way too many mistakes in technical documents.
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
-.bd B 3
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
@@ -135,39 +126,60 @@
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
-.\" ======================================================================
+.\" ========================================================================
.\"
.IX Title "BN_num_bytes 3"
-.TH BN_num_bytes 3 "0.9.7d" "2004-03-17" "OpenSSL"
-.UC
+.TH BN_num_bytes 3 "2005-02-24" "0.9.7d" "OpenSSL"
.SH "NAME"
-BN_num_bits, BN_num_bytes, BN_num_bits_word \- get \s-1BIGNUM\s0 size
+BN_num_bits, BN_num_bytes, BN_num_bits_word \- get BIGNUM size
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& #include <openssl/bn.h>
.Ve
+.PP
.Vb 1
\& int BN_num_bytes(const BIGNUM *a);
.Ve
+.PP
.Vb 1
\& int BN_num_bits(const BIGNUM *a);
.Ve
+.PP
.Vb 1
\& int BN_num_bits_word(BN_ULONG w);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
-These functions return the size of a \fB\s-1BIGNUM\s0\fR in bytes or bits,
-and the size of an unsigned integer in bits.
+\&\fIBN_num_bytes()\fR returns the size of a \fB\s-1BIGNUM\s0\fR in bytes.
+.PP
+\&\fIBN_num_bits_word()\fR 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 \fIfloor(log2(w))+1\fR.
+.PP
+\&\fIBN_num_bits()\fR returns the number of significant bits in a \fB\s-1BIGNUM\s0\fR,
+following the same principle as \fIBN_num_bits_word()\fR.
.PP
\&\fIBN_num_bytes()\fR is a macro.
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
The size.
+.SH "NOTES"
+.IX Header "NOTES"
+Some have tried using \fIBN_num_bits()\fR on individual numbers in \s-1RSA\s0 keys,
+\&\s-1DH\s0 keys and \s-1DSA\s0 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 \fIsignificant\fR bits a little lower. If you want to know the \*(L"key
+size\*(R" of such a key, either use functions like \fIRSA_size()\fR, \fIDH_size()\fR
+and \fIDSA_size()\fR, or use \fIBN_num_bytes()\fR and multiply with 8 (although
+there's no real guarantee that will match the \*(L"key size\*(R", just a lot
+more probability).
.SH "SEE ALSO"
.IX Header "SEE ALSO"
-bn(3)
+\&\fIbn\fR\|(3), \fIDH_size\fR\|(3), \fIDSA_size\fR\|(3),
+\&\fIRSA_size\fR\|(3)
.SH "HISTORY"
.IX Header "HISTORY"
\&\fIBN_num_bytes()\fR, \fIBN_num_bits()\fR and \fIBN_num_bits_word()\fR are available in
OpenPOWER on IntegriCloud