📄 modebase.cpp
字号:
/************************************************** Block Cipher Mode Base Source File ** (C) 1999-2002 The Botan Project **************************************************/#include <botan/modebase.h>#include <botan/lookup.h>namespace Botan {/************************************************** Block Cipher Mode Constructor **************************************************/BlockCipherMode::BlockCipherMode(const std::string& cipher_name, const std::string& cipher_mode_name, const SymmetricKey& key, const BlockCipherModeIV& iv, u32bit buf_size_mult) : BLOCK_SIZE(block_size_of(cipher_name)), BUFFER_SIZE(buf_size_mult * BLOCK_SIZE), mode_name(cipher_mode_name), cipher(get_block_cipher(cipher_name)), buffer(BUFFER_SIZE) { reset_key(key); state.set(iv, iv.length()); position = 0; }/************************************************** Return the name of this type **************************************************/std::string BlockCipherMode::name() const { return mode_name + "(" + cipher->name() + ")"; }/************************************************** Set the IV **************************************************/void BlockCipherMode::reset_iv(const BlockCipherModeIV& new_iv) { if(!valid_iv_length(new_iv.length())) throw Invalid_IV_Length(name(), new_iv.length()); state.set(new_iv, new_iv.length()); buffer.clear(); position = 0; }/************************************************** Default IV size check **************************************************/bool BlockCipherMode::valid_iv_length(u32bit iv_size) const { if(iv_size == BLOCK_SIZE) return true; return false; }/************************************************** Set the Key **************************************************/void BlockCipherMode::reset_key(const SymmetricKey& key) { cipher->set_key(key); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -