No need for getline.h.
[shishi.git] / lib / crypto.h
blobca751ba0ce649f196c82ccdb43e309480351a578
1 /* crypto.h --- Crypto prototypes.
2 * Copyright (C) 2002, 2003, 2004, 2007 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, see http://www.gnu.org/licenses or write
18 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19 * Floor, Boston, MA 02110-1301, USA
23 #ifndef _CRYPTO_H
24 #define _CRYPTO_H
26 #define SHISHI_DK_CONSTANT "\x6b\x65\x72\x62\x65\x72\x6f\x73"
28 extern int _shishi_crypto_init (Shishi * handle);
30 int
31 _shishi_simplified_derivekey (Shishi * handle,
32 Shishi_key * key,
33 int keyusage,
34 int derivekeymode, Shishi_key ** outkey);
35 int
36 _shishi_simplified_checksum (Shishi * handle,
37 Shishi_key * key,
38 int keyusage,
39 int cksumtype,
40 const char *in, size_t inlen,
41 char **out, size_t * outlen);
42 int
43 _shishi_simplified_dencrypt (Shishi * handle,
44 Shishi_key * key,
45 const char *iv, size_t ivlen,
46 char **ivout, size_t * ivoutlen,
47 const char *in, size_t inlen,
48 char **out, size_t * outlen, int decryptp);
49 int
50 _shishi_simplified_encrypt (Shishi * handle,
51 Shishi_key * key,
52 int keyusage,
53 const char *iv, size_t ivlen,
54 char **ivout, size_t * ivoutlen,
55 const char *in, size_t inlen,
56 char **out, size_t * outlen);
57 int
58 _shishi_simplified_decrypt (Shishi * handle,
59 Shishi_key * key,
60 int keyusage,
61 const char *iv, size_t ivlen,
62 char **ivout, size_t * ivoutlen,
63 const char *in, size_t inlen,
64 char **out, size_t * outlen);
66 typedef enum
68 SHISHI_DERIVEKEYMODE_CHECKSUM,
69 SHISHI_DERIVEKEYMODE_PRIVACY,
70 SHISHI_DERIVEKEYMODE_INTEGRITY
72 Shishi_derivekeymode;
74 typedef int (*Shishi_random_to_key_function) (Shishi * handle,
75 const char *rnd,
76 size_t rndlen,
77 Shishi_key * outkey);
79 typedef int (*Shishi_string_to_key_function) (Shishi * handle,
80 const char *password,
81 size_t passwordlen,
82 const char *salt,
83 size_t saltlen,
84 const char *parameter,
85 Shishi_key * outkey);
87 typedef int (*Shishi_encrypt_function) (Shishi * handle,
88 Shishi_key * key,
89 int keyusage,
90 const char *iv, size_t ivlen,
91 char **ivout, size_t * ivoutlen,
92 const char *in, size_t inlen,
93 char **out, size_t * outlen);
95 typedef int (*Shishi_decrypt_function) (Shishi * handle,
96 Shishi_key * key,
97 int keyusage,
98 const char *iv, size_t ivlen,
99 char **ivout, size_t * ivoutlen,
100 const char *in, size_t inlen,
101 char **out, size_t * outlen);
103 typedef int (*Shishi_checksum_function) (Shishi * handle,
104 Shishi_key * key,
105 int keyusage,
106 int cksumtype,
107 const char *in, size_t inlen,
108 char **out, size_t * outlen);
110 typedef int (*Shishi_verify_function) (Shishi * handle,
111 Shishi_key * key,
112 int keyusage,
113 int cksumtype,
114 const char *in, size_t inlen,
115 const char *cksum, size_t cksumlen);
117 struct cipherinfo
119 int32_t type;
120 const char *name;
121 int blocksize;
122 int confoundersize;
123 int keylen;
124 int randomlen;
125 int defaultcksumtype;
126 Shishi_random_to_key_function random2key;
127 Shishi_string_to_key_function string2key;
128 Shishi_encrypt_function encrypt;
129 Shishi_decrypt_function decrypt;
131 typedef struct cipherinfo cipherinfo;
133 struct checksuminfo
135 int32_t type;
136 const char *name;
137 int cksumlen;
138 Shishi_checksum_function checksum;
139 Shishi_verify_function verify;
141 typedef struct checksuminfo checksuminfo;
143 extern cipherinfo null_info;
145 extern checksuminfo crc32_info;
146 extern checksuminfo md4_info;
147 extern checksuminfo md5_info;
149 extern cipherinfo des_cbc_crc_info;
150 extern cipherinfo des_cbc_md4_info;
151 extern cipherinfo des_cbc_md5_info;
152 extern cipherinfo des_cbc_none_info;
153 extern checksuminfo md4_des_info;
154 extern checksuminfo md5_des_info;
155 extern checksuminfo md5_gss_info;
157 extern cipherinfo des3_cbc_none_info;
158 extern cipherinfo des3_cbc_sha1_kd_info;
159 extern checksuminfo hmac_sha1_des3_kd_info;
161 extern cipherinfo aes128_cts_hmac_sha1_96_info;
162 extern cipherinfo aes256_cts_hmac_sha1_96_info;
163 extern checksuminfo hmac_sha1_96_aes128_info;
164 extern checksuminfo hmac_sha1_96_aes256_info;
166 extern cipherinfo arcfour_hmac_info;
167 extern cipherinfo arcfour_hmac_exp_info;
168 extern checksuminfo arcfour_hmac_md5_info;
170 #endif