tin  2.6.0
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.6.0.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sha.h File Reference
#include <stdint.h>
Include dependency graph for sha.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SHA1Context
 
struct  SHA256Context
 
struct  SHA512Context
 
struct  USHAContext
 
struct  HMACContext
 
struct  HKDFContext
 

Macros

#define _SHA_enum_
 

Typedefs

typedef enum SHAversion SHAversion
 
typedef struct SHA1Context SHA1Context
 
typedef struct SHA256Context SHA256Context
 
typedef struct SHA512Context SHA512Context
 
typedef struct SHA256Context SHA224Context
 
typedef struct SHA512Context SHA384Context
 
typedef struct USHAContext USHAContext
 
typedef struct HMACContext HMACContext
 
typedef struct HKDFContext HKDFContext
 

Enumerations

enum  {
  shaSuccess = 0 , shaNull , shaInputTooLong , shaStateError ,
  shaBadParam
}
 
enum  {
  SHA1_Message_Block_Size = 64 , SHA224_Message_Block_Size = 64 , SHA256_Message_Block_Size = 64 , SHA384_Message_Block_Size = 128 ,
  SHA512_Message_Block_Size = 128 , USHA_Max_Message_Block_Size = SHA512_Message_Block_Size , SHA1HashSize = 20 , SHA224HashSize = 28 ,
  SHA256HashSize = 32 , SHA384HashSize = 48 , SHA512HashSize = 64 , USHAMaxHashSize = SHA512HashSize ,
  SHA1HashSizeBits = 160 , SHA224HashSizeBits = 224 , SHA256HashSizeBits = 256 , SHA384HashSizeBits = 384 ,
  SHA512HashSizeBits = 512 , USHAMaxHashSizeBits = SHA512HashSizeBits
}
 
enum  SHAversion {
  SHA1 , SHA224 , SHA256 , SHA384 ,
  SHA512
}
 

Functions

int SHA1Reset (SHA1Context *)
 
int SHA1Input (SHA1Context *, const uint8_t *bytes, unsigned int bytecount)
 
int SHA1FinalBits (SHA1Context *, uint8_t bits, unsigned int bit_count)
 
int SHA1Result (SHA1Context *, uint8_t Message_Digest[SHA1HashSize])
 
int SHA224Reset (SHA224Context *)
 
int SHA224Input (SHA224Context *, const uint8_t *bytes, unsigned int bytecount)
 
int SHA224FinalBits (SHA224Context *, uint8_t bits, unsigned int bit_count)
 
int SHA224Result (SHA224Context *, uint8_t Message_Digest[SHA224HashSize])
 
int SHA256Reset (SHA256Context *)
 
int SHA256Input (SHA256Context *, const uint8_t *bytes, unsigned int bytecount)
 
int SHA256FinalBits (SHA256Context *, uint8_t bits, unsigned int bit_count)
 
int SHA256Result (SHA256Context *, uint8_t Message_Digest[SHA256HashSize])
 
int SHA384Reset (SHA384Context *)
 
int SHA384Input (SHA384Context *, const uint8_t *bytes, unsigned int bytecount)
 
int SHA384FinalBits (SHA384Context *, uint8_t bits, unsigned int bit_count)
 
int SHA384Result (SHA384Context *, uint8_t Message_Digest[SHA384HashSize])
 
int SHA512Reset (SHA512Context *)
 
int SHA512Input (SHA512Context *, const uint8_t *bytes, unsigned int bytecount)
 
int SHA512FinalBits (SHA512Context *, uint8_t bits, unsigned int bit_count)
 
int SHA512Result (SHA512Context *, uint8_t Message_Digest[SHA512HashSize])
 
int USHAReset (USHAContext *context, SHAversion whichSha)
 
int USHAInput (USHAContext *context, const uint8_t *bytes, unsigned int bytecount)
 
int USHAFinalBits (USHAContext *context, uint8_t bits, unsigned int bit_count)
 
int USHAResult (USHAContext *context, uint8_t Message_Digest[USHAMaxHashSize])
 
