aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/base.cpp76
-rw-r--r--src/core/base.h89
-rw-r--r--src/core/buf_comp.cpp86
-rw-r--r--src/core/buf_comp.h104
-rw-r--r--src/core/hash.h2
-rw-r--r--src/core/info.txt2
6 files changed, 193 insertions, 166 deletions
diff --git a/src/core/base.cpp b/src/core/base.cpp
index 4fdf9562d..ede199685 100644
--- a/src/core/base.cpp
+++ b/src/core/base.cpp
@@ -69,13 +69,6 @@ StreamCipher::StreamCipher(u32bit key_min, u32bit key_max, u32bit key_mod,
}
/*************************************************
-* BufferedComputation Constructor *
-*************************************************/
-BufferedComputation::BufferedComputation(u32bit olen) : OUTPUT_LENGTH(olen)
- {
- }
-
-/*************************************************
* Default StreamCipher Resync Operation *
*************************************************/
void StreamCipher::resync(const byte[], u32bit length)
@@ -93,73 +86,4 @@ void StreamCipher::seek(u32bit)
throw Exception("The stream cipher " + name() + " does not support seek()");
}
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-void BufferedComputation::update(const byte in[], u32bit n)
- {
- add_data(in, n);
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-void BufferedComputation::update(const MemoryRegion<byte>& in)
- {
- add_data(in, in.size());
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-void BufferedComputation::update(const std::string& str)
- {
- update(reinterpret_cast<const byte*>(str.data()), str.size());
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-void BufferedComputation::update(byte in)
- {
- update(&in, 1);
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-SecureVector<byte> BufferedComputation::final()
- {
- SecureVector<byte> output(OUTPUT_LENGTH);
- final_result(output);
- return output;
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-SecureVector<byte> BufferedComputation::process(const byte in[], u32bit len)
- {
- update(in, len);
- return final();
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-SecureVector<byte> BufferedComputation::process(const MemoryRegion<byte>& in)
- {
- update(in, in.size());
- return final();
- }
-
-/*************************************************
-* Hashing/MACing *
-*************************************************/
-SecureVector<byte> BufferedComputation::process(const std::string& in)
- {
- update(in);
- return final();
- }
-
}
diff --git a/src/core/base.h b/src/core/base.h
index 64186f903..b9be665b1 100644
--- a/src/core/base.h
+++ b/src/core/base.h
@@ -209,95 +209,6 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
virtual void cipher(const byte[], byte[], u32bit) = 0;
};
-/**
-* This class represents any kind of computation which
-* uses an internal state,
-* such as hash functions.
-*/
-class BOTAN_DLL BufferedComputation
- {
- public:
-
- /**
- * The length of the output of this function in bytes.
- */
- const u32bit OUTPUT_LENGTH;
-
- /**
- * Add new input to process.
- * @param in the input to process as a byte array
- * @param the length of the byte array
- */
- void update(const byte in[], u32bit length);
-
- /**
- * Add new input to process.
- * @param in the input to process as a MemoryRegion
- */
- void update(const MemoryRegion<byte>& in);
-
- /**
- * Add new input to process.
- * @param in the input to process as a std::string. Will be interpreted
- * as a byte array based on
- * the strings encoding.
- */
- void update(const std::string&);
-
- /**
- * Process a single byte.
- * @param in the byte to process
- */
- void update(byte in);
-
- /**
- * Complete the computation and retrieve the
- * final result.
- * @param out The byte array to be filled with the result.
- * Must be of length OUTPUT_LENGTH.
- */
- void final(byte out[]) { final_result(out); }
-
- /**
- * Complete the computation and retrieve the
- * final result.
- * @return a SecureVector holding the result
- */
- SecureVector<byte> final();
-
- /**
- * Update and finalize computation. Does the same as calling update()
- * and final() consecutively.
- * @param in the input to process as a byte array
- * @param length the length of the byte array
- * @result the result of the call to final()
- */
- SecureVector<byte> process(const byte in[], u32bit length);
-
- /**
- * Update and finalize computation. Does the same as calling update()
- * and final() consecutively.
- * @param in the input to process
- * @result the result of the call to final()
- */
- SecureVector<byte> process(const MemoryRegion<byte>& in);
-
- /**
- * Update and finalize computation. Does the same as calling update()
- * and final() consecutively.
- * @param in the input to process as a string
- * @result the result of the call to final()
- */
- SecureVector<byte> process(const std::string& in);
-
- BufferedComputation(u32bit);
- virtual ~BufferedComputation() {}
- private:
- BufferedComputation& operator=(const BufferedComputation&);
- virtual void add_data(const byte[], u32bit) = 0;
- virtual void final_result(byte[]) = 0;
- };
-
}
#endif
diff --git a/src/core/buf_comp.cpp b/src/core/buf_comp.cpp
new file mode 100644
index 000000000..1611d6ab5
--- /dev/null
+++ b/src/core/buf_comp.cpp
@@ -0,0 +1,86 @@
+/**
+* BufferedComputation
+* (C) 1999-2007 Jack Lloyd
+*/
+
+#include <botan/buf_comp.h>
+
+namespace Botan {
+
+/*************************************************
+* BufferedComputation Constructor *
+*************************************************/
+BufferedComputation::BufferedComputation(u32bit olen) : OUTPUT_LENGTH(olen)
+ {
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+void BufferedComputation::update(const byte in[], u32bit n)
+ {
+ add_data(in, n);
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+void BufferedComputation::update(const MemoryRegion<byte>& in)
+ {
+ add_data(in, in.size());
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+void BufferedComputation::update(const std::string& str)
+ {
+ update(reinterpret_cast<const byte*>(str.data()), str.size());
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+void BufferedComputation::update(byte in)
+ {
+ update(&in, 1);
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+SecureVector<byte> BufferedComputation::final()
+ {
+ SecureVector<byte> output(OUTPUT_LENGTH);
+ final_result(output);
+ return output;
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+SecureVector<byte> BufferedComputation::process(const byte in[], u32bit len)
+ {
+ update(in, len);
+ return final();
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+SecureVector<byte> BufferedComputation::process(const MemoryRegion<byte>& in)
+ {
+ update(in, in.size());
+ return final();
+ }
+
+/*************************************************
+* Hashing/MACing *
+*************************************************/
+SecureVector<byte> BufferedComputation::process(const std::string& in)
+ {
+ update(in);
+ return final();
+ }
+
+}
diff --git a/src/core/buf_comp.h b/src/core/buf_comp.h
new file mode 100644
index 000000000..dd7430c50
--- /dev/null
+++ b/src/core/buf_comp.h
@@ -0,0 +1,104 @@
+/**
+* BufferedComputation
+* (C) 1999-2007 Jack Lloyd
+*/
+
+#ifndef BOTAN_BUFFERED_COMPUTATION_H__
+#define BOTAN_BUFFERED_COMPUTATION_H__
+
+#include <botan/secmem.h>
+
+namespace Botan {
+
+/**
+* This class represents any kind of computation which
+* uses an internal state,
+* such as hash functions.
+*/
+class BOTAN_DLL BufferedComputation
+ {
+ public:
+
+ /**
+ * The length of the output of this function in bytes.
+ */
+ const u32bit OUTPUT_LENGTH;
+
+ /**
+ * Add new input to process.
+ * @param in the input to process as a byte array
+ * @param the length of the byte array
+ */
+ void update(const byte in[], u32bit length);
+
+ /**
+ * Add new input to process.
+ * @param in the input to process as a MemoryRegion
+ */
+ void update(const MemoryRegion<byte>& in);
+
+ /**
+ * Add new input to process.
+ * @param in the input to process as a std::string. Will be interpreted
+ * as a byte array based on
+ * the strings encoding.
+ */
+ void update(const std::string&);
+
+ /**
+ * Process a single byte.
+ * @param in the byte to process
+ */
+ void update(byte in);
+
+ /**
+ * Complete the computation and retrieve the
+ * final result.
+ * @param out The byte array to be filled with the result.
+ * Must be of length OUTPUT_LENGTH.
+ */
+ void final(byte out[]) { final_result(out); }
+
+ /**
+ * Complete the computation and retrieve the
+ * final result.
+ * @return a SecureVector holding the result
+ */
+ SecureVector<byte> final();
+
+ /**
+ * Update and finalize computation. Does the same as calling update()
+ * and final() consecutively.
+ * @param in the input to process as a byte array
+ * @param length the length of the byte array
+ * @result the result of the call to final()
+ */
+ SecureVector<byte> process(const byte in[], u32bit length);
+
+ /**
+ * Update and finalize computation. Does the same as calling update()
+ * and final() consecutively.
+ * @param in the input to process
+ * @result the result of the call to final()
+ */
+ SecureVector<byte> process(const MemoryRegion<byte>& in);
+
+ /**
+ * Update and finalize computation. Does the same as calling update()
+ * and final() consecutively.
+ * @param in the input to process as a string
+ * @result the result of the call to final()
+ */
+ SecureVector<byte> process(const std::string& in);
+
+ BufferedComputation(u32bit);
+ virtual ~BufferedComputation() {}
+ private:
+ BufferedComputation& operator=(const BufferedComputation&);
+ virtual void add_data(const byte[], u32bit) = 0;
+ virtual void final_result(byte[]) = 0;
+ };
+
+}
+
+#endif
diff --git a/src/core/hash.h b/src/core/hash.h
index 9d4013b75..d42ee0d82 100644
--- a/src/core/hash.h
+++ b/src/core/hash.h
@@ -7,7 +7,7 @@
#define BOTAN_HASH_FUNCTION_BASE_CLASS_H__
#include <botan/types.h>
-#include <botan/base.h>
+#include <botan/buf_comp.h>
#include <string>
namespace Botan {
diff --git a/src/core/info.txt b/src/core/info.txt
index 34705048b..f40148dd9 100644
--- a/src/core/info.txt
+++ b/src/core/info.txt
@@ -19,6 +19,8 @@ base.cpp
base.h
botan.h
data_src.cpp
+buf_comp.h
+buf_comp.cpp
data_src.h
defalloc.cpp
defalloc.h