ReactOS 0.4.17-dev-863-gc5f151a
commoncrypto.c
Go to the documentation of this file.
1#include "precomp.h"
2
3#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
5{
6 return STATUS_SUCCESS;
7}
8
10{
11 return STATUS_SUCCESS;
12}
13
14NTSTATUS hash_init( struct hash *hash )
15{
16 switch (hash->alg_id)
17 {
18 case ALG_ID_MD5:
19 CC_MD5_Init( &hash->u.md5_ctx );
20 break;
21
22 case ALG_ID_SHA1:
23 CC_SHA1_Init( &hash->u.sha1_ctx );
24 break;
25
26 case ALG_ID_SHA256:
27 CC_SHA256_Init( &hash->u.sha256_ctx );
28 break;
29
30 case ALG_ID_SHA384:
31 CC_SHA384_Init( &hash->u.sha512_ctx );
32 break;
33
34 case ALG_ID_SHA512:
35 CC_SHA512_Init( &hash->u.sha512_ctx );
36 break;
37
38 default:
39 ERR( "unhandled id %u\n", hash->alg_id );
41 }
42 return STATUS_SUCCESS;
43}
44
45NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
46{
47 CCHmacAlgorithm cc_algorithm;
48 switch (hash->alg_id)
49 {
50 case ALG_ID_MD5:
51 cc_algorithm = kCCHmacAlgMD5;
52 break;
53
54 case ALG_ID_SHA1:
55 cc_algorithm = kCCHmacAlgSHA1;
56 break;
57
58 case ALG_ID_SHA256:
59 cc_algorithm = kCCHmacAlgSHA256;
60 break;
61
62 case ALG_ID_SHA384:
63 cc_algorithm = kCCHmacAlgSHA384;
64 break;
65
66 case ALG_ID_SHA512:
67 cc_algorithm = kCCHmacAlgSHA512;
68 break;
69
70 default:
71 ERR( "unhandled id %u\n", hash->alg_id );
73 }
74
75 CCHmacInit( &hash->u.hmac_ctx, cc_algorithm, key, key_size );
76 return STATUS_SUCCESS;
77}
78
79
81{
82 switch (hash->alg_id)
83 {
84 case ALG_ID_MD5:
85 CC_MD5_Update( &hash->u.md5_ctx, input, size );
86 break;
87
88 case ALG_ID_SHA1:
89 CC_SHA1_Update( &hash->u.sha1_ctx, input, size );
90 break;
91
92 case ALG_ID_SHA256:
93 CC_SHA256_Update( &hash->u.sha256_ctx, input, size );
94 break;
95
96 case ALG_ID_SHA384:
97 CC_SHA384_Update( &hash->u.sha512_ctx, input, size );
98 break;
99
100 case ALG_ID_SHA512:
101 CC_SHA512_Update( &hash->u.sha512_ctx, input, size );
102 break;
103
104 default:
105 ERR( "unhandled id %u\n", hash->alg_id );
107 }
108 return STATUS_SUCCESS;
109}
110
112{
113 CCHmacUpdate( &hash->u.hmac_ctx, input, size );
114 return STATUS_SUCCESS;
115}
116
117NTSTATUS hash_finish( struct hash *hash, UCHAR *output )
118{
119 switch (hash->alg_id)
120 {
121 case ALG_ID_MD5:
122 CC_MD5_Final( output, &hash->u.md5_ctx );
123 break;
124
125 case ALG_ID_SHA1:
126 CC_SHA1_Final( output, &hash->u.sha1_ctx );
127 break;
128
129 case ALG_ID_SHA256:
130 CC_SHA256_Final( output, &hash->u.sha256_ctx );
131 break;
132
133 case ALG_ID_SHA384:
134 CC_SHA384_Final( output, &hash->u.sha512_ctx );
135 break;
136
137 case ALG_ID_SHA512:
138 CC_SHA512_Final( output, &hash->u.sha512_ctx );
139 break;
140
141 default:
142 ERR( "unhandled id %u\n", hash->alg_id );
143 break;
144 }
145 return STATUS_SUCCESS;
146}
147
148NTSTATUS hmac_finish( struct hash *hash, UCHAR *output )
149{
150 CCHmacFinal( &hash->u.hmac_ctx, output );
151
152 return STATUS_SUCCESS;
153}
154
156{
158}
159
161{
163}
164
166{
168}
169
171{
173}
174
176{
178}
179
181{
183}
184
186{
188}
189
191{
193}
194
196{
198}
199
201{
203}
204
206{
208}
209
211{
213}
214
216{
218}
219
221{
223}
224
226{
228}
229
231{
233}
234
235#endif /* HAVE_COMMONCRYPTO_COMMONDIGEST_H */
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
NTSTATUS hmac_init(struct hash *hash, UCHAR *key, ULONG key_size)
NTSTATUS key_symmetric_vector_reset(void *args)
NTSTATUS key_symmetric_encrypt_internal(void *args)
NTSTATUS key_asymmetric_export(void *args)
NTSTATUS key_symmetric_set_auth_data(void *args)
NTSTATUS key_symmetric_get_tag(void *args)
NTSTATUS hash_update(struct hash *hash, UCHAR *input, ULONG size)
NTSTATUS key_asymmetric_encrypt(void *args)
NTSTATUS key_symmetric_destroy(void *args)
NTSTATUS key_symmetric_decrypt_internal(void *args)
NTSTATUS hmac_update(struct hash *hash, UCHAR *input, ULONG size)
NTSTATUS hash_finish(struct hash *hash, UCHAR *output)
NTSTATUS key_asymmetric_generate(void *args)
NTSTATUS key_asymmetric_destroy(void *args)
NTSTATUS process_attach(void *args)
NTSTATUS key_asymmetric_verify(void *args)
NTSTATUS key_asymmetric_derive_key(void *args)
NTSTATUS key_asymmetric_import(void *args)
NTSTATUS hash_init(struct hash *hash)
NTSTATUS key_asymmetric_sign(void *args)
NTSTATUS key_asymmetric_decrypt(void *args)
NTSTATUS key_asymmetric_duplicate(void *args)
NTSTATUS hmac_finish(struct hash *hash, UCHAR *output)
@ ALG_ID_SHA512
@ ALG_ID_SHA384
@ ALG_ID_SHA1
@ ALG_ID_SHA256
@ ALG_ID_MD5
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
static void process_detach(void)
Definition: main.c:94
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: match.c:390
enum alg_id alg_id
Definition: copy.c:22
unsigned char UCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59