Secure memory block with allocator and cleanup. More...
Public Types | |
typedef A::value_type | value_type |
typedef A::pointer | iterator |
typedef A::const_pointer | const_iterator |
typedef A::size_type | size_type |
Public Member Functions | |
SecBlock (size_type size=0) | |
Construct a SecBlock with space for size elements. | |
SecBlock (const SecBlock< T, A > &t) | |
Copy construct a SecBlock from another SecBlock. | |
SecBlock (const T *ptr, size_type len) | |
Construct a SecBlock from an array of elements. | |
operator const void * () const | |
operator void * () | |
operator const T * () const | |
operator T * () | |
iterator | begin () |
Provides an iterator pointing to the first element in the memory block. | |
const_iterator | begin () const |
Provides a constant iterator pointing to the first element in the memory block. | |
iterator | end () |
Provides an iterator pointing beyond the last element in the memory block. | |
const_iterator | end () const |
Provides a constant iterator pointing beyond the last element in the memory block. | |
A::pointer | data () |
Provides a pointer to the first element in the memory block. | |
A::const_pointer | data () const |
Provides a pointer to the first element in the memory block. | |
size_type | size () const |
Provides the count of elements in the SecBlock. | |
bool | empty () const |
Determines if the SecBlock is empty. | |
byte * | BytePtr () |
Provides a byte pointer to the first element in the memory block. | |
const byte * | BytePtr () const |
Return a byte pointer to the first element in the memory block. | |
size_type | SizeInBytes () const |
Provides the number of bytes in the SecBlock. | |
void | Assign (const T *ptr, size_type len) |
Set contents and size from an array. | |
void | Assign (const SecBlock< T, A > &t) |
Copy contents from another SecBlock. | |
SecBlock< T, A > & | operator= (const SecBlock< T, A > &t) |
Assign contents from another SecBlock. | |
SecBlock< T, A > & | operator+= (const SecBlock< T, A > &t) |
Append contents from another SecBlock. | |
SecBlock< T, A > | operator+ (const SecBlock< T, A > &t) |
Concatenate contents from another SecBlock. | |
bool | operator== (const SecBlock< T, A > &t) const |
Bitwise compare two SecBlocks. | |
bool | operator!= (const SecBlock< T, A > &t) const |
Bitwise compare two SecBlocks. | |
void | New (size_type newSize) |
Change size without preserving contents. | |
void | CleanNew (size_type newSize) |
Change size without preserving contents. | |
void | Grow (size_type newSize) |
Change size and preserve contents. | |
void | CleanGrow (size_type newSize) |
Change size and preserve contents. | |
void | resize (size_type newSize) |
Change size and preserve contents. | |
void | swap (SecBlock< T, A > &b) |
Swap contents with another SecBlock. | |
Public Attributes | |
A | m_alloc |
size_type | m_size |
T * | m_ptr |
Secure memory block with allocator and cleanup.
T | a class or type | |
A | AllocatorWithCleanup derived class for allocation and cleanup |
Definition at line 425 of file secblock.h.
SecBlock< T, A >::SecBlock | ( | size_type | size = 0 |
) | [inline, explicit] |
Construct a SecBlock with space for size elements.
size | the number of elements in the allocation |
std::bad_alloc |
The elements are not initialized.
Definition at line 438 of file secblock.h.
Referenced by SecBlock< word32 >::operator+().
SecBlock< T, A >::SecBlock | ( | const SecBlock< T, A > & | t | ) | [inline] |
Copy construct a SecBlock from another SecBlock.
t | the other SecBlock |
std::bad_alloc |
Definition at line 444 of file secblock.h.
SecBlock< T, A >::SecBlock | ( | const T * | ptr, | |
size_type | len | |||
) | [inline] |
Construct a SecBlock from an array of elements.
ptr | a pointer to an array of T | |
len | the number of elements in the memory block |
std::bad_alloc |
If ptr!=NULL
and len!=0
, then the block is initialized from the pointer ptr. If ptr==NULL
and len!=0
, then the block is initialized to 0. Otherwise, the block is empty and uninitialized.
Definition at line 458 of file secblock.h.
iterator SecBlock< T, A >::begin | ( | ) | [inline] |
Provides an iterator pointing to the first element in the memory block.
Definition at line 487 of file secblock.h.
Referenced by HuffmanEncoder::Initialize().
const_iterator SecBlock< T, A >::begin | ( | ) | const [inline] |
Provides a constant iterator pointing to the first element in the memory block.
Definition at line 491 of file secblock.h.
iterator SecBlock< T, A >::end | ( | ) | [inline] |
Provides an iterator pointing beyond the last element in the memory block.
Definition at line 495 of file secblock.h.
Referenced by HuffmanEncoder::Initialize().
const_iterator SecBlock< T, A >::end | ( | ) | const [inline] |
Provides a constant iterator pointing beyond the last element in the memory block.
Definition at line 499 of file secblock.h.
A::pointer SecBlock< T, A >::data | ( | ) | [inline] |
Provides a pointer to the first element in the memory block.
Definition at line 504 of file secblock.h.
Referenced by HKDF< T >::DeriveKey(), and RandomPool::GenerateIntoBufferedTransformation().
A::const_pointer SecBlock< T, A >::data | ( | ) | const [inline] |
Provides a pointer to the first element in the memory block.
Definition at line 507 of file secblock.h.
size_type SecBlock< T, A >::size | ( | ) | const [inline] |
Provides the count of elements in the SecBlock.
Definition at line 512 of file secblock.h.
Referenced by PolynomialMod2::AllOnes(), DL_PrivateKey_EC< EC >::BERDecodePrivateKey(), Integer::Decode(), DL_DecryptorBase< SCHEME_OPTIONS::Element >::Decrypt(), TF_DecryptorBase::Decrypt(), PKCS12_PBKDF< T >::DeriveKey(), HKDF< T >::DeriveKey(), Integer::DivideByPowerOf2(), TF_EncryptorBase::Encrypt(), KDF2_RNG::GenerateBlock(), X917RNG::GenerateIntoBufferedTransformation(), RandomPool::GenerateIntoBufferedTransformation(), RandomNumberGenerator::GenerateIntoBufferedTransformation(), Integer::GetBit(), Integer::GetByte(), PolynomialMod2::GetByte(), DL_VerifierBase< SCHEME_OPTIONS::Element >::InputSignature(), TF_VerifierBase::InputSignature(), Integer::Integer(), IntegrityCheckModule(), Integer::InverseMod(), SecBlock< word32 >::operator+(), SecBlock< word32 >::operator+=(), PolynomialMod2::Parity(), PolynomialMod2::PolynomialMod2(), SignerFilter::Put2(), PK_DefaultEncryptionFilter::Put2(), Grouper::Put2(), DL_VerifierBase< SCHEME_OPTIONS::Element >::RecoverAndRestart(), AutoSeededX917RNG< BLOCK_CIPHER >::Reseed(), Integer::SetBit(), DL_SignerBase< SCHEME_OPTIONS::Element >::SignAndRestart(), TF_SignerBase::SignAndRestart(), DMAC_Base< T >::UncheckedSetKey(), DL_VerifierBase< SCHEME_OPTIONS::Element >::VerifyAndRestart(), Integer::WordCount(), and PolynomialMod2::WordCount().
bool SecBlock< T, A >::empty | ( | ) | const [inline] |
Determines if the SecBlock is empty.
Definition at line 515 of file secblock.h.
byte* SecBlock< T, A >::BytePtr | ( | ) | [inline] |
Provides a byte pointer to the first element in the memory block.
Definition at line 519 of file secblock.h.
Referenced by SHA3::TruncatedFinal(), Weak::PanamaHash< B >::TruncatedFinal(), VMAC_Base::UncheckedSetKey(), and SHA3::Update().
const byte* SecBlock< T, A >::BytePtr | ( | ) | const [inline] |
Return a byte pointer to the first element in the memory block.
Definition at line 522 of file secblock.h.
size_type SecBlock< T, A >::SizeInBytes | ( | ) | const [inline] |
Provides the number of bytes in the SecBlock.
Definition at line 526 of file secblock.h.
Referenced by Integer::Decode(), and SHA3::Restart().
void SecBlock< T, A >::Assign | ( | const T * | ptr, | |
size_type | len | |||
) | [inline] |
Set contents and size from an array.
ptr | a pointer to an array of T | |
len | the number of elements in the memory block |
If the memory block is reduced in size, then the unused area is set to 0.
Definition at line 532 of file secblock.h.
Referenced by DL_VerifierBase< SCHEME_OPTIONS::Element >::InputSignature(), Grouper::IsolatedInitialize(), and SecBlock< word32 >::operator=().
void SecBlock< T, A >::Assign | ( | const SecBlock< T, A > & | t | ) | [inline] |
Copy contents from another SecBlock.
t | the other SecBlock |
Assign checks for self assignment.
If the memory block is reduced in size, then the unused area is set to 0.
Definition at line 543 of file secblock.h.
SecBlock<T, A>& SecBlock< T, A >::operator= | ( | const SecBlock< T, A > & | t | ) | [inline] |
Assign contents from another SecBlock.
t | the other SecBlock |
Internally, operator=() calls Assign().
If the memory block is reduced in size, then the unused area is set to 0.
Definition at line 557 of file secblock.h.
SecBlock<T, A>& SecBlock< T, A >::operator+= | ( | const SecBlock< T, A > & | t | ) | [inline] |
Append contents from another SecBlock.
t | the other SecBlock |
Internally, this SecBlock calls Grow and then copies the new content.
If the memory block is reduced in size, then the unused area is set to 0.
Definition at line 568 of file secblock.h.
SecBlock<T, A> SecBlock< T, A >::operator+ | ( | const SecBlock< T, A > & | t | ) | [inline] |
Concatenate contents from another SecBlock.
t | the other SecBlock |
Internally, a temporary SecBlock is created and the content from this SecBlock and the other SecBlock are concatenated. The temporary SecBlock is returned to the caller.
Definition at line 589 of file secblock.h.
bool SecBlock< T, A >::operator== | ( | const SecBlock< T, A > & | t | ) | const [inline] |
Bitwise compare two SecBlocks.
t | the other SecBlock |
Uses a constant time compare if the arrays are equal size. The constant time compare is VerifyBufsEqual() found in misc.h.
Definition at line 607 of file secblock.h.
Referenced by SecBlock< word32 >::operator!=().
bool SecBlock< T, A >::operator!= | ( | const SecBlock< T, A > & | t | ) | const [inline] |
Bitwise compare two SecBlocks.
t | the other SecBlock |
Uses a constant time compare if the arrays are equal size. The constant time compare is VerifyBufsEqual() found in misc.h.
Internally, operator!=() returns the inverse of operator==().
Definition at line 619 of file secblock.h.
void SecBlock< T, A >::New | ( | size_type | newSize | ) | [inline] |
Change size without preserving contents.
newSize | the new size of the memory block |
Old content is not preserved. If the memory block is reduced in size, then the unused content is set to 0. If the memory block grows in size, then all content is uninitialized.
Internally, this SecBlock calls reallocate().
Definition at line 631 of file secblock.h.
Referenced by SecBlock< word32 >::Assign(), SecBlock< word32 >::CleanNew(), TF_VerifierBase::InputSignature(), Deflator::IsolatedInitialize(), BaseN_Decoder::IsolatedInitialize(), SignerFilter::Put2(), DL_VerifierBase< SCHEME_OPTIONS::Element >::RecoverAndRestart(), and SAFER::Base::UncheckedSetKey().
void SecBlock< T, A >::CleanNew | ( | size_type | newSize | ) | [inline] |
Change size without preserving contents.
newSize | the new size of the memory block |
Old content is not preserved. If the memory block is reduced in size, then the unused content is set to 0. Existing and new content is set to 0.
Internally, this SecBlock calls reallocate().
Definition at line 643 of file secblock.h.
Referenced by Integer::Decode(), Integer::Divide(), PolynomialMod2::Divide(), VMAC_Base::UncheckedSetKey(), and CMAC_Base::UncheckedSetKey().
void SecBlock< T, A >::Grow | ( | size_type | newSize | ) | [inline] |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. If the memory block grows in size, then all content is uninitialized.
Internally, this SecBlock calls reallocate().
Definition at line 658 of file secblock.h.
Referenced by SecBlock< word32 >::operator+=().
void SecBlock< T, A >::CleanGrow | ( | size_type | newSize | ) | [inline] |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. If the memory block is reduced in size, then the unused content is set to 0. If the memory block grows in size, then the new content is uninitialized.
Internally, this SecBlock calls reallocate().
Definition at line 677 of file secblock.h.
Referenced by Integer::SetBit(), Integer::SetByte(), and PolynomialMod2::SetByte().
void SecBlock< T, A >::resize | ( | size_type | newSize | ) | [inline] |
Change size and preserve contents.
newSize | the new size of the memory block |
Old content is preserved. If the memory block grows in size, then all content is uninitialized.
Internally, this SecBlock calls reallocate().
Definition at line 696 of file secblock.h.
Referenced by Integer::DivideByPowerOf2(), InvertibleESIGNFunction::GenerateRandom(), HuffmanEncoder::Initialize(), IntegrityCheckModule(), PK_DefaultDecryptionFilter::Put2(), PK_DefaultEncryptionFilter::Put2(), and DMAC_Base< T >::UncheckedSetKey().
void SecBlock< T, A >::swap | ( | SecBlock< T, A > & | b | ) | [inline] |
Swap contents with another SecBlock.
b | the other SecBlock |
Internally, std::swap() is called on m_alloc, m_size and m_ptr.
Definition at line 705 of file secblock.h.
Referenced by SecBlock< word32 >::swap(), and Integer::swap().