#include <secmem.h>
Public Member Functions | |
| void | append (const MemoryRegion< T > &other) |
| void | append (T x) |
| void | append (const T data[], u32bit n) |
| const T * | begin () const |
| T * | begin () |
| void | clear () |
| void | copy (u32bit off, const T in[], u32bit n) |
| void | copy (const T in[], u32bit n) |
| void | destroy () |
| bool | empty () const |
| const T * | end () const |
| T * | end () |
| void | grow_to (u32bit n) |
| operator const T * () const | |
| operator T * () | |
| bool | operator!= (const MemoryRegion< T > &other) const |
| bool | operator< (const MemoryRegion< T > &other) const |
| MemoryRegion< T > & | operator= (const MemoryRegion< T > &other) |
| bool | operator== (const MemoryRegion< T > &other) const |
| void | resize (u32bit n) |
| void | set (const MemoryRegion< T > &in) |
| void | set (const T in[], u32bit n) |
| u32bit | size () const |
| void | swap (MemoryRegion< T > &other) |
| ~MemoryRegion () | |
Protected Member Functions | |
| void | init (bool locking, u32bit length=0) |
| MemoryRegion (const MemoryRegion< T > &other) | |
| MemoryRegion () | |
Definition at line 21 of file secmem.h.
| Botan::MemoryRegion< T >::~MemoryRegion | ( | ) | [inline] |
| Botan::MemoryRegion< T >::MemoryRegion | ( | ) | [inline, protected] |
| Botan::MemoryRegion< T >::MemoryRegion | ( | const MemoryRegion< T > & | other | ) | [inline, protected] |
| void Botan::MemoryRegion< T >::append | ( | const MemoryRegion< T > & | other | ) | [inline] |
Append data to the end of this buffer.
| other | the buffer containing the data to append |
Definition at line 161 of file secmem.h.
Referenced by Botan::MemoryRegion< byte >::append().
00162 { append(other.begin(), other.size()); }
| void Botan::MemoryRegion< T >::append | ( | T | x | ) | [inline] |
Append a single element.
| x | the element to append |
Definition at line 155 of file secmem.h.
Referenced by Botan::MemoryRegion< byte >::append().
00155 { append(&x, 1); }
| void Botan::MemoryRegion< T >::append | ( | const T | data[], | |
| u32bit | n | |||
| ) | [inline] |
Append data to the end of this buffer.
| data | the array containing the data to append | |
| n | the size of the array data |
Definition at line 148 of file secmem.h.
Referenced by Botan::DER_Encoder::add_object(), Botan::AlgorithmIdentifier::AlgorithmIdentifier(), Botan::OctetString::change(), Botan::PK_Verifier::check_signature(), Botan::CVC_EAC::create_ado_req(), Botan::CVC_EAC::create_cvc_req(), Botan::BigInt::decode(), Botan::X942_PRF::derive(), Botan::KDF2::derive(), Botan::DER_Encoder::encode(), Botan::OID::encode_into(), Botan::CryptoBox::encrypt(), Botan::ECDSA_Signature::get_concatenation(), Botan::make_cvc_cert(), Botan::DER_Encoder::raw_bytes(), Botan::BER_Decoder::raw_bytes(), Botan::HandshakeMessage::send(), Botan::Filter::send(), Botan::RTSS_Share::split(), Botan::EMSA3_Raw::update(), Botan::PK_Decryptor_Filter::write(), and Botan::PK_Encryptor_Filter::write().
| const T* Botan::MemoryRegion< T >::begin | ( | ) | const [inline] |
| T* Botan::MemoryRegion< T >::begin | ( | ) | [inline] |
Get a pointer to the first element in the buffer.
Definition at line 53 of file secmem.h.
Referenced by Botan::MDx_HashFunction::add_data(), Botan::DER_Encoder::add_object(), Botan::MemoryRegion< byte >::append(), Botan::OctetString::change(), Botan::check_passhash9(), Botan::Turing::cipher(), Botan::OFB::cipher(), Botan::CTR_BE::cipher(), Botan::ARC4::cipher(), Botan::SHA_160::compress_n(), Botan::MD5::compress_n(), Botan::decode_concatenation(), Botan::AlternativeName::decode_from(), Botan::DESX::decrypt_n(), Botan::PKCS5_PBKDF2::derive_key(), Botan::KDF::derive_key(), Botan::EC2OSP(), Botan::DER_Encoder::encode(), Botan::CryptoBox::encrypt(), Botan::DESX::encrypt_n(), Botan::Zlib_Decompression::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::Montgomery_Exponentiator::execute(), Botan::Record_Writer::flush(), Botan::Zlib_Compression::flush(), Botan::Bzip_Compression::flush(), Botan::CMS_Decoder::get_data(), Botan::Record_Reader::get_record(), Botan::MGF1::mask(), Botan::BigInt::operator+=(), Botan::operator<<(), Botan::operator>>(), Botan::OctetString::operator^=(), Botan::DataSource_Stream::peek(), Botan::Unix_EntropySource::poll(), Botan::FTW_EntropySource::poll(), Botan::Win32_CAPI_EntropySource::poll(), Botan::Pipe::process_msg(), Botan::Randpool::randomize(), Botan::DER_Encoder::raw_bytes(), Botan::Pipe::read_all_as_string(), Botan::RTSS_Share::reconstruct(), Botan::Filter::send(), Botan::Montgomery_Exponentiator::set_base(), Botan::CTR_BE::set_iv(), Botan::ASN1::to_string(), Botan::HandshakeHash::update(), Botan::Zlib_Decompression::write(), Botan::Zlib_Compression::write(), Botan::Pipe::write(), Botan::Bzip_Decompression::write(), and Botan::Bzip_Compression::write().
| void Botan::MemoryRegion< T >::clear | ( | ) | [inline] |
Zeroise the bytes of this buffer. The length remains unchanged.
Definition at line 167 of file secmem.h.
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::WiderWake_41_BE::clear(), Botan::Turing::clear(), Botan::Salsa20::clear(), Botan::OFB::clear(), Botan::CTR_BE::clear(), Botan::ARC4::clear(), Botan::ANSI_X931_RNG::clear(), Botan::Randpool::clear(), Botan::ANSI_X919_MAC::clear(), Botan::SSL3_MAC::clear(), Botan::HMAC::clear(), Botan::CMAC::clear(), Botan::CBC_MAC::clear(), Botan::Whirlpool::clear(), Botan::Tiger::clear(), Botan::Skein_512::clear(), Botan::SHA_160::clear(), Botan::RIPEMD_160::clear(), Botan::RIPEMD_128::clear(), Botan::MDx_HashFunction::clear(), Botan::MD5::clear(), Botan::MD2::clear(), Botan::HAS_160::clear(), Botan::GOST_34_11::clear(), Botan::Twofish::clear(), Botan::Square::clear(), Botan::Skipjack::clear(), Botan::Noekeon::clear(), Botan::LubyRackoff::clear(), Botan::Lion::clear(), Botan::AES_256_Intel::clear(), Botan::AES_192_Intel::clear(), Botan::AES_128_Intel::clear(), Botan::AES::clear(), Botan::BER_Decoder::decode_optional_string(), Botan::Montgomery_Exponentiator::execute(), Botan::MDx_HashFunction::final_result(), Botan::CMS_Encoder::get_contents(), Botan::BigInt::operator*=(), Botan::BigInt::operator+=(), Botan::BigInt::operator-=(), Botan::OctetString::operator^=(), Botan::EMSA3_Raw::raw_data(), Botan::Record_Writer::reset(), Botan::Montgomery_Exponentiator::set_base(), Botan::OFB::set_iv(), Botan::CTR_BE::set_iv(), Botan::CTS_Decryption::set_iv(), Botan::CTS_Encryption::set_iv(), Botan::CFB_Decryption::set_iv(), and Botan::CFB_Encryption::set_iv().
00167 { clear_mem(buf, allocated); }
| void Botan::MemoryRegion< T >::copy | ( | u32bit | off, | |
| const T | in[], | |||
| u32bit | n | |||
| ) | [inline] |
Copy the contents of an array of objects of type T into this buffer. The former contents of *this are discarded. The length of *this must be at least n, otherwise memory errors occur.
| off | the offset position inside this buffer to start inserting the copied bytes | |
| in | the array to copy the contents from | |
| n | the length of in |
Definition at line 125 of file secmem.h.
| void Botan::MemoryRegion< T >::copy | ( | const T | in[], | |
| u32bit | n | |||
| ) | [inline] |
Copy the contents of an array of objects of type T into this buffer. The former contents of *this are discarded. The length of *this must be at least n, otherwise memory errors occur.
| in | the array to copy the contents from | |
| n | the length of in |
Definition at line 113 of file secmem.h.
Referenced by Botan::MDx_HashFunction::add_data(), Botan::MemoryRegion< byte >::append(), Botan::BigInt::BigInt(), Botan::OctetString::change(), Botan::Blowfish::clear(), Botan::MemoryRegion< byte >::copy(), Botan::EC2OSP(), Botan::Montgomery_Exponentiator::execute(), Botan::operator^(), Botan::Record_Writer::send(), Botan::MemoryRegion< byte >::set(), Botan::OFB::set_iv(), Botan::CTR_BE::set_iv(), Botan::Hex_Encoder::write(), and Botan::Base64_Encoder::write().
| void Botan::MemoryRegion< T >::destroy | ( | ) | [inline] |
Reset this buffer to an empty buffer with size zero.
Definition at line 172 of file secmem.h.
Referenced by Botan::X509_DN::add_attribute(), Botan::ANSI_X931_RNG::clear(), Botan::PK_Decryptor_Filter::end_msg(), Botan::PK_Encryptor_Filter::end_msg(), Botan::DER_Encoder::get_contents(), Botan::BER_Decoder::raw_bytes(), and Botan::Filter::send().
00172 { resize(0); }
| bool Botan::MemoryRegion< T >::empty | ( | ) | const [inline] |
Find out whether this buffer is empty.
Definition at line 35 of file secmem.h.
Referenced by Botan::BER_Decoder::decode(), Botan::X509_DN::encode_into(), Botan::PK_Verifier_Filter::end_msg(), Botan::X509::load_key(), and Botan::CMS_Encoder::set_data().
| const T* Botan::MemoryRegion< T >::end | ( | ) | const [inline] |
| T* Botan::MemoryRegion< T >::end | ( | ) | [inline] |
| void Botan::MemoryRegion< T >::grow_to | ( | u32bit | n | ) | [inline] |
Change the size to n elements. If n is >= size(), preexisting elements remain unchanged, with later elements zero-initialized. If n < size(), then the last (size() - N) elements are removed.
| n | the new size |
Definition at line 248 of file secmem.h.
References Botan::clear_mem(), and Botan::copy_mem().
Referenced by Botan::MemoryRegion< byte >::append(), Botan::CryptoBox::encrypt(), Botan::BigInt::grow_reg(), and Botan::BigInt::grow_to().
00249 { 00250 if(n > used && n <= allocated) 00251 { 00252 clear_mem(buf + used, n - used); 00253 used = n; 00254 return; 00255 } 00256 else if(n > allocated) 00257 { 00258 T* new_buf = allocate(n); 00259 copy_mem(new_buf, buf, used); 00260 deallocate(buf, allocated); 00261 buf = new_buf; 00262 allocated = used = n; 00263 } 00264 }
| void Botan::MemoryRegion< T >::init | ( | bool | locking, | |
| u32bit | length = 0 | |||
| ) | [inline, protected] |
| locking | should we use a locking allocator | |
| length | the initial length to use |
Definition at line 215 of file secmem.h.
00216 { alloc = Allocator::get(locking); resize(length); }
| Botan::MemoryRegion< T >::operator const T * | ( | ) | const [inline] |
| Botan::MemoryRegion< T >::operator T * | ( | ) | [inline] |
| bool Botan::MemoryRegion< T >::operator!= | ( | const MemoryRegion< T > & | other | ) | const [inline] |
| bool Botan::MemoryRegion< T >::operator< | ( | const MemoryRegion< T > & | other | ) | const [inline] |
Compare two buffers lexicographically.
Definition at line 270 of file secmem.h.
References Botan::MemoryRegion< T >::size().
00271 { 00272 if(size() < other.size()) return true; 00273 if(size() > other.size()) return false; 00274 00275 for(u32bit j = 0; j != size(); j++) 00276 { 00277 if(buf[j] < other[j]) return true; 00278 if(buf[j] > other[j]) return false; 00279 } 00280 00281 return false; 00282 }
| MemoryRegion<T>& Botan::MemoryRegion< T >::operator= | ( | const MemoryRegion< T > & | other | ) | [inline] |
Copy the contents of another buffer into this buffer. The former contents of *this are discarded.
| other | the buffer to copy the contents from. |
Reimplemented in Botan::MemoryVector< T >, Botan::SecureVector< T, INITIAL_LEN >, Botan::MemoryVector< byte >, Botan::SecureVector< u32bit, 40 >, Botan::SecureVector< byte, 64 >, Botan::SecureVector< u32bit >, Botan::SecureVector< u32bit, 96 >, Botan::SecureVector< u64bit, 32 >, Botan::SecureVector< u64bit, 80 >, Botan::SecureVector< u32bit, 20 >, Botan::SecureVector< u32bit, 56 >, Botan::SecureVector< byte, 32 >, Botan::SecureVector< u64bit, 3 >, Botan::SecureVector< u16bit, 52 >, Botan::SecureVector< u16bit, 64 >, Botan::SecureVector< byte, 16 >, Botan::SecureVector< u64bit, 8 >, Botan::SecureVector< u32bit, 132 >, Botan::SecureVector< byte >, Botan::SecureVector< u32bit, 48 >, Botan::SecureVector< u32bit, 52 >, Botan::SecureVector< u64bit, 9 >, Botan::SecureVector< u32bit, 64 >, Botan::SecureVector< byte, DEFAULT_BUFFERSIZE >, Botan::SecureVector< u32bit, 16 >, Botan::SecureVector< u32bit, 4 >, Botan::SecureVector< byte, 48 >, Botan::SecureVector< u32bit, 28 >, Botan::SecureVector< u32bit, 17 >, Botan::SecureVector< u32bit, 256 >, Botan::SecureVector< u32bit, 5 >, Botan::SecureVector< byte, 2560 >, Botan::SecureVector< u32bit, 18 >, Botan::SecureVector< u32bit, 32 >, Botan::SecureVector< byte, 8 >, Botan::SecureVector< u64bit, 16 >, Botan::SecureVector< u32bit, 1024 >, Botan::SecureVector< u32bit, 44 >, Botan::SecureVector< word >, Botan::SecureVector< u32bit, 60 >, Botan::SecureVector< u32bit, 8 >, Botan::SecureVector< byte, 340 >, and Botan::SecureVector< u16bit, 100 >.
Definition at line 103 of file secmem.h.
| bool Botan::MemoryRegion< T >::operator== | ( | const MemoryRegion< T > & | other | ) | const [inline] |
| void Botan::MemoryRegion< T >::resize | ( | u32bit | n | ) | [inline] |
Reset this buffer to a buffer of specified length. The content will be initialized to zero bytes.
| n | the new length of the buffer |
Definition at line 236 of file secmem.h.
Referenced by Botan::ANSI_X931_RNG::ANSI_X931_RNG(), Botan::Base64_Decoder::Base64_Decoder(), Botan::Base64_Encoder::Base64_Encoder(), Botan::BigInt::BigInt(), Botan::BigInt::binary_decode(), Botan::Buffered_Filter::Buffered_Filter(), Botan::CBC_Decryption::CBC_Decryption(), Botan::CBC_Encryption::CBC_Encryption(), Botan::CFB_Decryption::CFB_Decryption(), Botan::CFB_Encryption::CFB_Encryption(), Botan::OctetString::change(), Botan::Client_Hello::Client_Hello(), Botan::Client_Key_Exchange::Client_Key_Exchange(), Botan::CMAC::CMAC(), Botan::CTR_BE::CTR_BE(), Botan::CTS_Decryption::CTS_Decryption(), Botan::CTS_Encryption::CTS_Encryption(), Botan::MemoryRegion< byte >::destroy(), Botan::divide(), Botan::EAX_Decryption::EAX_Decryption(), Botan::ECB_Decryption::ECB_Decryption(), Botan::ECB_Encryption::ECB_Encryption(), Botan::BER_Decoder::get_next_object(), Botan::Record_Reader::get_record(), Botan::Hex_Decoder::Hex_Decoder(), Botan::Hex_Encoder::Hex_Encoder(), Botan::HMAC::HMAC(), Botan::MemoryRegion< byte >::init(), Botan::Lion::Lion(), Botan::OctetString::OctetString(), Botan::OFB::OFB(), Botan::Client_Key_Exchange::pre_master_secret(), Botan::Randpool::Randpool(), Botan::RC5::RC5(), Botan::Server_Hello::Server_Hello(), Botan::MemoryRegion< byte >::set(), and Botan::SSL3_MAC::SSL3_MAC().
00237 { 00238 if(n <= allocated) { clear(); used = n; return; } 00239 deallocate(buf, allocated); 00240 buf = allocate(n); 00241 allocated = used = n; 00242 }
| void Botan::MemoryRegion< T >::set | ( | const MemoryRegion< T > & | in | ) | [inline] |
| void Botan::MemoryRegion< T >::set | ( | const T | in[], | |
| u32bit | n | |||
| ) | [inline] |
Set the contents of this according to the argument. The size of *this is increased if necessary.
| in | the array of objects of type T to copy the contents from | |
| n | the size of array in |
Definition at line 134 of file secmem.h.
Referenced by Botan::DataSource_Memory::DataSource_Memory(), Botan::BER_Decoder::decode(), Botan::decode_concatenation(), Botan::Record_Reader::get_record(), Botan::pkcs_hash_id(), Botan::CMS_Encoder::set_data(), and Botan::PK_Verifier_Filter::set_signature().
| u32bit Botan::MemoryRegion< T >::size | ( | ) | const [inline] |
Find out the size of the buffer, i.e. how many objects of type T it contains.
Definition at line 29 of file secmem.h.
Referenced by Botan::Randpool::add_entropy(), Botan::DER_Encoder::add_object(), Botan::Alert::Alert(), Botan::MemoryRegion< byte >::append(), Botan::BigInt::binary_decode(), Botan::OctetString::change(), Botan::check_passhash9(), Botan::PK_Verifier::check_signature(), Botan::WiderWake_41_BE::cipher(), Botan::Turing::cipher(), Botan::Salsa20::cipher(), Botan::OFB::cipher(), Botan::CTR_BE::cipher(), Botan::ARC4::cipher(), Botan::Client_Hello::Client_Hello(), Botan::MD5::compress_n(), Botan::MemoryRegion< byte >::copy(), Botan::CTR_BE::CTR_BE(), Botan::BER::decode(), Botan::EME::decode(), Botan::BigInt::decode(), Botan::BER_Decoder::decode(), Botan::decode_concatenation(), Botan::EAC_Time::decode_from(), Botan::OID::decode_from(), Botan::AlternativeName::decode_from(), Botan::BER_Decoder::decode_null(), Botan::BER_Decoder::decode_octet_string_bigint(), Botan::PK_Decryptor::decrypt(), Botan::CryptoBox::decrypt(), Botan::X942_PRF::derive(), Botan::KDF2::derive(), Botan::PK_Key_Agreement::derive_key(), Botan::PKCS5_PBKDF1::derive_key(), Botan::KDF::derive_key(), Botan::EC2OSP(), Botan::EME::encode(), Botan::PEM_Code::encode(), Botan::DER_Encoder::encode(), Botan::CRL_Entry::encode_into(), Botan::EMSA3::encoding_of(), Botan::PK_Encryptor::encrypt(), Botan::CryptoBox::encrypt(), Botan::MemoryRegion< byte >::end(), Botan::Zlib_Decompression::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::PK_Encryptor_Filter::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::MAC_Filter::end_msg(), Botan::Hash_Filter::end_msg(), Botan::DataSource_Memory::end_of_data(), Botan::Montgomery_Exponentiator::execute(), Botan::Zlib_Compression::flush(), Botan::Bzip_Compression::flush(), Botan::generate_dsa_primes(), Botan::generate_passhash9(), Botan::CMS_Decoder::get_data(), Botan::Record_Reader::get_record(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), Botan::Hex_Decoder::Hex_Decoder(), Botan::Hex_Encoder::Hex_Encoder(), Botan::ANSI_X931_RNG::is_seeded(), Botan::MGF1::mask(), Botan::PEM_Code::matches(), Botan::BigInt::operator*=(), Botan::BigInt::operator+=(), Botan::MemoryRegion< T >::operator<(), Botan::operator<<(), Botan::MemoryRegion< byte >::operator==(), Botan::operator>>(), Botan::OS2ECP(), Botan::OSSL_BN::OSSL_BN(), Botan::DataSource_Stream::peek(), Botan::DataSource_Memory::peek(), Botan::pkcs_hash_id(), Botan::Unix_EntropySource::poll(), Botan::FTW_EntropySource::poll(), Botan::Win32_CAPI_EntropySource::poll(), Botan::CMAC::poly_double(), Botan::Client_Key_Exchange::pre_master_secret(), Botan::Debug::print_vec(), Botan::BufferedComputation::process(), Botan::Pipe::process_msg(), Botan::random_prime(), Botan::ANSI_X931_RNG::randomize(), Botan::Randpool::randomize(), Botan::BigInt::randomize(), Botan::DER_Encoder::raw_bytes(), Botan::DataSource_Memory::read(), Botan::Pipe::read_all(), Botan::Pipe::read_all_as_string(), Botan::TLS_Data_Reader::remaining_bytes(), Botan::Randpool::reseed(), Botan::SecureVector< u16bit, 100 >::SecureVector(), Botan::Record_Writer::send(), Botan::HandshakeMessage::send(), Botan::Filter::send(), Botan::Server_Hello::Server_Hello(), Botan::Montgomery_Exponentiator::set_base(), Botan::WiderWake_41_BE::set_iv(), Botan::Turing::set_iv(), Botan::CTR_BE::set_iv(), Botan::EAX_Base::set_iv(), Botan::OctetString::set_odd_parity(), Botan::CMS_Encoder::sign(), Botan::PK_Signer::sign_message(), Botan::PK_Signer::signature(), Botan::KeyPair::signature_consistency_check(), Botan::RTSS_Share::split(), Botan::BER_Decoder::start_cons(), Botan::ASN1::to_string(), Botan::BufferedComputation::update(), Botan::HandshakeHash::update(), Botan::PK_Verifier::update(), Botan::PK_Signer::update(), Botan::Server_Key_Exchange::verify(), Botan::EMSA3::verify(), Botan::MessageAuthenticationCode::verify_mac(), Botan::PK_Verifier::verify_message(), Botan::Zlib_Decompression::write(), Botan::Zlib_Compression::write(), Botan::Pipe::write(), Botan::Hex_Decoder::write(), Botan::Hex_Encoder::write(), Botan::Bzip_Decompression::write(), Botan::Bzip_Compression::write(), Botan::Buffered_Filter::write(), Botan::Base64_Decoder::write(), Botan::Base64_Encoder::write(), and Botan::StreamCipher_Filter::write().
| void Botan::MemoryRegion< T >::swap | ( | MemoryRegion< T > & | other | ) | [inline] |
Swap this buffer with another object.
Definition at line 288 of file secmem.h.
References Botan::MemoryRegion< T >::alloc, Botan::MemoryRegion< T >::allocated, Botan::MemoryRegion< T >::buf, and Botan::MemoryRegion< T >::used.
Referenced by Botan::BigInt::swap().
00289 { 00290 std::swap(buf, x.buf); 00291 std::swap(used, x.used); 00292 std::swap(allocated, x.allocated); 00293 std::swap(alloc, x.alloc); 00294 }
1.5.8