Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
Sha256.h
Go to the documentation of this file.
1/* Sha256.h -- SHA-256 Hash
2: Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_SHA256_H
5#define ZIP7_INC_SHA256_H
6
7#include "7zTypes.h"
8
10
11#define SHA256_NUM_BLOCK_WORDS 16
12#define SHA256_NUM_DIGEST_WORDS 8
13
14#define SHA256_BLOCK_SIZE (SHA256_NUM_BLOCK_WORDS * 4)
15#define SHA256_DIGEST_SIZE (SHA256_NUM_DIGEST_WORDS * 4)
16
17
18
19
20typedef void (Z7_FASTCALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks);
21
22/*
23 if (the system supports different SHA256 code implementations)
24 {
25 (CSha256::func_UpdateBlocks) will be used
26 (CSha256::func_UpdateBlocks) can be set by
27 Sha256_Init() - to default (fastest)
28 Sha256_SetFunction() - to any algo
29 }
30 else
31 {
32 (CSha256::func_UpdateBlocks) is ignored.
33 }
34*/
35
36typedef struct
37{
38 union
39 {
40 struct
41 {
44 } vars;
45 UInt64 _pad_64bit[4];
46 void *_pad_align_ptr[2];
47 } v;
49
51} CSha256;
52
53
54#define SHA256_ALGO_DEFAULT 0
55#define SHA256_ALGO_SW 1
56#define SHA256_ALGO_HW 2
57
58/*
59Sha256_SetFunction()
60return:
61 0 - (algo) value is not supported, and func_UpdateBlocks was not changed
62 1 - func_UpdateBlocks was set according (algo) value.
63*/
64
65BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo);
66
68void Sha256_Init(CSha256 *p);
69void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
70void Sha256_Final(CSha256 *p, Byte *digest);
71
72
73
74
75// void Z7_FASTCALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks);
76
77/*
78call Sha256Prepare() once at program start.
79It prepares all supported implementations, and detects the fastest implementation.
80*/
81
82void Sha256Prepare(void);
83
85
86#endif
int BoolInt
Definition 7zTypes.h:259
#define EXTERN_C_BEGIN
Definition 7zTypes.h:20
unsigned long long int UInt64
Definition 7zTypes.h:234
#define Z7_FASTCALL
Definition 7zTypes.h:308
#define EXTERN_C_END
Definition 7zTypes.h:21
void Sha256_Init(CSha256 *p)
Definition Sha256.c:128
void Sha256_Final(CSha256 *p, Byte *digest)
Definition Sha256.c:400
#define SHA256_BLOCK_SIZE
Definition Sha256.h:14
void Sha256_InitState(CSha256 *p)
Definition Sha256.c:108
void Sha256Prepare(void)
Definition Sha256.c:441
BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo)
Definition Sha256.c:61
void Sha256_Update(CSha256 *p, const Byte *data, size_t size)
Definition Sha256.c:366
void(Z7_FASTCALL * SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks)
Definition Sha256.h:20
#define SHA256_NUM_DIGEST_WORDS
Definition Sha256.h:12
static const void * data
Definition XzCrc64.c:50
Definition Sha256.h:37
SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks
Definition Sha256.h:42
UInt64 count
Definition Sha256.h:43
Definition poolTests.c:28
size_t size
Definition platform.h:559
unsigned int UInt32
Definition bzlib_private.h:45
unsigned char Byte
Definition zconf.h:391