Botan 1.10.17

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_BN & | operator= (const OSSL_BN &)
| OSSL_BN (const OSSL_BN &)
| OSSL_BN (const BigInt &=0)
| OSSL_BN (const byte[], size_t)
BigInt | to_bigint () const
SecureVector< byte > | to_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.

References value.

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

## ◆ OSSL_BN() [2/3]

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 }
Botan::BigInt::encode
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ OSSL_BN() [3/3]

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 }
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ ~OSSL_BN()

Botan::OSSL_BN::~OSSL_BN | ( |  | ) |

Definition at line 43 of file bn_wrap.cpp.

References value.

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

## Member Function Documentation

## ◆ bytes()

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 }
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ encode()

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 }
Botan::OSSL_BN::bytes
size_t bytes() const
Definition: bn_wrap.cpp:68
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ operator=()

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 }
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ to_bigint()

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 }
Botan::BigInt::decode
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:102
Botan::OSSL_BN::bytes
size_t bytes() const
Definition: bn_wrap.cpp:68
Botan::OSSL_BN::value
BIGNUM * value
Definition: bn_wrap.h:22

## ◆ to_bytes()

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()); }
Botan::BigInt::encode
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
Botan::OSSL_BN::to_bigint
BigInt to_bigint() const
Definition: bn_wrap.cpp:76

## 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(), to_bigint(), and ~OSSL_BN().

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

- src/engine/openssl/bn_wrap.h
- src/engine/openssl/bn_wrap.cpp