sha2.h File Reference

Go to the source code of this file.

Data Structures

struct  _ldns_sha256_CTX
 
struct  _ldns_sha512_CTX
 

Macros

#define LDNS_SHA256_BLOCK_LENGTH   64
 
#define LDNS_SHA256_DIGEST_LENGTH   32
 
#define LDNS_SHA256_DIGEST_STRING_LENGTH   (LDNS_SHA256_DIGEST_LENGTH * 2 + 1)
 
#define LDNS_SHA384_BLOCK_LENGTH   128
 
#define LDNS_SHA384_DIGEST_LENGTH   48
 
#define LDNS_SHA384_DIGEST_STRING_LENGTH   (LDNS_SHA384_DIGEST_LENGTH * 2 + 1)
 
#define LDNS_SHA512_BLOCK_LENGTH   128
 
#define LDNS_SHA512_DIGEST_LENGTH   64
 
#define LDNS_SHA512_DIGEST_STRING_LENGTH   (LDNS_SHA512_DIGEST_LENGTH * 2 + 1)
 

Typedefs

typedef struct _ldns_sha256_CTX ldns_sha256_CTX
 
typedef struct _ldns_sha512_CTX ldns_sha512_CTX
 
typedef ldns_sha512_CTX ldns_sha384_CTX
 

Functions

void ldns_sha256_init (ldns_sha256_CTX *)
 
void ldns_sha256_update (ldns_sha256_CTX *, const uint8_t *, size_t)
 
void ldns_sha256_final (uint8_t[32], ldns_sha256_CTX *)
 
void ldns_sha384_init (ldns_sha384_CTX *)
 
void ldns_sha384_update (ldns_sha384_CTX *, const uint8_t *, size_t)
 
void ldns_sha384_final (uint8_t[48], ldns_sha384_CTX *)
 
void ldns_sha512_init (ldns_sha512_CTX *)
 
void ldns_sha512_update (ldns_sha512_CTX *, const uint8_t *, size_t)
 
void ldns_sha512_final (uint8_t[64], ldns_sha512_CTX *)
 
unsigned char * ldns_sha256 (const unsigned char *data, unsigned int data_len, unsigned char *digest)
 Convenience function to digest a fixed block of data at once. More...
 
unsigned char * ldns_sha384 (const unsigned char *data, unsigned int data_len, unsigned char *digest)
 Convenience function to digest a fixed block of data at once. More...
 
unsigned char * ldns_sha512 (const unsigned char *data, unsigned int data_len, unsigned char *digest)
 Convenience function to digest a fixed block of data at once. More...
 

Macro Definition Documentation

◆ LDNS_SHA256_BLOCK_LENGTH

#define LDNS_SHA256_BLOCK_LENGTH   64

Definition at line 62 of file sha2.h.

◆ LDNS_SHA256_DIGEST_LENGTH

#define LDNS_SHA256_DIGEST_LENGTH   32

Definition at line 63 of file sha2.h.

◆ LDNS_SHA256_DIGEST_STRING_LENGTH

#define LDNS_SHA256_DIGEST_STRING_LENGTH   (LDNS_SHA256_DIGEST_LENGTH * 2 + 1)

Definition at line 64 of file sha2.h.

◆ LDNS_SHA384_BLOCK_LENGTH

#define LDNS_SHA384_BLOCK_LENGTH   128

Definition at line 65 of file sha2.h.

◆ LDNS_SHA384_DIGEST_LENGTH

#define LDNS_SHA384_DIGEST_LENGTH   48

Definition at line 66 of file sha2.h.

◆ LDNS_SHA384_DIGEST_STRING_LENGTH

#define LDNS_SHA384_DIGEST_STRING_LENGTH   (LDNS_SHA384_DIGEST_LENGTH * 2 + 1)

Definition at line 67 of file sha2.h.

◆ LDNS_SHA512_BLOCK_LENGTH

#define LDNS_SHA512_BLOCK_LENGTH   128

Definition at line 68 of file sha2.h.

◆ LDNS_SHA512_DIGEST_LENGTH

