DEFINITIONS
This source file includes following functions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #ifndef __SHA2_H__
40 #define __SHA2_H__
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #include "defs.h"
47
48
49
50 #define SHA256_BLOCK_LENGTH 64
51 #define SHA256_DIGEST_LENGTH 32
52 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
53 #define SHA384_BLOCK_LENGTH 128
54 #define SHA384_DIGEST_LENGTH 48
55 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
56 #define SHA512_BLOCK_LENGTH 128
57 #define SHA512_DIGEST_LENGTH 64
58 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
59
60
61
62
63 typedef struct _SHA256_CTX {
64 uint32_t state[8];
65 uint64_t bitcount;
66 uint8_t buffer[SHA256_BLOCK_LENGTH];
67 } SHA256_CTX;
68 typedef struct _SHA512_CTX {
69 uint64_t state[8];
70 uint64_t bitcount[2];
71 uint8_t buffer[SHA512_BLOCK_LENGTH];
72 } SHA512_CTX;
73
74 typedef SHA512_CTX SHA384_CTX;
75
76
77 #ifdef RUBY
78 #define SHA256_Init rb_Digest_SHA256_Init
79 #define SHA256_Update rb_Digest_SHA256_Update
80 #define SHA256_Final rb_Digest_SHA256_Final
81 #define SHA256_End rb_Digest_SHA256_End
82 #define SHA256_Data rb_Digest_SHA256_Data
83 #define SHA256_File rb_Digest_SHA256_File
84 #define SHA256_Equal rb_Digest_SHA256_Equal
85
86 #define SHA384_Init rb_Digest_SHA384_Init
87 #define SHA384_Update rb_Digest_SHA384_Update
88 #define SHA384_Final rb_Digest_SHA384_Final
89 #define SHA384_End rb_Digest_SHA384_End
90 #define SHA384_Data rb_Digest_SHA384_Data
91 #define SHA384_File rb_Digest_SHA384_File
92 #define SHA384_Equal rb_Digest_SHA384_Equal
93
94 #define SHA512_Init rb_Digest_SHA512_Init
95 #define SHA512_Update rb_Digest_SHA512_Update
96 #define SHA512_Final rb_Digest_SHA512_Final
97 #define SHA512_End rb_Digest_SHA512_End
98 #define SHA512_Data rb_Digest_SHA512_Data
99 #define SHA512_File rb_Digest_SHA512_File
100 #define SHA512_Equal rb_Digest_SHA512_Equal
101 #endif
102
103
104 void SHA256_Init _((SHA256_CTX *));
105 void SHA256_Update _((SHA256_CTX*, const uint8_t*, size_t));
106 void SHA256_Final _((uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*));
107 char* SHA256_End _((SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]));
108 char* SHA256_Data _((const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]));
109 char *SHA256_File _((char *, char *));
110 int SHA256_Equal _((SHA256_CTX*, SHA256_CTX*));
111
112 void SHA384_Init _((SHA384_CTX*));
113 void SHA384_Update _((SHA384_CTX*, const uint8_t*, size_t));
114 void SHA384_Final _((uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*));
115 char* SHA384_End _((SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]));
116 char* SHA384_Data _((const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]));
117 char *SHA384_File _((char *, char *));
118 int SHA384_Equal _((SHA384_CTX*, SHA384_CTX*));
119
120 void SHA512_Init _((SHA512_CTX*));
121 void SHA512_Update _((SHA512_CTX*, const uint8_t*, size_t));
122 void SHA512_Final _((uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*));
123 char* SHA512_End _((SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]));
124 char* SHA512_Data _((const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]));
125 char *SHA512_File _((char *, char *));
126 int SHA512_Equal _((SHA512_CTX*, SHA512_CTX*));
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif
133