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
22023-04-02 : 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
17typedef void (Z7_FASTCALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks);
18
19/*
20 if (the system supports different SHA256 code implementations)
21 {
22 (CSha256::func_UpdateBlocks) will be used
23 (CSha256::func_UpdateBlocks) can be set by
24 Sha256_Init() - to default (fastest)
25 Sha256_SetFunction() - to any algo
26 }
27 else
28 {
29 (CSha256::func_UpdateBlocks) is ignored.
30 }
31*/
32
33typedef struct
34{
35 SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks;
36 UInt64 count;
37 UInt64 _pad_2[2];
39
40 Byte buffer[SHA256_BLOCK_SIZE];
41} CSha256;
42
43
44#define SHA256_ALGO_DEFAULT 0
45#define SHA256_ALGO_SW 1
46#define SHA256_ALGO_HW 2
47
48/*
49Sha256_SetFunction()
50return:
51 0 - (algo) value is not supported, and func_UpdateBlocks was not changed
52 1 - func_UpdateBlocks was set according (algo) value.
53*/
54
55BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo);
56
58void Sha256_Init(CSha256 *p);
59void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
60void Sha256_Final(CSha256 *p, Byte *digest);
61
62
63
64
65// void Z7_FASTCALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks);
66
67/*
68call Sha256Prepare() once at program start.
69It prepares all supported implementations, and detects the fastest implementation.
70*/
71
72void Sha256Prepare(void);
73
75
76#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
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