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

Macros

#define UL64(x)   x##ULL
 
#define GET_UINT64_BE(n, b, i)
 
#define PUT_UINT64_BE(n, b, i)
 
#define SHR(x, n)   (x >> n)
 
#define ROTR(x, n)   (SHR(x,n) | (x << (64 - n)))
 
#define S0(x)   (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))
 
#define S1(x)   (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6))
 
#define S2(x)   (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))
 
#define S3(x)   (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))
 
#define F0(x, y, z)   ((x & y) | (z & (x | y)))
 
#define F1(x, y, z)   (z ^ (x & (y ^ z)))
 
#define P(a, b, c, d, e, f, g, h, x, K)
 

Functions

void mbedtls_sha512_init (mbedtls_sha512_context *ctx)
 Initialize SHA-512 context. More...
 
void mbedtls_sha512_free (mbedtls_sha512_context *ctx)
 Clear SHA-512 context. More...
 
void mbedtls_sha512_clone (mbedtls_sha512_context *dst, const mbedtls_sha512_context *src)
 Clone (the state of) a SHA-512 context. More...
 
void mbedtls_sha512_starts (mbedtls_sha512_context *ctx, int is384)
 SHA-512 context setup. More...
 
void mbedtls_sha512_process (mbedtls_sha512_context *ctx, const unsigned char data[128])
 
void mbedtls_sha512_update (mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
 SHA-512 process buffer. More...
 
void mbedtls_sha512_finish (mbedtls_sha512_context *ctx, unsigned char output[64])
 SHA-512 final digest. More...
 
void mbedtls_sha512 (const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
 Output = SHA-512( input buffer ) More...
 
int mbedtls_sha512_self_test (int verbose)
 Checkup routine. More...
 

Variables

static const uint64_t K [80]
 
static const unsigned char sha512_padding [128]
 
static const unsigned char sha512_test_buf [3][113]
 
static const int sha512_test_buflen [3]
 
static const unsigned char sha512_test_sum [6][64]
 

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_UINT64_BE

#define GET_UINT64_BE (   n,
  b,
 
)
Value:
{ \
(n) = ( (uint64_t) (b)[(i) ] << 56 ) \
| ( (uint64_t) (b)[(i) + 1] << 48 ) \
| ( (uint64_t) (b)[(i) + 2] << 40 ) \
| ( (uint64_t) (b)[(i) + 3] << 32 ) \
| ( (uint64_t) (b)[(i) + 4] << 24 ) \
| ( (uint64_t) (b)[(i) + 5] << 16 ) \
| ( (uint64_t) (b)[(i) + 6] << 8 ) \
| ( (uint64_t) (b)[(i) + 7] ); \
}
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
unsigned __int64 uint64_t
Definition: stdint.h:136
GLdouble n
Definition: glext.h:8396

◆ 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; \
}
#define F0(x, y, z)
static const uint64_t K[80]
Definition: sha512.c:152
#define F1(x, y, z)
GLfloat f
Definition: glext.h:8207
#define S3(x)
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
GLboolean GLboolean g
Definition: glext.h:6844
#define S2(x)
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:8390
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844

◆ PUT_UINT64_BE

#define PUT_UINT64_BE (   n,
  b,
 
)
Value:
{ \
(b)[(i) ] = (unsigned char) ( (n) >> 56 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \
(b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \
(b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \
(b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 7] = (unsigned char) ( (n) ); \
}
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLdouble n
Definition: glext.h:8396

◆ ROTR

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

◆ S0

#define S0 (   x)    (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))

◆ S1

#define S1 (   x)    (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6))

◆ S2

#define S2 (   x)    (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))

◆ S3

#define S3 (   x)    (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))

◆ SHR

#define SHR (   x,
  n 
)    (x >> n)

◆ UL64

#define UL64 (   x)    x##ULL

Function Documentation

◆ mbedtls_sha512()

void mbedtls_sha512 ( const unsigned char *  input,
size_t  ilen,
unsigned char  output[64],
int  is384 
)

Output = SHA-512( input buffer )

Parameters
inputbuffer holding the data
ilenlength of the input data
outputSHA-384/512 checksum result
is3840 = use SHA512, 1 = use SHA384
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha512_clone()

void mbedtls_sha512_clone ( mbedtls_sha512_context dst,
const mbedtls_sha512_context src 
)

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

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

◆ mbedtls_sha512_finish()

void mbedtls_sha512_finish ( mbedtls_sha512_context ctx,
unsigned char  output[64] 
)

SHA-512 final digest.

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

◆ mbedtls_sha512_free()

void mbedtls_sha512_free ( mbedtls_sha512_context ctx)

Clear SHA-512 context.

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

◆ mbedtls_sha512_init()

void mbedtls_sha512_init ( mbedtls_sha512_context ctx)

Initialize SHA-512 context.

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

◆ mbedtls_sha512_process()

void mbedtls_sha512_process ( mbedtls_sha512_context ctx,
const unsigned char  data[128] 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_sha512_self_test()

int mbedtls_sha512_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_sha512_starts()

void mbedtls_sha512_starts ( mbedtls_sha512_context ctx,
int  is384 
)

SHA-512 context setup.

Parameters
ctxcontext to be initialized
is3840 = use SHA512, 1 = use SHA384
Here is the caller graph for this function:

◆ mbedtls_sha512_update()

void mbedtls_sha512_update ( mbedtls_sha512_context ctx,
const unsigned char *  input,
size_t  ilen 
)

SHA-512 process buffer.

Parameters
ctxSHA-512 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

◆ K

const uint64_t K[80]
static

◆ sha512_padding

const unsigned char sha512_padding[128]
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,
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, 0
}

◆ sha512_test_buf

const unsigned char sha512_test_buf[3][113]
static
Initial value:
=
{
{ "abc" },
{ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" },
{ "" }
}

◆ sha512_test_buflen

const int sha512_test_buflen[3]
static
Initial value:
=
{
3, 112, 1000
}

◆ sha512_test_sum

const unsigned char sha512_test_sum[6][64]
static