Rizin
unix-like reverse engineering framework and cli tools
sha2.h File Reference
#include <rz_types.h>
#include <sys/types.h>

Go to the source code of this file.

Classes

struct  _SHA256_CTX
 
struct  _SHA512_CTX
 

Macros

#define SHA256_BLOCK_LENGTH   64
 
#define SHA256_DIGEST_LENGTH   32
 
#define SHA256_DIGEST_STRING_LENGTH   (SHA256_DIGEST_LENGTH * 2 + 1)
 
#define SHA384_BLOCK_LENGTH   128
 
#define SHA384_DIGEST_LENGTH   48
 
#define SHA384_DIGEST_STRING_LENGTH   (SHA384_DIGEST_LENGTH * 2 + 1)
 
#define SHA512_BLOCK_LENGTH   128
 
#define SHA512_DIGEST_LENGTH   64
 
#define SHA512_DIGEST_STRING_LENGTH   (SHA512_DIGEST_LENGTH * 2 + 1)
 
#define u_int8_t   unsigned char
 
#define u_int32_t   unsigned int
 
#define u_int64_t   unsigned long long
 
#define SHA256_BLOCK_LENGTH   64
 
#define SHA384_BLOCK_LENGTH   128
 
#define SHA512_BLOCK_LENGTH   128
 

Typedefs

typedef struct _SHA256_CTX RZ_SHA256_CTX
 
typedef struct _SHA512_CTX RZ_SHA512_CTX
 
typedef RZ_SHA512_CTX RZ_SHA384_CTX
 

Functions

void SHA256_Init (RZ_SHA256_CTX *)
 
void SHA256_Update (RZ_SHA256_CTX *, const u_int8_t *, size_t)
 
void SHA256_Final (u_int8_t *, RZ_SHA256_CTX *)
 
char * SHA256_End (RZ_SHA256_CTX *, char *)
 
char * SHA256_Data (const u_int8_t *, size_t, char[SHA256_DIGEST_STRING_LENGTH])
 
void SHA384_Init (RZ_SHA384_CTX *)
 
void SHA384_Update (RZ_SHA384_CTX *, const u_int8_t *, size_t)
 
void SHA384_Final (u_int8_t *, RZ_SHA384_CTX *)
 
char * SHA384_End (RZ_SHA384_CTX *, char *)
 
char * SHA384_Data (const u_int8_t *, size_t, char[SHA384_DIGEST_STRING_LENGTH])
 
void SHA512_Init (RZ_SHA512_CTX *)
 
void SHA512_Update (RZ_SHA512_CTX *, const u_int8_t *, size_t)
 
void SHA512_Final (u_int8_t *, RZ_SHA512_CTX *)
 
char * SHA512_End (RZ_SHA512_CTX *, char *)
 
char * SHA512_Data (const u_int8_t *, size_t, char[SHA512_DIGEST_STRING_LENGTH])
 

Macro Definition Documentation

◆ SHA256_BLOCK_LENGTH [1/2]

#define SHA256_BLOCK_LENGTH   64

Definition at line 96 of file sha2.h.

◆ SHA256_BLOCK_LENGTH [2/2]

#define SHA256_BLOCK_LENGTH   64

Definition at line 96 of file sha2.h.

◆ SHA256_DIGEST_LENGTH

#define SHA256_DIGEST_LENGTH   32

Definition at line 60 of file sha2.h.

◆ SHA256_DIGEST_STRING_LENGTH

#define SHA256_DIGEST_STRING_LENGTH   (SHA256_DIGEST_LENGTH * 2 + 1)

Definition at line 61 of file sha2.h.

◆ SHA384_BLOCK_LENGTH [1/2]

#define SHA384_BLOCK_LENGTH   128

Definition at line 103 of file sha2.h.

◆ SHA384_BLOCK_LENGTH [2/2]

#define SHA384_BLOCK_LENGTH   128

Definition at line 103 of file sha2.h.

◆ SHA384_DIGEST_LENGTH

#define SHA384_DIGEST_LENGTH   48

Definition at line 63 of file sha2.h.

◆ SHA384_DIGEST_STRING_LENGTH

#define SHA384_DIGEST_STRING_LENGTH   (SHA384_DIGEST_LENGTH * 2 + 1)

Definition at line 64 of file sha2.h.

◆ SHA512_BLOCK_LENGTH [1/2]

#define SHA512_BLOCK_LENGTH   128

Definition at line 104 of file sha2.h.

◆ SHA512_BLOCK_LENGTH [2/2]

#define SHA512_BLOCK_LENGTH   128

Definition at line 104 of file sha2.h.

◆ SHA512_DIGEST_LENGTH

#define SHA512_DIGEST_LENGTH   64

Definition at line 66 of file sha2.h.

◆ SHA512_DIGEST_STRING_LENGTH

