00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BOTAN_CBC_PADDING_H__
00009 #define BOTAN_CBC_PADDING_H__
00010
00011 #include <botan/types.h>
00012 #include <string>
00013
00014 namespace Botan {
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 class BOTAN_DLL BlockCipherModePaddingMethod
00026 {
00027 public:
00028
00029
00030
00031
00032
00033 virtual void pad(byte block[],
00034 u32bit size,
00035 u32bit current_position) const = 0;
00036
00037
00038
00039
00040
00041 virtual u32bit unpad(const byte block[],
00042 u32bit size) const = 0;
00043
00044
00045
00046
00047
00048
00049 virtual u32bit pad_bytes(u32bit block_size,
00050 u32bit position) const;
00051
00052
00053
00054
00055
00056 virtual bool valid_blocksize(u32bit block_size) const = 0;
00057
00058
00059
00060
00061 virtual std::string name() const = 0;
00062
00063
00064
00065
00066 virtual ~BlockCipherModePaddingMethod() {}
00067 };
00068
00069
00070
00071
00072 class BOTAN_DLL PKCS7_Padding : public BlockCipherModePaddingMethod
00073 {
00074 public:
00075 void pad(byte[], u32bit, u32bit) const;
00076 u32bit unpad(const byte[], u32bit) const;
00077 bool valid_blocksize(u32bit) const;
00078 std::string name() const { return "PKCS7"; }
00079 };
00080
00081
00082
00083
00084 class BOTAN_DLL ANSI_X923_Padding : public BlockCipherModePaddingMethod
00085 {
00086 public:
00087 void pad(byte[], u32bit, u32bit) const;
00088 u32bit unpad(const byte[], u32bit) const;
00089 bool valid_blocksize(u32bit) const;
00090 std::string name() const { return "X9.23"; }
00091 };
00092
00093
00094
00095
00096 class BOTAN_DLL OneAndZeros_Padding : public BlockCipherModePaddingMethod
00097 {
00098 public:
00099 void pad(byte[], u32bit, u32bit) const;
00100 u32bit unpad(const byte[], u32bit) const;
00101 bool valid_blocksize(u32bit) const;
00102 std::string name() const { return "OneAndZeros"; }
00103 };
00104
00105
00106
00107
00108 class BOTAN_DLL Null_Padding : public BlockCipherModePaddingMethod
00109 {
00110 public:
00111 void pad(byte[], u32bit, u32bit) const { return; }
00112 u32bit unpad(const byte[], u32bit size) const { return size; }
00113 u32bit pad_bytes(u32bit, u32bit) const { return 0; }
00114 bool valid_blocksize(u32bit) const { return true; }
00115 std::string name() const { return "NoPadding"; }
00116 };
00117
00118 }
00119
00120 #endif