Macros | Functions | Variables
sha256.c File Reference
#include <openssl/sha.h>
#include <string.h>
#include <openssl/mem.h>
#include "../../internal.h"
#include "../digest/md32_common.h"
#include "internal.h"
Include dependency graph for sha256.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Ch(x, y, z)   (((x) & (y)) ^ ((~(x)) & (z)))
 
#define Maj(x, y, z)   (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
 
#define ROUND_00_15(i, a, b, c, d, e, f, g, h)
 
#define ROUND_16_63(i, a, b, c, d, e, f, g, h, X)
 
#define Sigma0(x)
 
#define sigma0(x)   (CRYPTO_rotr_u32((x), 7) ^ CRYPTO_rotr_u32((x), 18) ^ ((x) >> 3))
 
#define Sigma1(x)
 
#define sigma1(x)   (CRYPTO_rotr_u32((x), 17) ^ CRYPTO_rotr_u32((x), 19) ^ ((x) >> 10))
 

Functions

uint8_tSHA224 (const uint8_t *data, size_t len, uint8_t out[SHA224_DIGEST_LENGTH])
 
int SHA224_Final (uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx)
 
int SHA224_Init (SHA256_CTX *sha)
 
int SHA224_Update (SHA256_CTX *ctx, const void *data, size_t len)
 
uint8_tSHA256 (const uint8_t *data, size_t len, uint8_t out[SHA256_DIGEST_LENGTH])
 
static void sha256_block_data_order (uint32_t *state, const uint8_t *in, size_t num)
 
int SHA256_Final (uint8_t out[SHA256_DIGEST_LENGTH], SHA256_CTX *c)
 
static int sha256_final_impl (uint8_t *out, SHA256_CTX *c)
 
int SHA256_Init (SHA256_CTX *sha)
 
void SHA256_Transform (SHA256_CTX *c, const uint8_t data[SHA256_CBLOCK])
 
void SHA256_TransformBlocks (uint32_t state[8], const uint8_t *data, size_t num_blocks)
 
int SHA256_Update (SHA256_CTX *c, const void *data, size_t len)
 

Variables

static const uint32_t K256 [64]
 

Macro Definition Documentation

◆ Ch

#define Ch (   x,
  y,
  z 
)    (((x) & (y)) ^ ((~(x)) & (z)))

Definition at line 199 of file sha256.c.

◆ Maj

#define Maj (   x,
  y,
  z 
)    (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))

Definition at line 200 of file sha256.c.

◆ ROUND_00_15

#define ROUND_00_15 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
do { \
T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i]; \
h = Sigma0(a) + Maj(a, b, c); \
d += T1; \
h += T1; \
} while (0)

Definition at line 202 of file sha256.c.

◆ ROUND_16_63

#define ROUND_16_63 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  X 
)
Value:
do { \
s0 = X[(i + 1) & 0x0f]; \
s0 = sigma0(s0); \
s1 = X[(i + 14) & 0x0f]; \
s1 = sigma1(s1); \
T1 = X[(i) & 0x0f] += s0 + s1 + X[(i + 9) & 0x0f]; \
ROUND_00_15(i, a, b, c, d, e, f, g, h); \
} while (0)

Definition at line 210 of file sha256.c.

◆ Sigma0

#define Sigma0 (   x)
Value:
(CRYPTO_rotr_u32((x), 2) ^ CRYPTO_rotr_u32((x), 13) ^ \
CRYPTO_rotr_u32((x), 22))

Definition at line 188 of file sha256.c.

◆ sigma0

#define sigma0 (   x)    (CRYPTO_rotr_u32((x), 7) ^ CRYPTO_rotr_u32((x), 18) ^ ((x) >> 3))

Definition at line 194 of file sha256.c.

◆ Sigma1

#define Sigma1 (   x)
Value:
(CRYPTO_rotr_u32((x), 6) ^ CRYPTO_rotr_u32((x), 11) ^ \
CRYPTO_rotr_u32((x), 25))

Definition at line 191 of file sha256.c.

◆ sigma1

#define sigma1 (   x)    (CRYPTO_rotr_u32((x), 17) ^ CRYPTO_rotr_u32((x), 19) ^ ((x) >> 10))

Definition at line 196 of file sha256.c.

Function Documentation

◆ SHA224()

uint8_t* SHA224 ( const uint8_t data,
size_t  len,
uint8_t  out[SHA224_DIGEST_LENGTH] 
)

Definition at line 96 of file sha256.c.

◆ SHA224_Final()

int SHA224_Final ( uint8_t  out[SHA224_DIGEST_LENGTH],
SHA256_CTX ctx 
)

Definition at line 164 of file sha256.c.

◆ SHA224_Init()

int SHA224_Init ( SHA256_CTX sha)

Definition at line 68 of file sha256.c.

◆ SHA224_Update()

int SHA224_Update ( SHA256_CTX ctx,
const void *  data,
size_t  len 
)

Definition at line 131 of file sha256.c.

◆ SHA256()

uint8_t* SHA256 ( const uint8_t data,
size_t  len,
uint8_t  out[SHA256_DIGEST_LENGTH] 
)

Definition at line 106 of file sha256.c.

◆ sha256_block_data_order()

static void sha256_block_data_order ( uint32_t state,
const uint8_t in,
size_t  num 
)
static

Definition at line 220 of file sha256.c.

◆ SHA256_Final()

int SHA256_Final ( uint8_t  out[SHA256_DIGEST_LENGTH],
SHA256_CTX c 
)

Definition at line 156 of file sha256.c.

◆ sha256_final_impl()

static int sha256_final_impl ( uint8_t out,
SHA256_CTX c 
)
static

Definition at line 135 of file sha256.c.

◆ SHA256_Init()

int SHA256_Init ( SHA256_CTX sha)

Definition at line 82 of file sha256.c.

◆ SHA256_Transform()

void SHA256_Transform ( SHA256_CTX c,
const uint8_t  data[SHA256_CBLOCK] 
)

Definition at line 121 of file sha256.c.

◆ SHA256_TransformBlocks()

void SHA256_TransformBlocks ( uint32_t  state[8],
const uint8_t data,
size_t  num_blocks 
)

Definition at line 309 of file sha256.c.

◆ SHA256_Update()

int SHA256_Update ( SHA256_CTX c,
const void *  data,
size_t  len 
)

Definition at line 125 of file sha256.c.

Variable Documentation

◆ K256

const uint32_t K256[64]
static
Initial value:
= {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL}

Definition at line 172 of file sha256.c.

CRYPTO_rotr_u32
static uint32_t CRYPTO_rotr_u32(uint32_t value, int shift)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:907
sigma0
#define sigma0(x)
Definition: sha256.c:194
X
#define X(c)
sigma1
#define sigma1(x)
Definition: sha256.c:196
K256
static const uint32_t K256[64]
Definition: sha256.c:172
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
re2::T1
@ T1
Definition: bloaty/third_party/re2/util/rune.cc:31
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
Sigma0
#define Sigma0(x)
Definition: sha256.c:188
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
g
struct @717 g
d
static const fe d
Definition: curve25519_tables.h:19
Maj
#define Maj(x, y, z)
Definition: sha256.c:200
Sigma1
#define Sigma1(x)
Definition: sha256.c:191
Ch
#define Ch(x, y, z)
Definition: sha256.c:199
absl::str_format_internal::LengthMod::h
@ h
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:31