int USHABlockSize (enum SHAversion whichSha)
 
int USHAHashSize (enum SHAversion whichSha)
 
const char * USHAHashName (enum SHAversion whichSha)
 
int RFC2104Hmac (SHAversion whichSha, const unsigned char *text, int text_len, const unsigned char *key, int key_len, uint8_t digest[USHAMaxHashSize])
 
int RFC2104HmacReset (HMACContext *context, enum SHAversion whichSha, const unsigned char *key, int key_len)
 
int RFC2104HmacInput (HMACContext *context, const unsigned char *text, int text_len)
 
int RFC2104HmacFinalBits (HMACContext *context, uint8_t bits, unsigned int bit_count)
 
int RFC2104HmacResult (HMACContext *context, uint8_t digest[USHAMaxHashSize])
 
int RFC5869Hkdf (SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, const unsigned char *info, int info_len, uint8_t okm[], int okm_len)
 
int RFC5869HkdfExtract (SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, uint8_t prk[USHAMaxHashSize])
 
int RFC5869HkdfExpand (SHAversion whichSha, const uint8_t prk[], int prk_len, const unsigned char *info, int info_len, uint8_t okm[], int okm_len)
 
int RFC5869HkdfReset (HKDFContext *context, enum SHAversion whichSha, const unsigned char *salt, int salt_len)
 
int RFC5869HkdfInput (HKDFContext *context, const unsigned char *ikm, int ikm_len)
 
int RFC5869HkdfFinalBits (HKDFContext *context, uint8_t ikm_bits, unsigned int ikm_bit_count)
 
int RFC5869HkdfResult (HKDFContext *context, uint8_t prk[USHAMaxHashSize], const unsigned char *info, int info_len, uint8_t okm[USHAMaxHashSize], int okm_len)
 

Macro Definition Documentation

◆ _SHA_enum_

#define _SHA_enum_

Definition at line 89 of file sha.h.

Typedef Documentation

◆ HKDFContext

typedef struct HKDFContext HKDFContext

◆ HMACContext

typedef struct HMACContext HMACContext

◆ SHA1Context

typedef struct SHA1Context SHA1Context

◆ SHA224Context

typedef struct SHA256Context SHA224Context

Definition at line 188 of file sha.h.

◆ SHA256Context

typedef struct SHA256Context SHA256Context

◆ SHA384Context

typedef struct SHA512Context SHA384Context

Definition at line 194 of file sha.h.

◆ SHA512Context

typedef struct SHA512Context SHA512Context

◆ SHAversion

typedef enum SHAversion SHAversion

◆ USHAContext

typedef struct USHAContext USHAContext

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
shaSuccess 
shaNull 
shaInputTooLong 
shaStateError 
shaBadParam 

Definition at line 93 of file sha.h.

◆ anonymous enum

anonymous enum
Enumerator
SHA1_Message_Block_Size 
SHA224_Message_Block_Size 
SHA256_Message_Block_Size 
SHA384_Message_Block_Size 
SHA512_Message_Block_Size 
USHA_Max_Message_Block_Size 
SHA1HashSize 
SHA224HashSize 
SHA256HashSize 
SHA384HashSize 
SHA512HashSize 
USHAMaxHashSize 
SHA1HashSizeBits 
SHA224HashSizeBits 
SHA256HashSizeBits 
SHA384HashSizeBits 
SHA512HashSizeBits 
USHAMaxHashSizeBits 

Definition at line 106 of file sha.h.

◆ SHAversion

enum SHAversion
Enumerator
SHA1 
SHA224 
SHA256 
SHA384 
SHA512 

Definition at line 123 of file sha.h.

Function Documentation

◆ RFC2104Hmac()

int RFC2104Hmac ( SHAversion  whichSha,
const unsigned char *  text,
int  text_len,
const unsigned char *  key,
int  key_len,
uint8_t  digest[USHAMaxHashSize] 
)

Definition at line 49 of file hmac.c.

