crypto-algorithms.c

Basic implementations of standard cryptography algorithms, like AES and SHA-1
git clone git://git.finwo.net/lib/crypto-algorithms.c
Log | Files | Refs | README

sha1.h (1203B)


      1 /*********************************************************************
      2 * Filename:   sha1.h
      3 * Author:     Brad Conte (brad AT bradconte.com)
      4 * Copyright:
      5 * Disclaimer: This code is presented "as is" without any guarantees.
      6 * Details:    Defines the API for the corresponding SHA1 implementation.
      7 *********************************************************************/
      8 
      9 #ifndef SHA1_H
     10 #define SHA1_H
     11 
     12 /*************************** HEADER FILES ***************************/
     13 #include <stddef.h>
     14 
     15 /****************************** MACROS ******************************/
     16 #define SHA1_BLOCK_SIZE 20              // SHA1 outputs a 20 byte digest
     17 
     18 /**************************** DATA TYPES ****************************/
     19 typedef unsigned char BYTE;             // 8-bit byte
     20 typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
     21 
     22 typedef struct {
     23 	BYTE data[64];
     24 	WORD datalen;
     25 	unsigned long long bitlen;
     26 	WORD state[5];
     27 	WORD k[4];
     28 } SHA1_CTX;
     29 
     30 /*********************** FUNCTION DECLARATIONS **********************/
     31 void sha1_init(SHA1_CTX *ctx);
     32 void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len);
     33 void sha1_final(SHA1_CTX *ctx, BYTE hash[]);
     34 
     35 #endif   // SHA1_H