<commit_before>/*
* SHA-{224,256}
* (C) 1999-2008 <NAME>
*     2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/

#include <botan/sha2_32.h>
#include <botan/loadstor.h>
#include <botan/rotate.h>

namespace Botan {

namespace {

/*
* SHA-256 Rho Function
*/
inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
   {
   return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
           rotate_right(X, rot3));
   }

/*
* SHA-256 Sigma Function
*/
inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
   {
   return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
   }

/*
* SHA-256 F1 Function
*/
inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
               u32bit E, u32bit F, u32bit G, u32bit& H,
               u32bit msg, u32bit magic)
   {
   magic += rho(E, 6, 11, 25) + ((E & F) ^ (~E & G)) + msg;
   D += magic + H;
   H += magic + rho(A, 2, 13, 22) + ((A & B) ^ (A & C) ^ (B & C));
   }

}

/*
* SHA-256 Compression Function
*/
void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
   {
   u32bit A = digest[0], B = digest[1], C = digest[2],
          D = digest[3], E = digest[4], F = digest[5],
          G = digest[6], H = digest[7];

   for(u32bit i = 0; i != blocks; ++i)
      {
      for(u32bit j = 0; j != 16; ++j)
         W[j] = load_be<u32bit>(input, j);
      input += HASH_BLOCK_SIZE;

      for(u32bit j = 16; j != 64; ++j)
         W[j] = sigma(W[j- 2], 17, 19, 10) + W[j- 7] +
            sigma(W[j-15],  7, 18,  3) + W[j-16];

      F1(A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98);
      F1(H, A, B, C, D, E, F, G, W[ 1], 0x71374491);
      F1(G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF);
      F1(F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5);
      F1(E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B);
      F1(D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1);
      F1(C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4);
      F1(B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5);
      F1(A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98);
      F1(H, A, B, C, D, E, F, G, W[ 9], 0x12835B01);
      F1(G, H, A, B, C, D, E, F, W[10], 0x243185BE);
      F1(F, G, H, A, B, C, D, E, W[11], 0x550C7DC3);
      F1(E, F, G, H, A, B, C, D, W[12], 0x72BE5D74);
      F1(D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE);
      F1(C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7);
      F1(B, C, D, E, F, G, H, A, W[15], 0xC19BF174);
      F1(A, B, C, D, E, F, G, H, W[16], 0xE49B69C1);
      F1(H, A, B, C, D, E, F, G, W[17], 0xEFBE4786);
      F1(G, H, A, B, C, D, E, F, W[18], 0x0FC19DC6);
      F1(F, G, H, A, B, C, D, E, W[19], 0x240CA1CC);
      F1(E, F, G, H, A, B, C, D, W[20], 0x2DE92C6F);
      F1(D, E, F, G, H, A, B, C, W[21], 0x4A7484AA);
      F1(C, D, E, F, G, H, A, B, W[22], 0x5CB0A9DC);
      F1(B, C, D, E, F, G, H, A, W[23], 0x76F988DA);
      F1(A, B, C, D, E, F, G, H, W[24], 0x983E5152);
      F1(H, A, B, C, D, E, F, G, W[25], 0xA831C66D);
      F1(G, H, A, B, C, D, E, F, W[26], 0xB00327C8);
      F1(F, G, H, A, B, C, D, E, W[27], 0xBF597FC7);
      F1(E, F, G, H, A, B, C, D, W[28], 0xC6E00BF3);
      F1(D, E, F, G, H, A, B, C, W[29], 0xD5A79147);<commit_msg>Indent fix<commit_after>/*
* SHA-{224,256}
* (C) 1999-2008 <NAME>
*     2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/

#include <botan/sha2_32.h>
#include <botan/loadstor.h>
#include <botan/rotate.h>

namespace Botan {

namespace {

/*
* SHA-256 Rho Function
*/
inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
   {
   return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
           rotate_right(X, rot3));
   }

/*
* SHA-256 Sigma Function
*/
inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
   {
   return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
   }

/*
* SHA-256 F1 Function
*/
inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
               u32bit E, u32bit F, u32bit G, u32bit& H,
               u32bit msg, u32bit magic)
   {
   magic += rho(E, 6, 11, 25) + ((E & F) ^ (~E & G)) + msg;
   D += magic + H;
   H += magic + rho(A, 2, 13, 22) + ((A & B) ^ (A & C) ^ (B & C));
   }

}

/*
* SHA-256 Compression Function
*/
void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
   {
   u32bit A = digest[0], B = digest[1], C = digest[2],
          D = digest[3], E = digest[4], F = digest[5],
          G = digest[6], H = digest[7];

   for(u32bit i = 0; i != blocks; ++i)
      {
      for(u32bit j = 0; j != 16; ++j)
         W[j] = load_be<u32bit>(input, j);
      input += HASH_BLOCK_SIZE;

      for(u32bit j = 16; j != 64; ++j)
         W[j] = sigma(W[j- 2], 17, 19, 10) + W[j- 7] +
                sigma(W[j-15],  7, 18,  3) + W[j-16];

      F1(A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98);
      F1(H, A, B, C, D, E, F, G, W[ 1], 0x71374491);
      F1(G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF);
      F1(F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5);
      F1(E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B);
      F1(D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1);
      F1(C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4);
      F1(B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5);
      F1(A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98);
      F1(H, A, B, C, D, E, F, G, W[ 9], 0x12835B01);
      F1(G, H, A, B, C, D, E, F, W[10], 0x243185BE);
      F1(F, G, H, A, B, C, D, E, W[11], 0x550C7DC3);
      F1(E, F, G, H, A, B, C, D, W[12], 0x72BE5D74);
      F1(D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE);
      F1(C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7);
      F1(B, C, D, E, F, G, H, A, W[15], 0xC19BF174);
      F1(A, B, C, D, E, F, G, H, W[16], 0xE49B69C1);
      F1(H, A, B, C, D, E, F, G, W[17], 0xEFBE4786);
      F1(G, H, A, B, C, D, E, F, W[18], 0x0FC19DC6);
      F1(F, G, H, A, B, C, D, E, W[19], 0x240CA1CC);
      F1(E, F, G, H, A, B, C, D, W[20], 0x2DE92C6F);
      F1(D, E, F, G, H, A, B, C, W[21], 0x4A7484AA);
      F1(C, D, E, F, G, H, A, B, W[22], 0x5CB0A9DC);
      F1(B, C, D, E, F, G, H, A, W[23], 0x76F988DA);
      F1(A, B, C, D, E, F, G, H, W[24], 0x983E5152);
      F1(H, A, B, C, D, E, F, G, W[25], 0xA831C66D);
      F1(G, H, A, B, C, D, E, F, W[26], 0xB00327C8);
      F1(F, G, H, A, B, C, D, E, W[27], 0xBF597FC7);
      F1(E, F, G, H, A, B, C, D, W[28], 0xC6E00BF3);
      F1(D, E, F, G, H, A, B, C, W[29], 0xD5A79147);
{'fraction_non_alphanumeric': 0.2210943695479778, 'fraction_numerical': 0.12720063441712925, 'mean_word_length': 2.357827476038339, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '7525904', 'n_tokens_mistral': 3722, 'n_tokens_neox': 3280, 'n_words': 974}