modebase.cpp

来自「含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种Chec」· C++ 代码 · 共 69 行

CPP
69
字号
/************************************************** 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 + =
减小字号Ctrl + -
显示快捷键?