Botan
1.11.15
|
00001 /* 00002 * Serpent 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_SERPENT_H__ 00009 #define BOTAN_SERPENT_H__ 00010 00011 #include <botan/block_cipher.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * Serpent, an AES finalist 00017 */ 00018 class BOTAN_DLL Serpent : public Block_Cipher_Fixed_Params<16, 16, 32, 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 "Serpent"; } 00026 BlockCipher* clone() const { return new Serpent; } 00027 protected: 00028 /** 00029 * For use by subclasses using SIMD, asm, etc 00030 * @return const reference to the key schedule 00031 */ 00032 const secure_vector<u32bit>& get_round_keys() const 00033 { return round_key; } 00034 00035 /** 00036 * For use by subclasses that implement the key schedule 00037 * @param ks is the new key schedule value to set 00038 */ 00039 void set_round_keys(const u32bit ks[132]) 00040 { 00041 round_key.assign(&ks[0], &ks[132]); 00042 } 00043 00044 private: 00045 void key_schedule(const byte key[], size_t length); 00046 secure_vector<u32bit> round_key; 00047 }; 00048 00049 } 00050 00051 #endif