Botan 1.10.17
Botan::OSSL_BN Class Reference

#include <bn_wrap.h>

Public Member Functions

size_t bytes () const
void encode (byte[], size_t) const
OSSL_BNoperator= (const OSSL_BN &)
 OSSL_BN (const BigInt &=0)
 OSSL_BN (const byte[], size_t)
 OSSL_BN (const OSSL_BN &)
BigInt to_bigint () const
SecureVector< byteto_bytes () const
 ~OSSL_BN ()

Public Attributes

BIGNUM * value

Detailed Description

Lightweight OpenSSL BN wrapper. For internal use only.

Definition at line 19 of file bn_wrap.h.

Constructor & Destructor Documentation

◆ OSSL_BN() [1/3]

Botan::OSSL_BN::OSSL_BN ( const OSSL_BN & other)

Definition at line 35 of file bn_wrap.cpp.

36 {
37 value = BN_dup(other.value);
38 }
BIGNUM * value
Definition bn_wrap.h:22

References OSSL_BN(), and value.

Referenced by operator=(), and OSSL_BN().

◆ OSSL_BN() [2/3]

Botan::OSSL_BN::OSSL_BN ( const BigInt & in = 0)

Definition at line 15 of file bn_wrap.cpp.

16 {
17 value = BN_new();
18 SecureVector<byte> encoding = BigInt::encode(in);
19 if(in != 0)
20 BN_bin2bn(encoding, encoding.size(), value);
21 }
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition big_code.cpp:64

References Botan::BigInt::encode(), Botan::MemoryRegion< T >::size(), and value.

◆ OSSL_BN() [3/3]

Botan::OSSL_BN::OSSL_BN ( const byte in[],
size_t length )

Definition at line 26 of file bn_wrap.cpp.

27 {
28 value = BN_new();
29 BN_bin2bn(in, length, value);
30 }

References value.

◆ ~OSSL_BN()

Botan::OSSL_BN::~OSSL_BN ( )

Definition at line 43 of file bn_wrap.cpp.

44 {
45 BN_clear_free(value);
46 }

References value.

Member Function Documentation

◆ bytes()

size_t Botan::OSSL_BN::bytes ( ) const

Definition at line 68 of file bn_wrap.cpp.

69 {
70 return BN_num_bytes(value);
71 }

References value.

Referenced by encode(), and to_bigint().

◆ encode()

void Botan::OSSL_BN::encode ( byte out[],
size_t length ) const

Definition at line 60 of file bn_wrap.cpp.

61 {
62 BN_bn2bin(value, out + (length - bytes()));
63 }
size_t bytes() const
Definition bn_wrap.cpp:68

References bytes(), and value.

◆ operator=()

OSSL_BN & Botan::OSSL_BN::operator= ( const OSSL_BN & other)

Definition at line 51 of file bn_wrap.cpp.

52 {
53 BN_copy(value, other.value);
54 return (*this);
55 }

References OSSL_BN(), and value.

◆ to_bigint()

BigInt Botan::OSSL_BN::to_bigint ( ) const

Definition at line 76 of file bn_wrap.cpp.

77 {
78 SecureVector<byte> out(bytes());
79 BN_bn2bin(value, out);
80 return BigInt::decode(out);
81 }
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition big_code.cpp:102

References bytes(), Botan::BigInt::decode(), and value.

Referenced by to_bytes().

◆ to_bytes()

SecureVector< byte > Botan::OSSL_BN::to_bytes ( ) const
inline

Definition at line 28 of file bn_wrap.h.

29 { return BigInt::encode(to_bigint()); }
BigInt to_bigint() const
Definition bn_wrap.cpp:76

References Botan::BigInt::encode(), and to_bigint().

Member Data Documentation

◆ value

BIGNUM* Botan::OSSL_BN::value

Definition at line 22 of file bn_wrap.h.

Referenced by bytes(), encode(), operator=(), OSSL_BN(), OSSL_BN(), OSSL_BN(), to_bigint(), and ~OSSL_BN().


The documentation for this class was generated from the following files: