libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
keepass::SecureBuffer< N > Class Template Reference

Fixed-size byte buffer that is zeroized on destruction. More...

#include <secure.hh>

Public Member Functions

 SecureBuffer ()=default
 Default-constructs a zero-filled buffer.
 
 SecureBuffer (const std::array< uint8_t, N > &other)
 Constructs a buffer by copying the given fixed-size byte array.
 
 ~SecureBuffer ()
 Zeroizes the stored bytes.
 
 SecureBuffer (const SecureBuffer &)=delete
 No implicit copies of key material.
 
SecureBuffer & operator= (const SecureBuffer &)=delete
 No implicit copies of key material.
 
 SecureBuffer (SecureBuffer &&other) noexcept
 Move-constructs by copying the bytes and wiping the source.
 
SecureBuffer & operator= (SecureBuffer &&other) noexcept
 
uint8_t * data () noexcept
 Returns a pointer to the raw bytes.
 
const uint8_t * data () const noexcept
 Returns a const pointer to the raw bytes.
 
std::size_t size () const noexcept
 Returns the size of the buffer in bytes.
 
uint8_t * begin () noexcept
 Returns an iterator to the first byte.
 
uint8_t * end () noexcept
 Returns an iterator past the last byte.
 
const uint8_t * begin () const noexcept
 Returns a const iterator to the first byte.
 
const uint8_t * end () const noexcept
 Returns a const iterator past the last byte.
 
uint8_t & operator[] (std::size_t index) noexcept
 Returns the byte at the given index.
 
const uint8_t & operator[] (std::size_t index) const noexcept
 Returns the byte at the given index.
 
void fill (uint8_t value) noexcept
 Fills the buffer with the given byte value.
 
SecureBuffer Clone () const
 Returns an explicit deep copy of the buffer.
 

Detailed Description

template<std::size_t N>
class keepass::SecureBuffer< N >

Fixed-size byte buffer that is zeroized on destruction.

SecureBuffer owns a fixed number of key-material bytes. The content is overwritten with zeros when the buffer is destroyed, moved-from or assigned over. SecureBuffer is move-only; use Clone() to create an explicit deep copy.

Template Parameters
NThe number of bytes in the buffer.

Member Function Documentation

◆ operator=()

template<std::size_t N>
SecureBuffer & keepass::SecureBuffer< N >::operator= ( SecureBuffer< N > &&  other)
inlinenoexcept

Move-assigns by copying the bytes and wiping the source. The previous content is fully overwritten.


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