<commit_before>/*************************************************
* CBC-MAC Source File                            *
* (C) 1999-2007 The Botan Project                *
*************************************************/

#include <botan/cbc_mac.h>
#include <botan/lookup.h>
#include <botan/bit_ops.h>
#include <algorithm>

namespace Botan {

/*************************************************
* Update an CBC-MAC Calculation                  *
*************************************************/
void CBC_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 an CBC-MAC Calculation                *
*************************************************/
void CBC_MAC::final_result(byte mac[])
   {
   if(position)
      e->encrypt(state);

   copy_mem(mac, state.begin(), state.size());
   state.clear();
   position = 0;
   }

/*************************************************
* CBC-MAC Key Schedule                           *
*************************************************/
void CBC_MAC::key(const byte key[], u32bit length)
   {
   e->set_key(key, length);
   }<commit_msg>Use the OUTPUT_LENGTH constant instead of assuming the block size of the cipher is 64 bits.<commit_after>/*************************************************
* CBC-MAC Source File                            *
* (C) 1999-2007 The Botan Project                *
*************************************************/

#include <botan/cbc_mac.h>
#include <botan/lookup.h>
#include <botan/bit_ops.h>
#include <algorithm>

namespace Botan {

/*************************************************
* Update an CBC-MAC Calculation                  *
*************************************************/
void CBC_MAC::add_data(const byte input[], u32bit length)
   {
   u32bit xored = std::min(OUTPUT_LENGTH - position, length);
   xor_buf(state + position, input, xored);
   position += xored;

   if(position < OUTPUT_LENGTH)
      return;

   e->encrypt(state);
   input += xored;
   length -= xored;
   while(length >= OUTPUT_LENGTH)
      {
      xor_buf(state, input, OUTPUT_LENGTH);
      e->encrypt(state);
      input += OUTPUT_LENGTH;
      length -= OUTPUT_LENGTH;
      }

   xor_buf(state, input, length);
   position = length;
   }

/*************************************************
* Finalize an CBC-MAC Calculation                *
*************************************************/
void CBC_MAC::final_result(byte mac[])
   {
   if(position)
      e->encrypt(state);

   copy_mem(mac, state.begin(), state.size());
   state.clear();
   position = 0;
   }

/*************************************************
* CBC-MAC Key Schedule                           *
*************************************************/
void CBC_MAC::key(const byte key[], u32bit length)
   {
   e->set_key(key, length);
   }
{'fraction_non_alphanumeric': 0.34415584415584416, 'fraction_numerical': 0.011750154607297465, 'mean_word_length': 3.2509855453350855, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3987195', 'n_tokens_mistral': 948, 'n_tokens_neox': 866, 'n_words': 193}