/*
This header file is hereby released to the public domain.
~aaaaaa123456789, 2014-10-25
*/
#ifndef SHA256
#define SHA256
#ifdef __cplusplus
extern "C" {
#endif
enum sha256_opcodes {
// inputs
SHA256_IN_BLOCK = 0,
SHA256_IN_BUFFER = 1,
SHA256_IN_FILE = 2,
SHA256_IN_FILENAME = 3,
// outputs
SHA256_OUT_WORDS = 0, // 32 bits
SHA256_OUT_BYTES = 4,
SHA256_OUT_LONGS = 8, // 64 bits
SHA256_OUT_STRING = 12,
// flags
SHA256_LENGTH_BITS = 16, // length is in bits
SHA256_REVERSE_WORDS = 32, // reverse word order
SHA256_UPPERCASE_HEX = 64, // hex digits A-F are uppercase in string outputs
SHA256_REVERSE_ENDIAN = 64, // when not returning 32-bit words
};
enum sha256_errors {
SHA256_INVALID_OPCODE = 1,
SHA256_FILE_NOT_FOUND = 2,
SHA256_INVALID_ARGUMENT = 3,
SHA256_IO_ERROR = 4,
SHA256_PREMATURE_EOF = 5,
};
int sha256(int op, void * in, void * out, long long skip, long long length);
#ifdef __cplusplus
}
#endif
#endif
Comments