aboutsummaryrefslogtreecommitdiffstats
path: root/src/modes/mode_pad/mode_pad.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/modes/mode_pad/mode_pad.h')
-rw-r--r--src/modes/mode_pad/mode_pad.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/modes/mode_pad/mode_pad.h b/src/modes/mode_pad/mode_pad.h
new file mode 100644
index 000000000..4041efcdc
--- /dev/null
+++ b/src/modes/mode_pad/mode_pad.h
@@ -0,0 +1,79 @@
+/*************************************************
+* CBC Padding Methods Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_CBC_PADDING_H__
+#define BOTAN_CBC_PADDING_H__
+
+#include <botan/base.h>
+#include <string>
+
+namespace Botan {
+
+/*************************************************
+* Block Cipher Mode Padding Method *
+*************************************************/
+class BOTAN_DLL BlockCipherModePaddingMethod
+ {
+ public:
+ virtual void pad(byte[], u32bit, u32bit) const = 0;
+ virtual u32bit unpad(const byte[], u32bit) const = 0;
+ virtual u32bit pad_bytes(u32bit, u32bit) const;
+ virtual bool valid_blocksize(u32bit) const = 0;
+ virtual std::string name() const = 0;
+ virtual ~BlockCipherModePaddingMethod() {}
+ };
+
+/*************************************************
+* PKCS#7 Padding *
+*************************************************/
+class BOTAN_DLL PKCS7_Padding : public BlockCipherModePaddingMethod
+ {
+ public:
+ void pad(byte[], u32bit, u32bit) const;
+ u32bit unpad(const byte[], u32bit) const;
+ bool valid_blocksize(u32bit) const;
+ std::string name() const { return "PKCS7"; }
+ };
+
+/*************************************************
+* ANSI X9.23 Padding *
+*************************************************/
+class BOTAN_DLL ANSI_X923_Padding : public BlockCipherModePaddingMethod
+ {
+ public:
+ void pad(byte[], u32bit, u32bit) const;
+ u32bit unpad(const byte[], u32bit) const;
+ bool valid_blocksize(u32bit) const;
+ std::string name() const { return "X9.23"; }
+ };
+
+/*************************************************
+* One And Zeros Padding *
+*************************************************/
+class BOTAN_DLL OneAndZeros_Padding : public BlockCipherModePaddingMethod
+ {
+ public:
+ void pad(byte[], u32bit, u32bit) const;
+ u32bit unpad(const byte[], u32bit) const;
+ bool valid_blocksize(u32bit) const;
+ std::string name() const { return "OneAndZeros"; }
+ };
+
+/*************************************************
+* Null Padding *
+*************************************************/
+class BOTAN_DLL Null_Padding : public BlockCipherModePaddingMethod
+ {
+ public:
+ void pad(byte[], u32bit, u32bit) const { return; }
+ u32bit unpad(const byte[], u32bit size) const { return size; }
+ u32bit pad_bytes(u32bit, u32bit) const { return 0; }
+ bool valid_blocksize(u32bit) const { return true; }
+ std::string name() const { return "NoPadding"; }
+ };
+
+}
+
+#endif