RetroArch
Macros | Functions | Variables
sha256.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/sha256.h"
#include <string.h>
#include "mbedtls/platform.h"
#include "arc4_alt.h"
Include dependency graph for sha256.c:

Macros

#define GET_UINT32_BE(n, b, i)
 
#define PUT_UINT32_BE(n, b, i)
 
#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 (mbedtls_sha256_context *ctx)
 Initialize SHA-256 context. More...
 
void mbedtls_sha256_free (mbedtls_sha256_context *ctx)
 Clear SHA-256 context. More...
 
void mbedtls_sha256_clone (mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
 Clone (the state of) a SHA-256 context. More...
 
void mbedtls_sha256_starts (mbedtls_sha256_context *ctx, int is224)
 SHA-256 context setup. More...
 
void mbedtls_sha256_process (mbedtls_sha256_context *ctx, const unsigned char data[64])
 
void mbedtls_sha256_update (mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
 SHA-256 process buffer. More...
 
void mbedtls_sha256_finish (mbedtls_sha256_context *ctx, unsigned char output[32])
 SHA-256 final digest. More...
 
void mbedtls_sha256 (const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
 Output = SHA-256( input buffer ) More...
 
int mbedtls_sha256_self_test (int verbose)
 Checkup routine. More...
 

Variables

static const uint32_t SHA256_K []
 
static const unsigned char sha256_padding [64]
 
static const unsigned char sha256_test_buf [3][57]
 
static const int sha256_test_buflen [3]
 
static const unsigned char sha256_test_sum [6][32]
 

Macro Definition Documentation

◆ F0

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

◆ F1

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

◆ GET_UINT32_BE

#define GET_UINT32_BE (   n,
  b,
 
)
Value:
do { \
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
| ( (uint32_t) (b)[(i) + 3] ); \
} while( 0 )
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLdouble n
Definition: glext.h:8396
unsigned int uint32_t
Definition: stdint.h:126

◆ P

#define P (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  x,
  K 
)
Value:
{ \
temp1 = h + S3(e) + F1(e,f,g) + K + x; \
temp2 = S2(a) + F0(a,b,c); \
d += temp1; h = temp1 + temp2; \
}
GLfloat f
Definition: glext.h:8207
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
#define S2(x)
Definition: sha256.c:162
#define F1(x, y, z)
Definition: sha256.c:168
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
#define F0(x, y, z)
Definition: sha256.c:166
#define S3(x)
Definition: sha256.c:164
GLboolean GLboolean g
Definition: glext.h:6844
Definition: netplay_private.h:956
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:8390
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844

◆ PUT_UINT32_BE

#define PUT_UINT32_BE (   n,
  b,
 
)
Value:
do { \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 3] = (unsigned char) ( (n) ); \
} while( 0 )
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLdouble n
Definition: glext.h:8396

◆ R

#define R (   t)
Value:
( \
W[t] = S1(W[t - 2]) + W[t - 7] + \
S0(W[t - 15]) + W[t - 16] \
)
GLdouble GLdouble t
Definition: glext.h:6398
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld W[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub
Definition: pixman-arm-neon-asm.h:477
#define S1(x)
Definition: sha256.c:160

◆ ROTR

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

◆ S0

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

◆ S1

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

◆ S2

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

◆ S3

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

◆ SHR

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

Function Documentation

◆ mbedtls_sha256()

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

Output = SHA-256( input buffer )

Parameters
inputbuffer holding the data
ilenlength of the input data
outputSHA-224/256 checksum result
is2240 = use SHA256, 1 = use SHA224
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha256_clone()

void mbedtls_sha256_clone ( mbedtls_sha256_context dst,
const mbedtls_sha256_context src 
)

Clone (the state of) a SHA-256 context.

Parameters
dstThe destination context
srcThe context to be cloned
Here is the caller graph for this function:

◆ mbedtls_sha256_finish()

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

SHA-256 final digest.

Parameters
ctxSHA-256 context
outputSHA-224/256 checksum result
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha256_free()

void mbedtls_sha256_free ( mbedtls_sha256_context ctx)

Clear SHA-256 context.

Parameters
ctxSHA-256 context to be cleared
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha256_init()

void mbedtls_sha256_init ( mbedtls_sha256_context ctx)

Initialize SHA-256 context.

Parameters
ctxSHA-256 context to be initialized
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha256_process()

void mbedtls_sha256_process ( mbedtls_sha256_context ctx,
const unsigned char  data[64] 
)
Here is the caller graph for this function:

◆ mbedtls_sha256_self_test()

int mbedtls_sha256_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed
Here is the call graph for this function:

◆ mbedtls_sha256_starts()

void mbedtls_sha256_starts ( mbedtls_sha256_context ctx,
int  is224 
)

SHA-256 context setup.

Parameters
ctxcontext to be initialized
is2240 = use SHA256, 1 = use SHA224
Here is the caller graph for this function:

◆ mbedtls_sha256_update()

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

SHA-256 process buffer.

Parameters
ctxSHA-256 context
inputbuffer holding the data
ilenlength of the input data
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ SHA256_K

const uint32_t SHA256_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,
}

◆ sha256_padding

const unsigned char sha256_padding[64]
static
Initial value:
=
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

◆ sha256_test_buf

const unsigned char sha256_test_buf[3][57]
static
Initial value:
=
{
{ "abc" },
{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
{ "" }
}

◆ sha256_test_buflen

const int sha256_test_buflen[3]
static
Initial value:
=
{
3, 56, 1000
}

◆ sha256_test_sum

const unsigned char sha256_test_sum[6][32]
static
Initial value:
=
{
{ 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22,
0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3,
0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7,
0xE3, 0x6C, 0x9D, 0xA7 },
{ 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC,
0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50,
0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19,
0x52, 0x52, 0x25, 0x25 },
{ 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