aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/algo_base/transform.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-10 03:41:59 +0000
committerlloyd <[email protected]>2014-01-10 03:41:59 +0000
commit6894dca64c04936d07048c0e8cbf7e25858548c3 (patch)
tree5d572bfde9fe667dab14e3f04b5285a85d8acd95 /src/lib/algo_base/transform.h
parent9efa3be92442afb3d0b69890a36c7f122df18eda (diff)
Move lib into src
Diffstat (limited to 'src/lib/algo_base/transform.h')
-rw-r--r--src/lib/algo_base/transform.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/lib/algo_base/transform.h b/src/lib/algo_base/transform.h
new file mode 100644
index 000000000..2eec9d85b
--- /dev/null
+++ b/src/lib/algo_base/transform.h
@@ -0,0 +1,99 @@
+/*
+* Transformations of data
+* (C) 2013 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_TRANSFORM_H__
+#define BOTAN_TRANSFORM_H__
+
+#include <botan/sym_algo.h>
+#include <string>
+
+namespace Botan {
+
+/**
+* Interface for general transformations on data
+*/
+class BOTAN_DLL Transformation : public SymmetricAlgorithm
+ {
+ public:
+ /**
+ * Begin processing a message.
+ * @param nonce the per message nonce
+ */
+ template<typename Alloc>
+ secure_vector<byte> start_vec(const std::vector<byte, Alloc>& nonce)
+ {
+ return start(&nonce[0], nonce.size());
+ }
+
+ /**
+ * Begin processing a message.
+ * @param nonce the per message nonce
+ * @param nonce_len length of nonce
+ */
+ virtual secure_vector<byte> start(const byte nonce[], size_t nonce_len) = 0;
+
+ /**
+ * Process some data. Input must be in size update_granularity() byte blocks.
+ * @param blocks in/out paramter which will possibly be resized
+ */
+ virtual void update(secure_vector<byte>& blocks, size_t offset = 0) = 0;
+
+ /**
+ * Complete processing of a message.
+ *
+ * @param final_block in/out parameter which must be at least
+ * minimum_final_size() bytes, and will be set to any final output
+ * @param offset an offset into final_block to begin processing
+ */
+ virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+
+ /**
+ * Returns the size of the output if this transform is used to process a
+ * message with input_length bytes. Will throw if unable to give a precise
+ * answer.
+ */
+ virtual size_t output_length(size_t input_length) const = 0;
+
+ /**
+ * @return size of required blocks to update
+ */
+ virtual size_t update_granularity() const = 0;
+
+ /**
+ * @return required minimium size to finalize() - may be any
+ * length larger than this.
+ */
+ virtual size_t minimum_final_size() const = 0;
+
+ /**
+ * Return the default size for a nonce
+ */
+ virtual size_t default_nonce_length() const = 0;
+
+ BOTAN_DEPRECATED("Use default_nonce_length")
+ size_t default_nonce_size() const
+ { return default_nonce_length(); }
+
+ /**
+ * Return true iff nonce_len is a valid length for the nonce
+ */
+ virtual bool valid_nonce_length(size_t nonce_len) const = 0;
+
+ /**
+ * Return some short name describing the provider of this tranformation.
+ * Useful in cases where multiple implementations are available (eg,
+ * different implementations of AES). Default "core" is used for the
+ * 'standard' implementation included in the library.
+ */
+ virtual std::string provider() const { return "core"; }
+
+ virtual ~Transformation() {}
+ };
+
+}
+
+#endif