Botan  1.10.9
Public Member Functions | Public Attributes | List of all members
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 OSSL_BN &)
 
 OSSL_BN (const BigInt &=0)
 
 OSSL_BN (const byte[], size_t)
 
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

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

Definition at line 35 of file bn_wrap.cpp.

References value.

36  {
37  value = BN_dup(other.value);
38  }
BIGNUM * value
Definition: bn_wrap.h:22
Botan::OSSL_BN::OSSL_BN ( const BigInt in = 0)

Definition at line 15 of file bn_wrap.cpp.

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

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
BIGNUM * value
Definition: bn_wrap.h:22
Botan::OSSL_BN::OSSL_BN ( const byte  in[],
size_t  length 
)

Definition at line 26 of file bn_wrap.cpp.

References value.

27  {
28  value = BN_new();
29  BN_bin2bn(in, length, value);
30  }
BIGNUM * value
Definition: bn_wrap.h:22
Botan::OSSL_BN::~OSSL_BN ( )

Definition at line 43 of file bn_wrap.cpp.

References value.

44  {
45  BN_clear_free(value);
46  }
BIGNUM * value
Definition: bn_wrap.h:22

Member Function Documentation

size_t Botan::OSSL_BN::bytes ( ) const

Definition at line 68 of file bn_wrap.cpp.

References value.

Referenced by encode(), and to_bigint().

69  {
70  return BN_num_bytes(value);
71  }
BIGNUM * value
Definition: bn_wrap.h:22
void Botan::OSSL_BN::encode ( byte  out[],
size_t  length 
) const

Definition at line 60 of file bn_wrap.cpp.

References bytes(), and value.

61  {
62  BN_bn2bin(value, out + (length - bytes()));
63  }
size_t bytes() const
Definition: bn_wrap.cpp:68
BIGNUM * value
Definition: bn_wrap.h:22
OSSL_BN & Botan::OSSL_BN::operator= ( const OSSL_BN other)

Definition at line 51 of file bn_wrap.cpp.

References value.

52  {
53  BN_copy(value, other.value);
54  return (*this);
55  }
BIGNUM * value
Definition: bn_wrap.h:22
BigInt Botan::OSSL_BN::to_bigint ( ) const

Definition at line 76 of file bn_wrap.cpp.

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

Referenced by to_bytes().

77  {
78  SecureVector<byte> out(bytes());
79  BN_bn2bin(value, out);
80  return BigInt::decode(out);
81  }
size_t bytes() const
Definition: bn_wrap.cpp:68
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:102
BIGNUM * value
Definition: bn_wrap.h:22
SecureVector<byte> Botan::OSSL_BN::to_bytes ( ) const
inline

Definition at line 28 of file bn_wrap.h.

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

29  { return BigInt::encode(to_bigint()); }
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
BigInt to_bigint() const
Definition: bn_wrap.cpp:76

Member Data Documentation

BIGNUM* Botan::OSSL_BN::value

Definition at line 22 of file bn_wrap.h.

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


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