diff options
Diffstat (limited to 'src/lib/libcrypto/man/BN_num_bytes.3')
| -rw-r--r-- | src/lib/libcrypto/man/BN_num_bytes.3 | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_num_bytes.3 b/src/lib/libcrypto/man/BN_num_bytes.3 new file mode 100644 index 0000000000..2d7be7e443 --- /dev/null +++ b/src/lib/libcrypto/man/BN_num_bytes.3 | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | .Dd $Mdocdate: February 23 2015 $ | ||
| 2 | .Dt BN_NUM_BYTES 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm BN_num_bits , | ||
| 6 | .Nm BN_num_bytes , | ||
| 7 | .Nm BN_num_bits_word | ||
| 8 | .Nd get BIGNUM size | ||
| 9 | .Sh SYNOPSIS | ||
| 10 | .In openssl/bn.h | ||
| 11 | .Ft int | ||
| 12 | .Fo BN_num_bytes | ||
| 13 | .Fa "const BIGNUM *a" | ||
| 14 | .Fc | ||
| 15 | .Ft int | ||
| 16 | .Fo BN_num_bits | ||
| 17 | .Fa "const BIGNUM *a" | ||
| 18 | .Fc | ||
| 19 | .Ft int | ||
| 20 | .Fo BN_num_bits_word | ||
| 21 | .Fa "BN_ULONG w" | ||
| 22 | .Fc | ||
| 23 | .Sh DESCRIPTION | ||
| 24 | .Fn BN_num_bytes | ||
| 25 | returns the size of a | ||
| 26 | .Sy BIGNUM | ||
| 27 | in bytes. | ||
| 28 | .Pp | ||
| 29 | .Fn BN_num_bits_word | ||
| 30 | returns the number of significant bits in a word. | ||
| 31 | If we take 0x00000432 as an example, it returns 11, not 16, not 32. | ||
| 32 | Basically, except for a zero, it returns | ||
| 33 | .Pp | ||
| 34 | .D1 floor(log2( Ns Fa w ) ) No + 1 . | ||
| 35 | .Pp | ||
| 36 | .Fn BN_num_bits | ||
| 37 | returns the number of significant bits in a | ||
| 38 | .Sy BIGNUM , | ||
| 39 | following the same principle as | ||
| 40 | .Fn BN_num_bits_word . | ||
| 41 | .Pp | ||
| 42 | .Fn BN_num_bytes | ||
| 43 | is a macro. | ||
| 44 | .Sh RETURN VALUES | ||
| 45 | The size. | ||
| 46 | .Sh NOTES | ||
| 47 | Some have tried using | ||
| 48 | .Fn BN_num_bits | ||
| 49 | on individual numbers in RSA keys, DH keys and DSA keys, and found that | ||
| 50 | they don't always come up with the number of bits they expected | ||
| 51 | (something like 512, 1024, 2048, ...). This is because generating a | ||
| 52 | number with some specific number of bits doesn't always set the highest | ||
| 53 | bits, thereby making the number of | ||
| 54 | .Em significant | ||
| 55 | bits a little lower. | ||
| 56 | If you want to know the "key size" of such a key, either use functions | ||
| 57 | like | ||
| 58 | .Xr RSA_size 3 , | ||
| 59 | .Xr DH_size 3 , | ||
| 60 | and | ||
| 61 | .Xr DSA_size 3 , | ||
| 62 | or use | ||
| 63 | .Fn BN_num_bytes | ||
| 64 | and multiply with 8 (although there's no real guarantee that will match | ||
| 65 | the "key size", just a lot more probability). | ||
| 66 | .Sh SEE ALSO | ||
| 67 | .Xr bn 3 , | ||
| 68 | .Xr DH_size 3 , | ||
| 69 | .Xr DSA_size 3 , | ||
| 70 | .Xr RSA_size 3 | ||
| 71 | .Sh HISTORY | ||
| 72 | .Fn BN_num_bytes , | ||
| 73 | .Fn BN_num_bits , | ||
| 74 | and | ||
| 75 | .Fn BN_num_bits_word | ||
| 76 | are available in all versions of SSLeay and OpenSSL. | ||
