BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sha512.c File Reference
#include "polarssl/sha512.h"

Go to the source code of this file.

Macros

#define POLARSSL_SHA512_C
 
#define polarssl_printf   printf
 
#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 sha512_init (sha512_context *ctx)
 Initialize SHA-512 context. More...
 
void sha512_free (sha512_context *ctx)
 Clear SHA-512 context. More...
 
void sha512_starts (sha512_context *ctx, int is384)
 SHA-512 context setup. More...
 
void sha512_process (sha512_context *ctx, const unsigned char data[128])
 
void sha512_update (sha512_context *ctx, const unsigned char *input, size_t ilen)
 SHA-512 process buffer. More...
 
void sha512_finish (sha512_context *ctx, unsigned char output[64])
 SHA-512 final digest. More...
 
void sha512 (const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
 Output = SHA-512( input buffer ) More...
 

Macro Definition Documentation

#define F0 (   x,
  y,
 
)    ((x & y) | (z & (x | y)))
#define F1 (   x,
  y,
 
)    (z ^ (x & (y ^ z)))
#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] ); \
}

Definition at line 51 of file sha512.c.

#define P (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  x,
 
)
Value:
{ \
temp1 = h + S3(e) + F1(e,f,g) + K + x; \
temp2 = S2(a) + F0(a,b,c); \
d += temp1; h = temp1 + temp2; \
}
#define S2(x)
#define S3(x)
#define F1(x, y, z)
#define F0(x, y, z)
#define polarssl_printf   printf

Definition at line 38 of file sha512.c.

#define POLARSSL_SHA512_C

Definition at line 28 of file sha512.c.

#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) ); \
}

Definition at line 65 of file sha512.c.

#define ROTR (   x,
 
)    (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 SHR (   x,
 
)    (x >> n)

Function Documentation

void 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

Definition at line 336 of file sha512.c.

void sha512_finish ( sha512_context ctx,
unsigned char  output[64] 
)

SHA-512 final digest.

Parameters
ctxSHA-512 context
outputSHA-384/512 checksum result

Definition at line 298 of file sha512.c.

void sha512_free ( sha512_context ctx)

Clear SHA-512 context.

Parameters
ctxSHA-512 context to be cleared

Definition at line 130 of file sha512.c.

void sha512_init ( sha512_context ctx)

Initialize SHA-512 context.

Parameters
ctxSHA-512 context to be initialized

Definition at line 125 of file sha512.c.

void sha512_process ( sha512_context ctx,
const unsigned char  data[128] 
)

Definition at line 174 of file sha512.c.

void sha512_starts ( sha512_context ctx,
int  is384 
)

SHA-512 context setup.

Parameters
ctxcontext to be initialized
is3840 = use SHA512, 1 = use SHA384

Definition at line 141 of file sha512.c.

void sha512_update ( 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

Definition at line 246 of file sha512.c.