#define SHA512_DIGEST_STRING_LENGTH   (SHA512_DIGEST_LENGTH * 2 + 1)

Definition at line 67 of file sha2.h.

◆ u_int32_t

#define u_int32_t   unsigned int

Definition at line 76 of file sha2.h.

◆ u_int64_t

#define u_int64_t   unsigned long long

Definition at line 77 of file sha2.h.

◆ u_int8_t

#define u_int8_t   unsigned char

Definition at line 75 of file sha2.h.

Typedef Documentation

◆ RZ_SHA256_CTX

typedef struct _SHA256_CTX RZ_SHA256_CTX

◆ RZ_SHA384_CTX

Definition at line 110 of file sha2.h.

◆ RZ_SHA512_CTX

typedef struct _SHA512_CTX RZ_SHA512_CTX

Function Documentation

◆ SHA256_Data()

char* SHA256_Data ( const u_int8_t ,
size_t  ,
char  [SHA256_DIGEST_STRING_LENGTH] 
)

◆ SHA256_End()

char* SHA256_End ( RZ_SHA256_CTX ,
char *   
)

◆ SHA256_Final()

void SHA256_Final ( u_int8_t ,
RZ_SHA256_CTX  
)

◆ SHA256_Init()

void SHA256_Init ( RZ_SHA256_CTX context)

Definition at line 285 of file sha2.c.

285  {
286  if (context == (RZ_SHA256_CTX *)0) {
287  return;
288  }
291  context->bitcount = 0;
292 }
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_mem_memzero(void *, size_t)
Definition: mem.c:365
static const ut32 sha256_initial_hash_value[8]
Definition: sha2.c:199
#define SHA256_DIGEST_LENGTH
Definition: sha2.h:60
#define SHA256_BLOCK_LENGTH
Definition: sha2.h:96
zip_uint8_t buffer[BUFSIZE]

References context::buffer, memcpy(), rz_mem_memzero(), SHA256_BLOCK_LENGTH, SHA256_DIGEST_LENGTH, and sha256_initial_hash_value.

Referenced by plugin_sha256_init(), plugin_sha256_small_block(), and SHA256_Data().

◆ SHA256_Update()

void SHA256_Update ( RZ_SHA256_CTX ,
const u_int8_t ,
size_t   
)

◆ SHA384_Data()

char* SHA384_Data ( const u_int8_t ,
size_t  ,
char  [SHA384_DIGEST_STRING_LENGTH] 
)

◆ SHA384_End()

char* SHA384_End ( RZ_SHA384_CTX ,
char *   
)

◆ SHA384_Final()

void SHA384_Final ( u_int8_t ,
RZ_SHA384_CTX  
)

◆ SHA384_Init()

void SHA384_Init ( RZ_SHA384_CTX context)

Definition at line 938 of file sha2.c.

938  {
939  if (context == (RZ_SHA384_CTX *)0) {
940  return;
941  }
944  context->bitcount[0] = context->bitcount[1] = 0;
945 }
return memset(p, 0, total)
static const ut64 sha384_initial_hash_value[8]
Definition: sha2.c:255
#define SHA512_DIGEST_LENGTH
Definition: sha2.h:66
#define SHA384_BLOCK_LENGTH
Definition: sha2.h:103

References context::buffer, memcpy(), memset(), SHA384_BLOCK_LENGTH, sha384_initial_hash_value, and SHA512_DIGEST_LENGTH.

Referenced by plugin_sha384_init(), plugin_sha384_small_block(), and SHA384_Data().

◆ SHA384_Update()

void SHA384_Update ( RZ_SHA384_CTX ,
const u_int8_t ,
size_t   
)

◆ SHA512_Data()

char* SHA512_Data ( const u_int8_t ,
size_t  ,
char  [SHA512_DIGEST_STRING_LENGTH] 
)

◆ SHA512_End()

char* SHA512_End ( RZ_SHA512_CTX ,
char *   
)

◆ SHA512_Final()

void SHA512_Final ( u_int8_t ,
RZ_SHA512_CTX  
)

◆ SHA512_Init()

void SHA512_Init ( RZ_SHA512_CTX context)

Definition at line 606 of file sha2.c.

606  {
607  if (context == (RZ_SHA512_CTX *)0) {
608  return;
609  }
612  context->bitcount[0] = context->bitcount[1] = 0;
613 }
static const ut64 sha512_initial_hash_value[8]
Definition: sha2.c:267
#define SHA512_BLOCK_LENGTH
Definition: sha2.h:104

References context::buffer, memcpy(), rz_mem_memzero(), SHA512_BLOCK_LENGTH, SHA512_DIGEST_LENGTH, and sha512_initial_hash_value.

Referenced by plugin_sha512_init(), plugin_sha512_small_block(), and SHA512_Data().

◆ SHA512_Update()

void SHA512_Update ( RZ_SHA512_CTX ,
const u_int8_t ,
size_t   
)