sha256.h
author Ryan C. Gordon <icculus@icculus.org>
Sun, 18 Jun 2017 19:40:30 -0400
changeset 56 a573346e6f7b
parent 46 fe4f59680246
permissions -rw-r--r--
Added One Time Password support.

This is only for time-based OTP for now ("TOPT" algorithm), but that's more
or less what one expects to see in the wild anyhow.

This is sort of a placeholder UI until I replace the entire existing UI with
something better.
icculus@46
     1
/*********************************************************************
icculus@46
     2
* Filename:   sha256.h
icculus@46
     3
* Author:     Brad Conte (brad AT bradconte.com)
icculus@46
     4
* Copyright:
icculus@46
     5
* Disclaimer: This code is presented "as is" without any guarantees.
icculus@46
     6
* Details:    Defines the API for the corresponding SHA1 implementation.
icculus@46
     7
*********************************************************************/
icculus@46
     8
icculus@46
     9
#ifndef SHA256_H
icculus@46
    10
#define SHA256_H
icculus@46
    11
icculus@46
    12
/*************************** HEADER FILES ***************************/
icculus@46
    13
#include <stddef.h>
icculus@46
    14
icculus@46
    15
/****************************** MACROS ******************************/
icculus@46
    16
#define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
icculus@46
    17
icculus@46
    18
/**************************** DATA TYPES ****************************/
icculus@46
    19
typedef unsigned char BYTE;             // 8-bit byte
icculus@46
    20
typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
icculus@46
    21
icculus@46
    22
typedef struct {
icculus@46
    23
	BYTE data[64];
icculus@46
    24
	WORD datalen;
icculus@46
    25
	unsigned long long bitlen;
icculus@46
    26
	WORD state[8];
icculus@46
    27
} SHA256_CTX;
icculus@46
    28
icculus@46
    29
/*********************** FUNCTION DECLARATIONS **********************/
icculus@46
    30
void sha256_init(SHA256_CTX *ctx);
icculus@46
    31
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
icculus@46
    32
void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
icculus@46
    33
icculus@46
    34
#endif   // SHA256_H