BN_NUM_BYTES - Online Linux Manual PageSection : 3ossl
Updated : 2022-03-15
Source : 3.0.2
Note : OpenSSL

NAMEBN_num_bits, BN_num_bytes, BN_num_bits_word − get BIGNUM size

SYNOPSIS​ #include <openssl/bn.h> ​ ​ int BN_num_bytes(const BIGNUM *a); ​ ​ int BN_num_bits(const BIGNUM *a); ​ ​ int BN_num_bits_word(BN_ULONG w);

DESCRIPTIONBN_num_bytes() returns the size of a BIGNUM in bytes. BN_num_bits_word() 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 floor(log2(w))+1. BN_num_bits() returns the number of significant bits in a BIGNUM, following the same principle as BN_num_bits_word(). BN_num_bytes() is a macro.

RETURN VALUESThe size.

NOTESSome have tried using BN_num_bits() 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 significant bits a little lower. If you want to know the key size of such a key, either use functions like RSA_size(), DH_size() and DSA_size(), or use BN_num_bytes() and multiply with 8 (although there's no real guarantee that will match the key size, just a lot more probability).

SEE ALSODH_size(3), DSA_size(3), ​RSA_size(3)

COPYRIGHTCopyright 2000−2017 The OpenSSL Project Authors. All Rights Reserved. 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 <https://www.openssl.org/source/license.html>.
0
Johanes Gumabo
Data Size   :   7,579 byte
man-BN_num_bits_word.3osslBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 169,996
Visitor ID   :     :  
Visitor IP   :   3.141.45.90   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|B___N_num_bits.3ossl|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|B___N_num_bits.3ossl|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|B___N_num_bits.3ossl|43|br══─}─══|'br══─}─══ )         (htmlprn|149|B___N_num_bits.3ossl|43|'br══─}─══ |'br══─}─══ )