NCBI C++ ToolKit
Macros | Functions | Variables
sha256.c File Reference
#include "common.h"
#include "mbedtls/sha256.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"
#include <string.h>
#include "mbedtls/platform.h"
+ Include dependency graph for sha256.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define SHA256_VALIDATE_RET(cond)    MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA)
 
#define SHA256_VALIDATE(cond)   MBEDTLS_INTERNAL_VALIDATE(cond)
 
#define SHR(x, n)   (((x) & 0xFFFFFFFF) >> (n))
 
#define ROTR(x, n)   (SHR(x, n) | ((x) << (32 - (n))))
 
#define S0(x)   (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
 
#define S1(x)   (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
 
#define S2(x)   (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
 
#define S3(x)   (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
 
#define F0(x, y, z)   (((x) & (y)) | ((z) & ((x) | (y))))
 
#define F1(x, y, z)   ((z) ^ ((x) & ((y) ^ (z))))
 
#define R(t)
 
#define P(a, b, c, d, e, f, g, h, x, K)
 

Functions

void mbedtls_sha256_init_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx)
 
void mbedtls_sha256_free_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx)
 
void mbedtls_sha256_clone_ncbicxx_2_28_3 (mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
 
int mbedtls_sha256_starts_ret_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, int is224)
 
void mbedtls_sha256_starts_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, int is224)
 
int mbedtls_internal_sha256_process_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, const unsigned char data[64])
 
void mbedtls_sha256_process_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, const unsigned char data[64])
 
int mbedtls_sha256_update_ret_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
 
void mbedtls_sha256_update_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
 
int mbedtls_sha256_finish_ret_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, unsigned char output[32])
 
void mbedtls_sha256_finish_ncbicxx_2_28_3 (mbedtls_sha256_context *ctx, unsigned char output[32])
 
int mbedtls_sha256_ret_ncbicxx_2_28_3 (const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
 
void mbedtls_sha256_ncbicxx_2_28_3 (const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
 

Variables

static const uint32_t K []
 

Macro Definition Documentation

◆ F0

#define F0 (   x,
  y,
 
)    (((x) & (y)) | ((z) & ((x) | (y))))

Definition at line 144 of file sha256.c.

◆ F1

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

Definition at line 145 of file sha256.c.

◆ P

#define P (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  x,
  K 
)
Value:
do \
{ \
local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x); \
local.temp2 = S2(a) + F0((a), (b), (c)); \
(d) += local.temp1; (h) = local.temp1 + local.temp2; \
} while (0)
unsigned int a
Definition: ncbi_localip.c:102
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define F1(x, y, z)
Definition: sha256.c:145
#define S2(x)
Definition: sha256.c:141
#define F0(x, y, z)
Definition: sha256.c:144
static const uint32_t K[]
Definition: sha256.c:115
#define S3(x)
Definition: sha256.c:142
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
Definition: thrddgri.c:44
#define local
Definition: zutil.h:33

Definition at line 153 of file sha256.c.

◆ R

#define R (   t)
Value:
( \
local.W[t] = S1(local.W[(t) - 2]) + local.W[(t) - 7] + \
S0(local.W[(t) - 15]) + local.W[(t) - 16] \
)
EIPRangeType t
Definition: ncbi_localip.c:101
#define S0(x)
Definition: sha256.c:138
#define S1(x)
Definition: sha256.c:139

Definition at line 147 of file sha256.c.

◆ ROTR

#define ROTR (   x,
  n 
)    (SHR(x, n) | ((x) << (32 - (n))))

Definition at line 136 of file sha256.c.

◆ S0

#define S0 (   x)    (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))

Definition at line 138 of file sha256.c.

◆ S1

#define S1 (   x)    (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))

Definition at line 139 of file sha256.c.

◆ S2

#define S2 (   x)    (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))

Definition at line 141 of file sha256.c.

◆ S3

#define S3 (   x)    (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))

Definition at line 142 of file sha256.c.

◆ SHA256_VALIDATE

#define SHA256_VALIDATE (   cond)    MBEDTLS_INTERNAL_VALIDATE(cond)

