Botan
1.11.15
|
00001 /* 00002 * DES 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_DES_H__ 00009 #define BOTAN_DES_H__ 00010 00011 #include <botan/block_cipher.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * DES 00017 */ 00018 class BOTAN_DLL DES : public Block_Cipher_Fixed_Params<8, 8> 00019 { 00020 public: 00021 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00022 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00023 00024 void clear(); 00025 std::string name() const { return "DES"; } 00026 BlockCipher* clone() const { return new DES; } 00027 private: 00028 void key_schedule(const byte[], size_t); 00029 00030 secure_vector<u32bit> round_key; 00031 }; 00032 00033 /** 00034 * Triple DES 00035 */ 00036 class BOTAN_DLL TripleDES : public Block_Cipher_Fixed_Params<8, 16, 24, 8> 00037 { 00038 public: 00039 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00040 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00041 00042 void clear(); 00043 std::string name() const { return "TripleDES"; } 00044 BlockCipher* clone() const { return new TripleDES; } 00045 private: 00046 void key_schedule(const byte[], size_t); 00047 00048 secure_vector<u32bit> round_key; 00049 }; 00050 00051 /* 00052 * DES Tables 00053 */ 00054 extern const u32bit DES_SPBOX1[256]; 00055 extern const u32bit DES_SPBOX2[256]; 00056 extern const u32bit DES_SPBOX3[256]; 00057 extern const u32bit DES_SPBOX4[256]; 00058 extern const u32bit DES_SPBOX5[256]; 00059 extern const u32bit DES_SPBOX6[256]; 00060 extern const u32bit DES_SPBOX7[256]; 00061 extern const u32bit DES_SPBOX8[256]; 00062 00063 extern const u64bit DES_IPTAB1[256]; 00064 extern const u64bit DES_IPTAB2[256]; 00065 extern const u64bit DES_FPTAB1[256]; 00066 extern const u64bit DES_FPTAB2[256]; 00067 00068 } 00069 00070 #endif