diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/buf_comp/buf_comp.h (renamed from src/utils/buf_comp.h) | 0 | ||||
-rw-r--r-- | src/utils/data_src.cpp | 207 | ||||
-rw-r--r-- | src/utils/data_src.h | 150 | ||||
-rw-r--r-- | src/utils/datastor/datastor.cpp (renamed from src/utils/datastor.cpp) | 0 | ||||
-rw-r--r-- | src/utils/datastor/datastor.h (renamed from src/utils/datastor.h) | 0 | ||||
-rw-r--r-- | src/utils/info.txt | 12 | ||||
-rw-r--r-- | src/utils/scan_name.cpp | 74 | ||||
-rw-r--r-- | src/utils/scan_name.h | 77 | ||||
-rw-r--r-- | src/utils/secmem.h | 438 |
9 files changed, 0 insertions, 958 deletions
diff --git a/src/utils/buf_comp.h b/src/utils/buf_comp/buf_comp.h index 3f1e90bad..3f1e90bad 100644 --- a/src/utils/buf_comp.h +++ b/src/utils/buf_comp/buf_comp.h diff --git a/src/utils/data_src.cpp b/src/utils/data_src.cpp deleted file mode 100644 index e6387c4ba..000000000 --- a/src/utils/data_src.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* -* DataSource -* (C) 1999-2007 Jack Lloyd -* 2005 Matthew Gregan -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/data_src.h> -#include <botan/exceptn.h> - -#include <fstream> -#include <algorithm> - -namespace Botan { - -/* -* Read a single byte from the DataSource -*/ -u32bit DataSource::read_byte(byte& out) - { - return read(&out, 1); - } - -/* -* Peek a single byte from the DataSource -*/ -u32bit DataSource::peek_byte(byte& out) const - { - return peek(&out, 1, 0); - } - -/* -* Discard the next N bytes of the data -*/ -u32bit DataSource::discard_next(u32bit n) - { - u32bit discarded = 0; - byte dummy; - for(u32bit j = 0; j != n; ++j) - discarded += read_byte(dummy); - return discarded; - } - -/* -* Read from a memory buffer -*/ -u32bit DataSource_Memory::read(byte out[], u32bit length) - { - u32bit got = std::min(source.size() - offset, length); - copy_mem(out, source + offset, got); - offset += got; - return got; - } - -/* -* Peek into a memory buffer -*/ -u32bit DataSource_Memory::peek(byte out[], u32bit length, - u32bit peek_offset) const - { - const u32bit bytes_left = source.size() - offset; - if(peek_offset >= bytes_left) return 0; - - u32bit got = std::min(bytes_left - peek_offset, length); - copy_mem(out, source + offset + peek_offset, got); - return got; - } - -/* -* Check if the memory buffer is empty -*/ -bool DataSource_Memory::end_of_data() const - { - return (offset == source.size()); - } - -/* -* DataSource_Memory Constructor -*/ -DataSource_Memory::DataSource_Memory(const byte in[], u32bit length) - { - source.set(in, length); - offset = 0; - } - -/* -* DataSource_Memory Constructor -*/ -DataSource_Memory::DataSource_Memory(const MemoryRegion<byte>& in) - { - source = in; - offset = 0; - } - -/* -* DataSource_Memory Constructor -*/ -DataSource_Memory::DataSource_Memory(const std::string& in) - { - source.set(reinterpret_cast<const byte*>(in.data()), in.length()); - offset = 0; - } - -/* -* Read from a stream -*/ -u32bit DataSource_Stream::read(byte out[], u32bit length) - { - source->read(reinterpret_cast<char*>(out), length); - if(source->bad()) - throw Stream_IO_Error("DataSource_Stream::read: Source failure"); - - u32bit got = source->gcount(); - total_read += got; - return got; - } - -/* -* Peek into a stream -*/ -u32bit DataSource_Stream::peek(byte out[], u32bit length, u32bit offset) const - { - if(end_of_data()) - throw Invalid_State("DataSource_Stream: Cannot peek when out of data"); - - u32bit got = 0; - - if(offset) - { - SecureVector<byte> buf(offset); - source->read(reinterpret_cast<char*>(buf.begin()), buf.size()); - if(source->bad()) - throw Stream_IO_Error("DataSource_Stream::peek: Source failure"); - got = source->gcount(); - } - - if(got == offset) - { - source->read(reinterpret_cast<char*>(out), length); - if(source->bad()) - throw Stream_IO_Error("DataSource_Stream::peek: Source failure"); - got = source->gcount(); - } - - if(source->eof()) - source->clear(); - source->seekg(total_read, std::ios::beg); - - return got; - } - -/* -* Check if the stream is empty or in error -*/ -bool DataSource_Stream::end_of_data() const - { - return (!source->good()); - } - -/* -* Return a human-readable ID for this stream -*/ -std::string DataSource_Stream::id() const - { - return identifier; - } - -/* -* DataSource_Stream Constructor -*/ -DataSource_Stream::DataSource_Stream(const std::string& path, - bool use_binary) : - identifier(path), owner(true) - { - if(use_binary) - source = new std::ifstream(path.c_str(), std::ios::binary); - else - source = new std::ifstream(path.c_str()); - - if(!source->good()) - throw Stream_IO_Error("DataSource: Failure opening file " + path); - - total_read = 0; - } - -/* -* DataSource_Stream Constructor -*/ -DataSource_Stream::DataSource_Stream(std::istream& in, - const std::string& name) : - identifier(name), owner(false) - { - source = ∈ - total_read = 0; - } - -/* -* DataSource_Stream Destructor -*/ -DataSource_Stream::~DataSource_Stream() - { - if(owner) - delete source; - } - -} diff --git a/src/utils/data_src.h b/src/utils/data_src.h deleted file mode 100644 index e16217e0f..000000000 --- a/src/utils/data_src.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -* DataSource -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_DATA_SRC_H__ -#define BOTAN_DATA_SRC_H__ - -#include <botan/secmem.h> -#include <string> -#include <iosfwd> - -namespace Botan { - -/** -* This class represents an abstract data source object. -*/ -class BOTAN_DLL DataSource - { - public: - /** - * Read from the source. Moves the internal offset so that - * every call to read will return a new portion of the source. - * @param out the byte array to write the result to - * @param length the length of the byte array out - * @return the length in bytes that was actually read and put - * into out - */ - virtual u32bit read(byte out[], u32bit length) = 0; - - /** - * Read from the source but do not modify the internal offset. Consecutive - * calls to peek() will return portions of the source starting at the same - * position. - * @param out the byte array to write the output to - * @param length the length of the byte array out - * @return the length in bytes that was actually read and put - * into out - */ - virtual u32bit peek(byte out[], u32bit length, - u32bit peek_offset) const = 0; - - /** - * Test whether the source still has data that can be read. - * @return true if there is still data to read, false otherwise - */ - virtual bool end_of_data() const = 0; - /** - * return the id of this data source - * @return the std::string representing the id of this data source - */ - virtual std::string id() const { return ""; } - - /** - * Read one byte. - * @param the byte to read to - * @return the length in bytes that was actually read and put - * into out - */ - u32bit read_byte(byte& out); - - /** - * Peek at one byte. - * @param the byte to read to - * @return the length in bytes that was actually read and put - * into out - */ - u32bit peek_byte(byte& out) const; - - /** - * Discard the next N bytes of the data - * @param N the number of bytes to discard - * @return the number of bytes actually discarded - */ - u32bit discard_next(u32bit N); - - DataSource() {} - virtual ~DataSource() {} - private: - DataSource& operator=(const DataSource&) { return (*this); } - DataSource(const DataSource&); - }; - -/** -* This class represents a Memory-Based DataSource -*/ -class BOTAN_DLL DataSource_Memory : public DataSource - { - public: - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit) const; - bool end_of_data() const; - - /** - * Construct a memory source that reads from a string - * @param in the string to read from - */ - DataSource_Memory(const std::string& in); - - /** - * Construct a memory source that reads from a byte array - * @param in the byte array to read from - * @param length the length of the byte array - */ - DataSource_Memory(const byte in[], u32bit length); - - /** - * Construct a memory source that reads from a MemoryRegion - * @param in the MemoryRegion to read from - */ - DataSource_Memory(const MemoryRegion<byte>& in); - private: - SecureVector<byte> source; - u32bit offset; - }; - -/** -* This class represents a Stream-Based DataSource. -*/ -class BOTAN_DLL DataSource_Stream : public DataSource - { - public: - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit) const; - bool end_of_data() const; - std::string id() const; - - DataSource_Stream(std::istream&, const std::string& id = ""); - - /** - * Construct a Stream-Based DataSource from file - * @param file the name of the file - * @param use_binary whether to treat the file as binary or not - */ - DataSource_Stream(const std::string& file, bool use_binary = false); - - ~DataSource_Stream(); - private: - const std::string identifier; - const bool owner; - - std::istream* source; - u32bit total_read; - }; - -} - -#endif diff --git a/src/utils/datastor.cpp b/src/utils/datastor/datastor.cpp index 129dad9bf..129dad9bf 100644 --- a/src/utils/datastor.cpp +++ b/src/utils/datastor/datastor.cpp diff --git a/src/utils/datastor.h b/src/utils/datastor/datastor.h index 7ee626fda..7ee626fda 100644 --- a/src/utils/datastor.h +++ b/src/utils/datastor/datastor.h diff --git a/src/utils/info.txt b/src/utils/info.txt index dcf4b9288..36b10df76 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -11,13 +11,10 @@ tru64 -> rt <add> bit_ops.h bswap.h -buf_comp.h charset.cpp charset.h data_src.cpp data_src.h -datastor.cpp -datastor.h exceptn.cpp exceptn.h loadstor.h @@ -26,9 +23,6 @@ mlock.cpp parsing.cpp parsing.h rotate.h -scan_name.cpp -scan_name.h -secmem.h stl_util.h types.h ui.cpp @@ -39,9 +33,3 @@ version.cpp version.h xor_buf.h </add> - -<requires> -alloc -filters -libstate -</requires> diff --git a/src/utils/scan_name.cpp b/src/utils/scan_name.cpp deleted file mode 100644 index ef771871d..000000000 --- a/src/utils/scan_name.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/** -SCAN Name Abstraction -(C) 2008 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/scan_name.h> -#include <botan/parsing.h> -#include <botan/libstate.h> -#include <stdexcept> - -namespace Botan { - -namespace { - -std::vector<std::string> -parse_and_deref_aliases(const std::string& algo_spec) - { - std::vector<std::string> parts = parse_algorithm_name(algo_spec); - std::vector<std::string> out; - - for(size_t i = 0; i != parts.size(); ++i) - { - std::string part_i = global_state().deref_alias(parts[i]); - - if(i == 0 && part_i.find_first_of(",()") != std::string::npos) - { - std::vector<std::string> parts_i = parse_and_deref_aliases(part_i); - - for(size_t j = 0; j != parts_i.size(); ++j) - out.push_back(parts_i[j]); - } - else - out.push_back(part_i); - } - - return out; - } - -} - -SCAN_Name::SCAN_Name(const std::string& algo_spec) - { - orig_algo_spec = algo_spec; - - name = parse_and_deref_aliases(algo_spec); - - if(name.size() == 0) - throw Decoding_Error("Bad SCAN name " + algo_spec); - } - -std::string SCAN_Name::arg(u32bit i) const - { - if(i >= arg_count()) - throw std::range_error("SCAN_Name::argument"); - return name[i+1]; - } - -std::string SCAN_Name::arg(u32bit i, const std::string& def_value) const - { - if(i >= arg_count()) - return def_value; - return name[i+1]; - } - -u32bit SCAN_Name::arg_as_u32bit(u32bit i, u32bit def_value) const - { - if(i >= arg_count()) - return def_value; - return to_u32bit(name[i+1]); - } - -} diff --git a/src/utils/scan_name.h b/src/utils/scan_name.h deleted file mode 100644 index 9e7af40d6..000000000 --- a/src/utils/scan_name.h +++ /dev/null @@ -1,77 +0,0 @@ -/** -SCAN Name Abstraction -(C) 2008 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_SCAN_NAME_H__ -#define BOTAN_SCAN_NAME_H__ - -#include <botan/types.h> -#include <string> -#include <vector> -#include <set> - -namespace Botan { - -/** -A class encapsulating a SCAN name (similar to JCE conventions) -http://www.users.zetnet.co.uk/hopwood/crypto/scan/ -*/ -class SCAN_Name - { - public: - /** - @param algo_spec A SCAN name - */ - SCAN_Name(const std::string& algo_spec); - - /** - @return the original input string - */ - std::string as_string() const { return orig_algo_spec; } - - /** - @return the algorithm name - */ - std::string algo_name() const { return name[0]; } - - /** - @return the number of arguments - */ - u32bit arg_count() const { return name.size() - 1; } - - /** - @return if the number of arguments is between lower and upper - */ - bool arg_count_between(u32bit lower, u32bit upper) const - { return ((arg_count() >= lower) && (arg_count() <= upper)); } - - /** - @param i which argument - @return the ith argument - */ - std::string arg(u32bit i) const; - - /** - @param i which argument - @param def_value the default value - @return the ith argument or the default value - */ - std::string arg(u32bit i, const std::string& def_value) const; - - /** - @param i which argument - @param def_value the default value - @return the ith argument as a u32bit, or the default value - */ - u32bit arg_as_u32bit(u32bit i, u32bit def_value) const; - private: - std::string orig_algo_spec; - std::vector<std::string> name; - }; - -} - -#endif diff --git a/src/utils/secmem.h b/src/utils/secmem.h deleted file mode 100644 index d64a376ca..000000000 --- a/src/utils/secmem.h +++ /dev/null @@ -1,438 +0,0 @@ -/* -* Secure Memory Buffers -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_SECURE_MEMORY_BUFFERS_H__ -#define BOTAN_SECURE_MEMORY_BUFFERS_H__ - -#include <botan/allocate.h> -#include <botan/mem_ops.h> -#include <algorithm> - -namespace Botan { - -/** -* This class represents variable length memory buffers. -*/ -template<typename T> -class MemoryRegion - { - public: - /** - * Find out the size of the buffer, i.e. how many objects of type T it - * contains. - * @return the size of the buffer - */ - u32bit size() const { return used; } - - /** - * Find out whether this buffer is empty. - * @return true if the buffer is empty, false otherwise - */ - bool is_empty() const { return (used == 0); } - - /** - * Find out whether this buffer is non-empty - * @return true if the buffer is non-empty, false otherwise - */ - bool has_items() const { return (used != 0); } - - /** - * Get a pointer to the first element in the buffer. - * @return a pointer to the first element in the buffer - */ - operator T* () { return buf; } - - /** - * Get a constant pointer to the first element in the buffer. - * @return a constant pointer to the first element in the buffer - */ - operator const T* () const { return buf; } - - /** - * Get a pointer to the first element in the buffer. - * @return a pointer to the first element in the buffer - */ - T* begin() { return buf; } - - /** - * Get a constant pointer to the first element in the buffer. - * @return a constant pointer to the first element in the buffer - */ - const T* begin() const { return buf; } - - /** - * Get a pointer to the last element in the buffer. - * @return a pointer to the last element in the buffer - */ - T* end() { return (buf + size()); } - - /** - * Get a constant pointer to the last element in the buffer. - * @return a constant pointer to the last element in the buffer - */ - const T* end() const { return (buf + size()); } - - /** - * Check two buffers for equality. - * @return true iff the content of both buffers is byte-wise equal - */ - bool operator==(const MemoryRegion<T>& other) const - { - return (size() == other.size() && - same_mem(buf, other.buf, size())); - } - - /** - * Compare two buffers lexicographically. - * @return true if this buffer is lexicographically smaller than other. - */ - bool operator<(const MemoryRegion<T>& other) const; - - /** - * Check two buffers for inequality. - * @return false if the content of both buffers is byte-wise equal, true - * otherwise. - */ - bool operator!=(const MemoryRegion<T>& in) const - { return (!(*this == in)); } - - /** - * Copy the contents of another buffer into this buffer. - * The former contents of *this are discarded. - * @param in the buffer to copy the contents from. - * @return a reference to *this - */ - MemoryRegion<T>& operator=(const MemoryRegion<T>& in) - { if(this != &in) set(in); return (*this); } - - /** - * The use of this function is discouraged because of the risk of memory - * errors. Use MemoryRegion<T>::set() - * instead. - * 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. - * @param in the array to copy the contents from - * @param n the length of in - */ - void copy(const T in[], u32bit n) - { copy(0, in, n); } - - /** - * The use of this function is discouraged because of the risk of memory - * errors. Use MemoryRegion<T>::set() - * instead. - * 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. - * @param off the offset position inside this buffer to start inserting - * the copied bytes - * @param in the array to copy the contents from - * @param n the length of in - */ - void copy(u32bit off, const T in[], u32bit n) - { copy_mem(buf + off, in, (n > size() - off) ? (size() - off) : n); } - - /** - * Set the contents of this according to the argument. The size of - * *this is increased if necessary. - * @param in the array of objects of type T to copy the contents from - * @param n the size of array in - */ - void set(const T in[], u32bit n) { create(n); copy(in, n); } - - /** - * Set the contents of this according to the argument. The size of - * *this is increased if necessary. - * @param in the buffer to copy the contents from - */ - void set(const MemoryRegion<T>& in) { set(in.begin(), in.size()); } - - /** - * Append data to the end of this buffer. - * @param data the array containing the data to append - * @param n the size of the array data - */ - void append(const T data[], u32bit n) - { grow_to(size()+n); copy(size() - n, data, n); } - - /** - * Append a single element. - * @param x the element to append - */ - void append(T x) { append(&x, 1); } - - /** - * Append data to the end of this buffer. - * @param data the buffer containing the data to append - */ - void append(const MemoryRegion<T>& x) { append(x.begin(), x.size()); } - - /** - * Zeroise the bytes of this buffer. The length remains unchanged. - */ - void clear() { clear_mem(buf, allocated); } - - /** - * Reset this buffer to an empty buffer with size zero. - */ - void destroy() { create(0); } - - /** - * Reset this buffer to a buffer of specified length. The content will be - * initialized to zero bytes. - * @param n the new length of the buffer - */ - void create(u32bit n); - - /** - * Preallocate memory, so that this buffer can grow up to size n without - * having to perform any actual memory allocations. (This is - * the same principle as for std::vector::reserve().) - */ - void grow_to(u32bit N); - - /** - * Swap this buffer with another object. - */ - void swap(MemoryRegion<T>& other); - - ~MemoryRegion() { deallocate(buf, allocated); } - protected: - MemoryRegion() { buf = 0; alloc = 0; used = allocated = 0; } - MemoryRegion(const MemoryRegion<T>& other) - { - buf = 0; - used = allocated = 0; - alloc = other.alloc; - set(other.buf, other.used); - } - - void init(bool locking, u32bit length = 0) - { alloc = Allocator::get(locking); create(length); } - private: - T* allocate(u32bit n) - { - return static_cast<T*>(alloc->allocate(sizeof(T)*n)); - } - - void deallocate(T* p, u32bit n) - { alloc->deallocate(p, sizeof(T)*n); } - - T* buf; - u32bit used; - u32bit allocated; - Allocator* alloc; - }; - -/* -* Create a new buffer -*/ -template<typename T> -void MemoryRegion<T>::create(u32bit n) - { - if(n <= allocated) { clear(); used = n; return; } - deallocate(buf, allocated); - buf = allocate(n); - allocated = used = n; - } - -/* -* Increase the size of the buffer -*/ -template<typename T> -void MemoryRegion<T>::grow_to(u32bit n) - { - if(n > used && n <= allocated) - { - clear_mem(buf + used, n - used); - used = n; - return; - } - else if(n > allocated) - { - T* new_buf = allocate(n); - copy_mem(new_buf, buf, used); - deallocate(buf, allocated); - buf = new_buf; - allocated = used = n; - } - } - -/* -* Compare this buffer with another one -*/ -template<typename T> -bool MemoryRegion<T>::operator<(const MemoryRegion<T>& in) const - { - if(size() < in.size()) return true; - if(size() > in.size()) return false; - - for(u32bit j = 0; j != size(); j++) - { - if(buf[j] < in[j]) return true; - if(buf[j] > in[j]) return false; - } - - return false; - } - -/* -* Swap this buffer with another one -*/ -template<typename T> -void MemoryRegion<T>::swap(MemoryRegion<T>& x) - { - std::swap(buf, x.buf); - std::swap(used, x.used); - std::swap(allocated, x.allocated); - std::swap(alloc, x.alloc); - } - -/** -* This class represents variable length buffers that do not -* make use of memory locking. -*/ -template<typename T> -class MemoryVector : public MemoryRegion<T> - { - public: - /** - * Copy the contents of another buffer into this buffer. - * @param in the buffer to copy the contents from - * @return a reference to *this - */ - MemoryVector<T>& operator=(const MemoryRegion<T>& in) - { if(this != &in) set(in); return (*this); } - - /** - * Create a buffer of the specified length. - * @param n the length of the buffer to create. - - */ - MemoryVector(u32bit n = 0) { MemoryRegion<T>::init(false, n); } - - /** - * Create a buffer with the specified contents. - * @param in the array containing the data to be initially copied - * into the newly created buffer - * @param n the size of the arry in - */ - MemoryVector(const T in[], u32bit n) - { MemoryRegion<T>::init(false); set(in, n); } - - /** - * Copy constructor. - */ - MemoryVector(const MemoryRegion<T>& in) - { MemoryRegion<T>::init(false); set(in); } - - /** - * Create a buffer whose content is the concatenation of two other - * buffers. - * @param in1 the first part of the new contents - * @param in2 the contents to be appended to in1 - */ - MemoryVector(const MemoryRegion<T>& in1, const MemoryRegion<T>& in2) - { MemoryRegion<T>::init(false); set(in1); append(in2); } - }; - -/** -* This class represents variable length buffers using the operating -* systems capability to lock memory, i.e. keeping it from being -* swapped out to disk. In this way, a security hole allowing attackers -* to find swapped out secret keys is closed. Please refer to -* Botan::InitializerOptions::secure_memory() for restrictions and -* further details. -*/ -template<typename T> -class SecureVector : public MemoryRegion<T> - { - public: - /** - * Copy the contents of another buffer into this buffer. - * @param in the buffer to copy the contents from - * @return a reference to *this - */ - SecureVector<T>& operator=(const MemoryRegion<T>& in) - { if(this != &in) set(in); return (*this); } - - /** - * Create a buffer of the specified length. - * @param n the length of the buffer to create. - - */ - SecureVector(u32bit n = 0) { MemoryRegion<T>::init(true, n); } - - /** - * Create a buffer with the specified contents. - * @param in the array containing the data to be initially copied - * into the newly created buffer - * @param n the size of the array in - */ - SecureVector(const T in[], u32bit n) - { MemoryRegion<T>::init(true); set(in, n); } - - /** - * Create a buffer with contents specified contents. - * @param in the buffer holding the contents that will be - * copied into the newly created buffer. - */ - SecureVector(const MemoryRegion<T>& in) - { MemoryRegion<T>::init(true); set(in); } - - /** - * Create a buffer whose content is the concatenation of two other - * buffers. - * @param in1 the first part of the new contents - * @param in2 the contents to be appended to in1 - */ - SecureVector(const MemoryRegion<T>& in1, const MemoryRegion<T>& in2) - { MemoryRegion<T>::init(true); set(in1); append(in2); } - }; - -/** -* This class represents fixed length buffers using the operating -* systems capability to lock memory, i.e. keeping it from being -* swapped out to disk. In this way, a security hole allowing attackers -* to find swapped out secret keys is closed. Please refer to -* Botan::InitializerOptions::secure_memory() for restrictions and -* further details. -*/ -template<typename T, u32bit L> -class SecureBuffer : public MemoryRegion<T> - { - public: - /** - * Copy the contents of another buffer into this buffer. - * @param in the buffer to copy the contents from - * @return a reference to *this - */ - SecureBuffer<T,L>& operator=(const SecureBuffer<T,L>& in) - { if(this != &in) set(in); return (*this); } - - /** - * Create a buffer of the length L. - */ - SecureBuffer() { MemoryRegion<T>::init(true, L); } - - /** - * Create a buffer of size L with the specified contents. - * @param in the array containing the data to be initially copied - * into the newly created buffer - * @param n the size of the array in - */ - SecureBuffer(const T in[], u32bit n) - { MemoryRegion<T>::init(true, L); copy(in, n); } - private: - SecureBuffer<T, L>& operator=(const MemoryRegion<T>& in) - { if(this != &in) set(in); return (*this); } - }; - -} - -#endif |