Definition at line 39 of file sha256.c.

◆ SHA256_VALIDATE_RET

#define SHA256_VALIDATE_RET (   cond)     MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA)

Definition at line 37 of file sha256.c.

◆ SHR

#define SHR (   x,
  n 
)    (((x) & 0xFFFFFFFF) >> (n))

Definition at line 135 of file sha256.c.

Function Documentation

◆ mbedtls_internal_sha256_process_ncbicxx_2_28_3()

int mbedtls_internal_sha256_process_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
const unsigned char  data[64] 
)

Definition at line 161 of file sha256.c.

References A, ctx, i, K, local, MBEDTLS_GET_UINT32_BE, mbedtls_platform_zeroize(), NULL, P, R, SHA256_VALIDATE_RET, and W.

◆ mbedtls_sha256_clone_ncbicxx_2_28_3()

void mbedtls_sha256_clone_ncbicxx_2_28_3 ( mbedtls_sha256_context dst,
const mbedtls_sha256_context src 
)

Definition at line 59 of file sha256.c.

References NULL, and SHA256_VALIDATE.

◆ mbedtls_sha256_finish_ncbicxx_2_28_3()

void mbedtls_sha256_finish_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
unsigned char  output[32] 
)

Definition at line 390 of file sha256.c.

References ctx, mbedtls_sha256_finish_ret(), and output.

◆ mbedtls_sha256_finish_ret_ncbicxx_2_28_3()

int mbedtls_sha256_finish_ret_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
unsigned char  output[32] 
)

◆ mbedtls_sha256_free_ncbicxx_2_28_3()

void mbedtls_sha256_free_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx)

Definition at line 50 of file sha256.c.

References ctx, mbedtls_platform_zeroize(), and NULL.

◆ mbedtls_sha256_init_ncbicxx_2_28_3()

void mbedtls_sha256_init_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx)

Definition at line 43 of file sha256.c.

References ctx, NULL, and SHA256_VALIDATE.

◆ mbedtls_sha256_ncbicxx_2_28_3()

void mbedtls_sha256_ncbicxx_2_28_3 ( const unsigned char *  input,
size_t  ilen,
unsigned char  output[32],
int  is224 
)

Definition at line 435 of file sha256.c.

References input(), mbedtls_sha256_ret(), and output.

◆ mbedtls_sha256_process_ncbicxx_2_28_3()

void mbedtls_sha256_process_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
const unsigned char  data[64] 
)

Definition at line 250 of file sha256.c.

References ctx, and mbedtls_internal_sha256_process().

◆ mbedtls_sha256_ret_ncbicxx_2_28_3()

int mbedtls_sha256_ret_ncbicxx_2_28_3 ( const unsigned char *  input,
size_t  ilen,
unsigned char  output[32],
int  is224 
)

◆ mbedtls_sha256_starts_ncbicxx_2_28_3()

void mbedtls_sha256_starts_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
int  is224 
)

Definition at line 107 of file sha256.c.

References ctx, and mbedtls_sha256_starts_ret().

◆ mbedtls_sha256_starts_ret_ncbicxx_2_28_3()

int mbedtls_sha256_starts_ret_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
int  is224 
)

Definition at line 71 of file sha256.c.

References ctx, NULL, and SHA256_VALIDATE_RET.

◆ mbedtls_sha256_update_ncbicxx_2_28_3()

void mbedtls_sha256_update_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
const unsigned char *  input,
size_t  ilen 
)

Definition at line 315 of file sha256.c.

References ctx, input(), and mbedtls_sha256_update_ret().

◆ mbedtls_sha256_update_ret_ncbicxx_2_28_3()

int mbedtls_sha256_update_ret_ncbicxx_2_28_3 ( mbedtls_sha256_context ctx,
const unsigned char *  input,
size_t  ilen 
)

Variable Documentation

◆ K

const uint32_t K[]
static
Initial value:
=
{
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
}

Definition at line 115 of file sha256.c.

Referenced by mbedtls_internal_sha256_process_ncbicxx_2_28_3().

Modified on Thu Feb 22 17:05:44 2024 by modify_doxy.py rev. 669887