2 * Copyright 2016 Michael Müller
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __BCRYPT_INTERNAL_H
21 #define __BCRYPT_INTERNAL_H
30 #define MAGIC_DSS1 ('D' | ('S' << 8) | ('S' << 16) | ('1' << 24))
31 #define MAGIC_DSS2 ('D' | ('S' << 8) | ('S' << 16) | ('2' << 24))
40 void sha256_init(SHA256_CTX
*ctx
) DECLSPEC_HIDDEN
;
41 void sha256_update(SHA256_CTX
*ctx
, const UCHAR
*buffer
, ULONG len
) DECLSPEC_HIDDEN
;
42 void sha256_finalize(SHA256_CTX
*ctx
, UCHAR
*buffer
) DECLSPEC_HIDDEN
;
51 void sha512_init(SHA512_CTX
*ctx
) DECLSPEC_HIDDEN
;
52 void sha512_update(SHA512_CTX
*ctx
, const UCHAR
*buffer
, ULONG len
) DECLSPEC_HIDDEN
;
53 void sha512_finalize(SHA512_CTX
*ctx
, UCHAR
*buffer
) DECLSPEC_HIDDEN
;
55 void sha384_init(SHA512_CTX
*ctx
) DECLSPEC_HIDDEN
;
56 #define sha384_update sha512_update
57 void sha384_finalize(SHA512_CTX
*ctx
, UCHAR
*buffer
) DECLSPEC_HIDDEN
;
60 unsigned char chksum
[16], X
[48], buf
[16];
64 void md2_init(MD2_CTX
*ctx
) DECLSPEC_HIDDEN
;
65 void md2_update(MD2_CTX
*ctx
, const unsigned char *buf
, ULONG len
) DECLSPEC_HIDDEN
;
66 void md2_finalize(MD2_CTX
*ctx
, unsigned char *hash
) DECLSPEC_HIDDEN
;
68 /* Definitions from advapi32 */
69 typedef struct tagMD4_CTX
{
73 unsigned char digest
[16];
76 VOID WINAPI
MD4Init(MD4_CTX
*ctx
);
77 VOID WINAPI
MD4Update(MD4_CTX
*ctx
, const unsigned char *buf
, unsigned int len
);
78 VOID WINAPI
MD4Final(MD4_CTX
*ctx
);
85 unsigned char digest
[16];
88 VOID WINAPI
MD5Init(MD5_CTX
*ctx
);
89 VOID WINAPI
MD5Update(MD5_CTX
*ctx
, const unsigned char *buf
, unsigned int len
);
90 VOID WINAPI
MD5Final(MD5_CTX
*ctx
);
100 VOID WINAPI
A_SHAInit(SHA_CTX
*ctx
);
101 VOID WINAPI
A_SHAUpdate(SHA_CTX
*ctx
, const UCHAR
*buffer
, UINT size
);
102 VOID WINAPI
A_SHAFinal(SHA_CTX
*ctx
, PULONG result
);
104 #define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
105 #define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
106 #define MAGIC_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '0')
107 #define MAGIC_SECRET (('S' << 24) | ('C' << 16) | ('R' << 8) | 'T')
128 /* asymmetric encryption */
131 /* secret agreement */
170 #define KEY_FLAG_LEGACY_DSA_V2 0x00000001
172 struct key_asymmetric
174 ULONG bitlen
; /* ignored for ECC keys */
185 void *private[2]; /* private data for backend */
188 struct key_symmetric s
;
189 struct key_asymmetric a
;
200 NTSTATUS (CDECL
*key_set_property
)( struct key
*, const WCHAR
*, UCHAR
*, ULONG
, ULONG
);
201 NTSTATUS (CDECL
*key_symmetric_init
)( struct key
* );
202 void (CDECL
*key_symmetric_vector_reset
)( struct key
* );
203 NTSTATUS (CDECL
*key_symmetric_set_auth_data
)( struct key
*, UCHAR
*, ULONG
);
204 NTSTATUS (CDECL
*key_symmetric_encrypt
)( struct key
*, const UCHAR
*, ULONG
, UCHAR
*, ULONG
);
205 NTSTATUS (CDECL
*key_symmetric_decrypt
)( struct key
*, const UCHAR
*, ULONG
, UCHAR
*, ULONG
);
206 NTSTATUS (CDECL
*key_symmetric_get_tag
)( struct key
*, UCHAR
*, ULONG
);
207 void (CDECL
*key_symmetric_destroy
)( struct key
* );
208 NTSTATUS (CDECL
*key_asymmetric_init
)( struct key
* );
209 NTSTATUS (CDECL
*key_asymmetric_generate
)( struct key
* );
210 NTSTATUS (CDECL
*key_asymmetric_decrypt
)( struct key
*, UCHAR
*, ULONG
, UCHAR
*, ULONG
, ULONG
* );
211 NTSTATUS (CDECL
*key_asymmetric_duplicate
)( struct key
*, struct key
* );
212 NTSTATUS (CDECL
*key_asymmetric_sign
)( struct key
*, void *, UCHAR
*, ULONG
, UCHAR
*, ULONG
, ULONG
*, ULONG
);
213 NTSTATUS (CDECL
*key_asymmetric_verify
)( struct key
*, void *, UCHAR
*, ULONG
, UCHAR
*, ULONG
, DWORD
);
214 void (CDECL
*key_asymmetric_destroy
)( struct key
* );
215 NTSTATUS (CDECL
*key_export_dsa_capi
)( struct key
*, UCHAR
*, ULONG
, ULONG
* );
216 NTSTATUS (CDECL
*key_export_ecc
)( struct key
*, UCHAR
*, ULONG
, ULONG
* );
217 NTSTATUS (CDECL
*key_import_dsa_capi
)( struct key
*, UCHAR
*, ULONG
);
218 NTSTATUS (CDECL
*key_import_ecc
)( struct key
*, UCHAR
*, ULONG
);
219 NTSTATUS (CDECL
*key_import_rsa
)( struct key
*, UCHAR
*, ULONG
);
222 #endif /* __BCRYPT_INTERNAL_H */