aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/block_cipher.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-18 20:32:36 +0000
committerlloyd <[email protected]>2012-05-18 20:32:36 +0000
commitc691561f3198f481c13457433efbccc1c9fcd898 (patch)
treea45ea2c5a30e0cb009fbcb68a61ef39332ff790c /src/block/block_cipher.h
parentd76700f01c7ecac5633edf75f8d7408b46c5dbac (diff)
Fairly huge update that replaces the old secmem types with std::vector
using a custom allocator. Currently our allocator just does new/delete with a memset before deletion, and the mmap and mlock allocators have been removed.
Diffstat (limited to 'src/block/block_cipher.h')
-rw-r--r--src/block/block_cipher.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/block/block_cipher.h b/src/block/block_cipher.h
index 8e820fc5a..4a07bb048 100644
--- a/src/block/block_cipher.h
+++ b/src/block/block_cipher.h
@@ -75,6 +75,50 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
/**
* Encrypt one or more blocks
+ * @param block the input/output buffer (multiple of block_size())
+ */
+ template<typename Alloc>
+ void encrypt(std::vector<byte, Alloc>& block) const
+ {
+ return encrypt_n(&block[0], &block[0], block.size() / block_size());
+ }
+
+ /**
+ * Decrypt one or more blocks
+ * @param block the input/output buffer (multiple of block_size())
+ */
+ template<typename Alloc>
+ void decrypt(std::vector<byte, Alloc>& block) const
+ {
+ return decrypt_n(&block[0], &block[0], block.size() / block_size());
+ }
+
+ /**
+ * Encrypt one or more blocks
+ * @param in the input buffer (multiple of block_size())
+ * @param out the output buffer (same size as in)
+ */
+ template<typename Alloc, typename Alloc2>
+ void encrypt(const std::vector<byte, Alloc>& in,
+ std::vector<byte, Alloc2>& out) const
+ {
+ return encrypt_n(&in[0], &out[0], in.size() / block_size());
+ }
+
+ /**
+ * Decrypt one or more blocks
+ * @param in the input buffer (multiple of block_size())
+ * @param out the output buffer (same size as in)
+ */
+ template<typename Alloc, typename Alloc2>
+ void decrypt(const std::vector<byte, Alloc>& in,
+ std::vector<byte, Alloc2>& out) const
+ {
+ return decrypt_n(&in[0], &out[0], in.size() / block_size());
+ }
+
+ /**
+ * Encrypt one or more blocks
* @param in the input buffer (multiple of block_size())
* @param out the output buffer (same size as in)
* @param blocks the number of blocks to process