aboutsummaryrefslogtreecommitdiffstats
path: root/include/mode_pad.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mode_pad.h')
-rw-r--r--include/mode_pad.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/mode_pad.h b/include/mode_pad.h
new file mode 100644
index 000000000..38cb55487
--- /dev/null
+++ b/include/mode_pad.h
@@ -0,0 +1,77 @@
+/*************************************************
+* CBC Padding Methods Header File *
+* (C) 1999-2006 The Botan Project *
+*************************************************/
+
+#ifndef BOTAN_CBC_PADDING_H__
+#define BOTAN_CBC_PADDING_H__
+
+#include <botan/base.h>
+#include <string>
+
+namespace Botan {
+
+/*************************************************
+* Block Cipher Mode Padding Method *
+*************************************************/
+class BlockCipherModePaddingMethod : public Algorithm
+ {
+ 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;
+ };
+
+/*************************************************
+* PKCS#7 Padding *
+*************************************************/
+class 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 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 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 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