#define LDNS_SHA512_DIGEST_LENGTH   64

Definition at line 69 of file sha2.h.

◆ LDNS_SHA512_DIGEST_STRING_LENGTH

#define LDNS_SHA512_DIGEST_STRING_LENGTH   (LDNS_SHA512_DIGEST_LENGTH * 2 + 1)

Definition at line 70 of file sha2.h.

Typedef Documentation

◆ ldns_sha256_CTX

◆ ldns_sha512_CTX

◆ ldns_sha384_CTX

Definition at line 86 of file sha2.h.

Function Documentation

◆ ldns_sha256_init()

void ldns_sha256_init ( ldns_sha256_CTX context)

Definition at line 315 of file sha2.c.

References MEMCPY_BCOPY, and _ldns_sha256_CTX::state.

◆ ldns_sha256_update()

void ldns_sha256_update ( ldns_sha256_CTX context,
const uint8_t *  data,
size_t  len 
)

◆ ldns_sha256_final()

void ldns_sha256_final ( uint8_t  digest[32],
ldns_sha256_CTX context 
)

◆ ldns_sha384_init()

void ldns_sha384_init ( ldns_sha384_CTX context)

Definition at line 948 of file sha2.c.

References MEMCPY_BCOPY, and _ldns_sha512_CTX::state.

◆ ldns_sha384_update()

void ldns_sha384_update ( ldns_sha384_CTX context,
const uint8_t *  data,
size_t  len 
)

Definition at line 957 of file sha2.c.

References ldns_sha512_update().

◆ ldns_sha384_final()

void ldns_sha384_final ( uint8_t  digest[48],
ldns_sha384_CTX context 
)

Definition at line 961 of file sha2.c.

◆ ldns_sha512_init()

void ldns_sha512_init ( ldns_sha512_CTX context)

Definition at line 634 of file sha2.c.

References MEMCPY_BCOPY, and _ldns_sha512_CTX::state.

◆ ldns_sha512_update()

void ldns_sha512_update ( ldns_sha512_CTX context,
const uint8_t *  data,
size_t  len 
)

◆ ldns_sha512_final()

void ldns_sha512_final ( uint8_t  digest[64],
ldns_sha512_CTX context 
)

Definition at line 908 of file sha2.c.

◆ ldns_sha256()

unsigned char* ldns_sha256 ( const unsigned char *  data,
unsigned int  data_len,
unsigned char *  digest 
)

Convenience function to digest a fixed block of data at once.

Parameters
[in]datathe data to digest
[in]data_lenthe length of data in bytes
[out]digestthe length of data in bytes This pointer MUST have LDNS_SHA256_DIGEST_LENGTH bytes available
Returns
the SHA1 digest of the given data

Definition at line 624 of file sha2.c.

References ldns_sha256_final(), ldns_sha256_init(), and ldns_sha256_update().

◆ ldns_sha384()

unsigned char* ldns_sha384 ( const unsigned char *  data,
unsigned int  data_len,
unsigned char *  digest 
)

Convenience function to digest a fixed block of data at once.

Parameters
[in]datathe data to digest
[in]data_lenthe length of data in bytes
[out]digestthe length of data in bytes This pointer MUST have LDNS_SHA384_DIGEST_LENGTH bytes available
Returns
the SHA1 digest of the given data

Definition at line 991 of file sha2.c.

References ldns_sha384_final(), ldns_sha384_init(), and ldns_sha384_update().

◆ ldns_sha512()

unsigned char* ldns_sha512 ( const unsigned char *  data,
unsigned int  data_len,
unsigned char *  digest 
)

Convenience function to digest a fixed block of data at once.

Parameters
[in]datathe data to digest
[in]data_lenthe length of data in bytes
[out]digestthe length of data in bytes This pointer MUST have LDNS_SHA512_DIGEST_LENGTH bytes available
Returns
the SHA1 digest of the given data

Definition at line 938 of file sha2.c.

References ldns_sha512_final(), ldns_sha512_init(), and ldns_sha512_update().