References cl_clear_secret(), RFC2104HmacInput(), RFC2104HmacReset(), and RFC2104HmacResult().

Referenced by cl_get_key().

◆ RFC2104HmacFinalBits()

int RFC2104HmacFinalBits ( HMACContext context,
uint8_t  bits,
unsigned int  bit_count 
)

Definition at line 204 of file hmac.c.

References shaNull, shaStateError, and USHAFinalBits().

◆ RFC2104HmacInput()

int RFC2104HmacInput ( HMACContext context,
const unsigned char *  text,
int  text_len 
)

Definition at line 174 of file hmac.c.

References shaNull, shaStateError, and USHAInput().

Referenced by RFC2104Hmac().

◆ RFC2104HmacReset()

int RFC2104HmacReset ( HMACContext context,
enum SHAversion  whichSha,
const unsigned char *  key,
int  key_len 
)

◆ RFC2104HmacResult()

int RFC2104HmacResult ( HMACContext context,
uint8_t  digest[USHAMaxHashSize] 
)

◆ RFC5869Hkdf()

int RFC5869Hkdf ( SHAversion  whichSha,
const unsigned char *  salt,
int  salt_len,
const unsigned char *  ikm,
int  ikm_len,
const unsigned char *  info,
int  info_len,
uint8_t  okm[],
int  okm_len 
)

◆ RFC5869HkdfExpand()

int RFC5869HkdfExpand ( SHAversion  whichSha,
const uint8_t  prk[],
int  prk_len,
const unsigned char *  info,
int  info_len,
uint8_t  okm[],
int  okm_len 
)

◆ RFC5869HkdfExtract()

int RFC5869HkdfExtract ( SHAversion  whichSha,
const unsigned char *  salt,
int  salt_len,
const unsigned char *  ikm,
int  ikm_len,
uint8_t  prk[USHAMaxHashSize] 
)

◆ RFC5869HkdfFinalBits()

int RFC5869HkdfFinalBits ( HKDFContext context,
uint8_t  ikm_bits,
unsigned int  ikm_bit_count 
)

◆ RFC5869HkdfInput()

int RFC5869HkdfInput ( HKDFContext context,
const unsigned char *  ikm,
int  ikm_len 
)

◆ RFC5869HkdfReset()

int RFC5869HkdfReset ( HKDFContext context,
enum SHAversion  whichSha,
const unsigned char *  salt,
int  salt_len 
)

◆ RFC5869HkdfResult()

int RFC5869HkdfResult ( HKDFContext context,
uint8_t  prk[USHAMaxHashSize],
const unsigned char *  info,
int  info_len,
uint8_t  okm[USHAMaxHashSize],
int  okm_len 
)

◆ SHA1FinalBits()

int SHA1FinalBits ( SHA1Context context,
uint8_t  bits,
unsigned int  bit_count 
)

Definition at line 163 of file sha1.c.

References SHA1AddLength, SHA1Finalize(), shaBadParam, shaNull, shaStateError, and shaSuccess.

Referenced by USHAFinalBits().

◆ SHA1Input()

int SHA1Input ( SHA1Context ,
const uint8_t *  bytes,
unsigned int  bytecount 
)

Referenced by USHAInput().

◆ SHA1Reset()

int SHA1Reset ( SHA1Context context)

Definition at line 81 of file sha1.c.

References shaNull, and shaSuccess.

Referenced by USHAReset().

◆ SHA1Result()

int SHA1Result ( SHA1Context context,
uint8_t  Message_Digest[SHA1HashSize] 
)

Definition at line 213 of file sha1.c.

References SHA1Finalize(), SHA1HashSize, shaNull, and shaSuccess.

Referenced by USHAResult().

◆ SHA224FinalBits()

int SHA224FinalBits ( SHA224Context context,
uint8_t  bits,
unsigned int  bit_count 
)

Definition at line 163 of file sha224-256.c.

References SHA256FinalBits().

Referenced by USHAFinalBits().

◆ SHA224Input()

int SHA224Input ( SHA224Context context,
const uint8_t *  bytes,
unsigned int  bytecount 
)

