rsaenh: Implement exporting PLAINTEXTKEYBLOBs.
[wine] / dlls / rsaenh / implglue.h
1 /*
2  * dlls/rsaenh/implglue.h
3  * Glueing the RSAENH specific code to the crypto library
4  *
5  * Copyright (c) 2004 Michael Jung
6  *
7  * based on code by Mike McCormack and David Hammerton
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #ifndef __WINE_IMPLGLUE_H
25 #define __WINE_IMPLGLUE_H
26
27 #include "tomcrypt.h"
28
29 /* Next typedef copied from dlls/advapi32/crypt_md4.c */
30 typedef struct tagMD4_CTX {
31     unsigned int buf[4];
32     unsigned int i[2];
33     unsigned char in[64];
34     unsigned char digest[16];
35 } MD4_CTX;
36
37 /* Next typedef copied from dlls/advapi32/crypt_md5.c */
38 typedef struct tagMD5_CTX
39 {
40     unsigned int i[2];
41     unsigned int buf[4];
42     unsigned char in[64];
43     unsigned char digest[16];
44 } MD5_CTX;
45
46 /* Next typedef copied form dlls/advapi32/crypt_sha.c */
47 typedef struct tagSHA_CTX
48 {
49     ULONG Unknown[6];
50     ULONG State[5];
51     ULONG Count[2];
52     UCHAR Buffer[64];
53 } SHA_CTX, *PSHA_CTX;
54
55 typedef union tagHASH_CONTEXT {
56     md2_state md2;
57     MD4_CTX md4;
58     MD5_CTX md5;
59     SHA_CTX sha;
60 } HASH_CONTEXT;
61
62 typedef union tagKEY_CONTEXT {
63     rc2_key rc2;
64     des_key des;
65     des3_key des3;
66     aes_key aes;
67     prng_state rc4;
68     rsa_key rsa;
69 } KEY_CONTEXT;
70
71 BOOL init_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext);
72 BOOL update_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, CONST BYTE *pbData, 
73                       DWORD dwDataLen);
74 BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHashValue);
75 BOOL duplicate_hash_impl(ALG_ID aiAlgid, CONST HASH_CONTEXT *pSrcHashContext, 
76                          HASH_CONTEXT *pDestHashContext);
77
78 BOOL new_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen);
79 BOOL free_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext);
80 BOOL setup_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
81                     DWORD dwEffectiveKeyLen, DWORD dwSaltLen, BYTE *abKeyValue);
82 BOOL duplicate_key_impl(ALG_ID aiAlgid, CONST KEY_CONTEXT *pSrcKeyContext, 
83                         KEY_CONTEXT *pDestKeyContext);
84
85 /* dwKeySpec is optional for symmetric key algorithms */
86 BOOL encrypt_block_impl(ALG_ID aiAlgid, DWORD dwKeySpec, KEY_CONTEXT *pKeyContext, CONST BYTE *pbIn, BYTE *pbOut, 
87                         DWORD enc);
88 BOOL encrypt_stream_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, BYTE *pbInOut, DWORD dwLen);
89
90 BOOL export_public_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
91                             DWORD *pdwPubExp);
92 BOOL import_public_key_impl(CONST BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, 
93                             DWORD dwPubExp);
94 BOOL export_private_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
95                              DWORD *pdwPubExp);
96 BOOL import_private_key_impl(CONST BYTE* pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, 
97                              DWORD dwPubExp);
98
99 BOOL gen_rand_impl(BYTE *pbBuffer, DWORD dwLen);
100
101 #endif /* __WINE_IMPLGLUE_H */