aboutsummaryrefslogtreecommitdiffstats
path: root/include/symkey.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-18 18:33:19 +0000
committerlloyd <[email protected]>2006-05-18 18:33:19 +0000
commita2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch)
treead3d6c4fcc8dd0f403f8105598943616246fe172 /include/symkey.h
Initial checkin1.5.6
Diffstat (limited to 'include/symkey.h')
-rw-r--r--include/symkey.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/symkey.h b/include/symkey.h
new file mode 100644
index 000000000..c3b5789d5
--- /dev/null
+++ b/include/symkey.h
@@ -0,0 +1,81 @@
+/*************************************************
+* OctetString Header File *
+* (C) 1999-2006 The Botan Project *
+*************************************************/
+
+#ifndef BOTAN_SYMKEY_H__
+#define BOTAN_SYMKEY_H__
+
+#include <botan/secmem.h>
+#include <botan/enums.h>
+#include <string>
+
+namespace Botan {
+
+/*************************************************
+* Octet String *
+*************************************************/
+class OctetString
+ {
+ public:
+ u32bit length() const { return bits.size(); }
+ SecureVector<byte> bits_of() const { return bits; }
+
+ const byte* begin() const { return bits.begin(); }
+ const byte* end() const { return bits.end(); }
+
+ std::string as_string() const;
+
+ OctetString& operator^=(const OctetString&);
+
+ void set_odd_parity();
+
+ void change(u32bit);
+ void change(const std::string&);
+ void change(const byte[], u32bit);
+ void change(const MemoryRegion<byte>& in) { bits = in; }
+
+ OctetString(const std::string& str = "") { change(str); }
+ OctetString(const byte in[], u32bit len) { change(in, len); }
+ OctetString(const MemoryRegion<byte>& in) { change(in); }
+ private:
+ SecureVector<byte> bits;
+ };
+
+/*************************************************
+* Operations on Octet Strings *
+*************************************************/
+bool operator==(const OctetString&, const OctetString&);
+bool operator!=(const OctetString&, const OctetString&);
+OctetString operator+(const OctetString&, const OctetString&);
+OctetString operator^(const OctetString&, const OctetString&);
+
+/*************************************************
+* Symmetric Key *
+*************************************************/
+class SymmetricKey : public OctetString
+ {
+ public:
+ SymmetricKey(u32bit len) { change(len); }
+ SymmetricKey(const std::string& str = "") : OctetString(str) {}
+ SymmetricKey(const byte in[], u32bit l) : OctetString(in, l) {}
+ SymmetricKey(const MemoryRegion<byte>& in) : OctetString(in) {}
+ SymmetricKey(const OctetString& os) : OctetString(os) {}
+ };
+
+/*************************************************
+* Initialization Vector *
+*************************************************/
+class InitializationVector : public OctetString
+ {
+ public:
+ InitializationVector(u32bit len) { change(len); }
+ InitializationVector(const std::string& str = "") : OctetString(str) {}
+ InitializationVector(const byte in[], u32bit l) : OctetString(in, l) {}
+ InitializationVector(const MemoryRegion<byte>& in) : OctetString(in) {}
+ InitializationVector(const OctetString& os) : OctetString(os) {}
+ };
+
+}
+
+#endif