Definition at line 138 of file sha224-256.c.

References SHA256Input().

Referenced by USHAInput().

◆ SHA224Reset()

int SHA224Reset ( SHA224Context context)

Definition at line 113 of file sha224-256.c.

References SHA224_256Reset(), and SHA224_H0.

Referenced by USHAReset().

◆ SHA224Result()

int SHA224Result ( SHA224Context context,
uint8_t  Message_Digest[SHA224HashSize] 
)

Definition at line 188 of file sha224-256.c.

References SHA224_256ResultN(), and SHA224HashSize.

Referenced by USHAResult().

◆ SHA256FinalBits()

int SHA256FinalBits ( SHA256Context context,
uint8_t  bits,
unsigned int  bit_count 
)

◆ SHA256Input()

int SHA256Input ( SHA256Context context,
const uint8_t *  bytes,
unsigned int  bytecount 
)

◆ SHA256Reset()

int SHA256Reset ( SHA256Context context)

Definition at line 208 of file sha224-256.c.

References SHA224_256Reset(), and SHA256_H0.

Referenced by USHAReset().

◆ SHA256Result()

int SHA256Result ( SHA256Context context,
uint8_t  Message_Digest[SHA256HashSize] 
)

Definition at line 323 of file sha224-256.c.

References SHA224_256ResultN(), and SHA256HashSize.

Referenced by USHAResult().

◆ SHA384FinalBits()

int SHA384FinalBits ( SHA384Context context,
uint8_t  bits,
unsigned int  bit_count 
)

Definition at line 400 of file sha384-512.c.

References SHA512FinalBits().

Referenced by USHAFinalBits().

◆ SHA384Input()

int SHA384Input ( SHA384Context context,
const uint8_t *  bytes,
unsigned int  bytecount 
)

Definition at line 374 of file sha384-512.c.

References SHA512Input().

Referenced by USHAInput().

◆ SHA384Reset()

int SHA384Reset ( SHA384Context context)

Definition at line 349 of file sha384-512.c.

References SHA384_512Reset(), and SHA384_H0.

Referenced by USHAReset().

◆ SHA384Result()

int SHA384Result ( SHA384Context context,
uint8_t  Message_Digest[SHA384HashSize] 
)

Definition at line 426 of file sha384-512.c.

References SHA384_512ResultN(), and SHA384HashSize.

Referenced by USHAResult().

◆ SHA512FinalBits()

int SHA512FinalBits ( SHA512Context context,
uint8_t  bits,
unsigned int  bit_count 
)

◆ SHA512Input()

int SHA512Input ( SHA512Context context,
const uint8_t *  bytes,
unsigned int  bytecount 
)

◆ SHA512Reset()

int SHA512Reset ( SHA512Context context)

Definition at line 447 of file sha384-512.c.

References SHA384_512Reset(), and SHA512_H0.

Referenced by USHAReset().

◆ SHA512Result()

int SHA512Result ( SHA512Context context,
uint8_t  Message_Digest[SHA512HashSize] 
)

Definition at line 565 of file sha384-512.c.

References SHA384_512ResultN(), and SHA512HashSize.

Referenced by USHAResult().

◆ USHABlockSize()

◆ USHAFinalBits()

int USHAFinalBits ( USHAContext context,
uint8_t  bits,
unsigned int  bit_count 
)

◆ USHAHashName()

const char * USHAHashName ( enum SHAversion  whichSha)

Definition at line 272 of file usha.c.

References SHA1, SHA224, SHA256, SHA384, and SHA512.

◆ USHAHashSize()

int USHAHashSize ( enum SHAversion  whichSha)

◆ USHAInput()

int USHAInput ( USHAContext context,
const uint8_t *  bytes,
unsigned int  bytecount 
)

◆ USHAReset()

int USHAReset ( USHAContext context,
SHAversion  whichSha 
)

◆ USHAResult()

int USHAResult ( USHAContext context,
uint8_t  Message_Digest[USHAMaxHashSize] 
)