totp

Simple cli tool for storing TOTP secrets and generating tokens
git clone https://git.inz.fi/totp/
Log | Files | Refs | Submodules

sha256.h (782B)


      1 #ifndef SHA256_H
      2 #define SHA256_H
      3 
      4 #include <stdlib.h>
      5 #include <stdint.h>
      6 
      7 #define SHA256_HASHSIZE 32
      8 #define SHA224_HASHSIZE 28
      9 
     10 struct sha256 {
     11 	uint8_t buffer[64];
     12 	uint32_t h[8];
     13 	uint64_t len;
     14 };
     15 
     16 struct sha224 {
     17 	uint8_t buffer[64];
     18 	uint32_t h[7];
     19 	uint32_t h7;
     20 	uint64_t len;
     21 };
     22 
     23 void sha256_init(struct sha256 *s);
     24 void sha256_update(struct sha256 *s, const void *data, size_t len);
     25 void sha256_finish(struct sha256 *s);
     26 
     27 void sha256_hmac(const void *key, size_t keylen,
     28 		 const void *data, size_t datalen,
     29 		 void *h);
     30 
     31 void sha224_init(struct sha224 *s);
     32 void sha224_update(struct sha224 *s, const void *data, size_t len);
     33 void sha224_finish(struct sha224 *s);
     34 
     35 void sha224_hmac(const void *key, size_t keylen,
     36 		 const void *data, size_t datalen,
     37 		 void *h);
     38 
     39 #endif