⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x919_mac.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/************************************************** ANSI X9.19 MAC Source File                     ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/x919_mac.h>#include <botan/lookup.h>namespace Botan {/************************************************** Update a ANSI X9.19 MAC Computation            **************************************************/void ANSI_X919_MAC::add_data(const byte input[], u32bit length)   {   u32bit xored = std::min(8 - position, length);   xor_buf(state + position, input, xored);   position += xored;   if(position < 8) return;   e->encrypt(state);   input += xored;   length -= xored;   while(length >= 8)      {      xor_buf(state, input, 8);      e->encrypt(state);      input += 8;      length -= 8;      }   xor_buf(state, input, length);   position = length;   }/************************************************** Finalize a ANSI X9.19 MAC Computation          **************************************************/void ANSI_X919_MAC::final_result(byte mac[])   {   if(position)      e->encrypt(state);   d->decrypt(state, mac);   e->encrypt(mac);   state.clear();   position = 0;   }/************************************************** ANSI X9.19 MAC Key Schedule                    **************************************************/void ANSI_X919_MAC::key(const byte key[], u32bit length)   {   e->set_key(key, 8);   if(length == 8) d->set_key(key, 8);   else            d->set_key(key + 8, 8);   }/************************************************** Clear memory of sensitive data                 **************************************************/void ANSI_X919_MAC::clear() throw()   {   e->clear();   d->clear();   state.clear();   position = 0;   }/************************************************** ANSI X9.19 MAC Constructor                     **************************************************/ANSI_X919_MAC::ANSI_X919_MAC() : MessageAuthenticationCode(8, 8, 16, 8)   {   e = get_block_cipher("DES");   d = get_block_cipher("DES");   position = 0;   }/************************************************** ANSI X9.19 MAC Destructor                      **************************************************/ANSI_X919_MAC::~ANSI_X919_MAC()   {   delete e;   delete d;   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -