Bump versions.
[shishi.git] / lib / crypto.h
blobd9361fb21412ec1789eec91004cb8435e0daf9a9
1 /* crypto.h --- Crypto prototypes.
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifndef _CRYPTO_H
23 #define _CRYPTO_H
25 #define SHISHI_DK_CONSTANT "\x6b\x65\x72\x62\x65\x72\x6f\x73"
27 extern int _shishi_crypto_init (Shishi * handle);
29 int
30 _shishi_simplified_derivekey (Shishi * handle,
31 Shishi_key * key,
32 int keyusage,
33 int derivekeymode, Shishi_key ** outkey);
34 int
35 _shishi_simplified_checksum (Shishi * handle,
36 Shishi_key * key,
37 int keyusage,
38 int cksumtype,
39 const char *in, size_t inlen,
40 char **out, size_t * outlen);
41 int
42 _shishi_simplified_dencrypt (Shishi * handle,
43 Shishi_key * key,
44 const char *iv, size_t ivlen,
45 char **ivout, size_t * ivoutlen,
46 const char *in, size_t inlen,
47 char **out, size_t * outlen, int decryptp);
48 int
49 _shishi_simplified_encrypt (Shishi * handle,
50 Shishi_key * key,
51 int keyusage,
52 const char *iv, size_t ivlen,
53 char **ivout, size_t * ivoutlen,
54 const char *in, size_t inlen,
55 char **out, size_t * outlen);
56 int
57 _shishi_simplified_decrypt (Shishi * handle,
58 Shishi_key * key,
59 int keyusage,
60 const char *iv, size_t ivlen,
61 char **ivout, size_t * ivoutlen,
62 const char *in, size_t inlen,
63 char **out, size_t * outlen);
65 typedef enum
67 SHISHI_DERIVEKEYMODE_CHECKSUM,
68 SHISHI_DERIVEKEYMODE_PRIVACY,
69 SHISHI_DERIVEKEYMODE_INTEGRITY
71 Shishi_derivekeymode;
73 typedef int (*Shishi_random_to_key_function) (Shishi * handle,
74 const char *rnd,
75 size_t rndlen,
76 Shishi_key * outkey);
78 typedef int (*Shishi_string_to_key_function) (Shishi * handle,
79 const char *password,
80 size_t passwordlen,
81 const char *salt,
82 size_t saltlen,
83 const char *parameter,
84 Shishi_key * outkey);
86 typedef int (*Shishi_encrypt_function) (Shishi * handle,
87 Shishi_key * key,
88 int keyusage,
89 const char *iv, size_t ivlen,
90 char **ivout, size_t * ivoutlen,
91 const char *in, size_t inlen,
92 char **out, size_t * outlen);
94 typedef int (*Shishi_decrypt_function) (Shishi * handle,
95 Shishi_key * key,
96 int keyusage,
97 const char *iv, size_t ivlen,
98 char **ivout, size_t * ivoutlen,
99 const char *in, size_t inlen,
100 char **out, size_t * outlen);
102 typedef int (*Shishi_checksum_function) (Shishi * handle,
103 Shishi_key * key,
104 int keyusage,
105 int cksumtype,
106 const char *in, size_t inlen,
107 char **out, size_t * outlen);
109 typedef int (*Shishi_verify_function) (Shishi * handle,
110 Shishi_key * key,
111 int keyusage,
112 int cksumtype,
113 const char *in, size_t inlen,
114 const char *cksum, size_t cksumlen);
116 struct cipherinfo
118 int32_t type;
119 const char *name;
120 int blocksize;
121 int confoundersize;
122 int keylen;
123 int randomlen;
124 int defaultcksumtype;
125 Shishi_random_to_key_function random2key;
126 Shishi_string_to_key_function string2key;
127 Shishi_encrypt_function encrypt;
128 Shishi_decrypt_function decrypt;
130 typedef struct cipherinfo cipherinfo;
132 struct checksuminfo
134 int32_t type;
135 const char *name;
136 int cksumlen;
137 Shishi_checksum_function checksum;
138 Shishi_verify_function verify;
140 typedef struct checksuminfo checksuminfo;
142 extern cipherinfo null_info;
144 extern checksuminfo crc32_info;
145 extern checksuminfo md4_info;
146 extern checksuminfo md5_info;
148 extern cipherinfo des_cbc_crc_info;
149 extern cipherinfo des_cbc_md4_info;
150 extern cipherinfo des_cbc_md5_info;
151 extern cipherinfo des_cbc_none_info;
152 extern checksuminfo md4_des_info;
153 extern checksuminfo md5_des_info;
154 extern checksuminfo md5_gss_info;
156 extern cipherinfo des3_cbc_none_info;
157 extern cipherinfo des3_cbc_sha1_kd_info;
158 extern checksuminfo hmac_sha1_des3_kd_info;
160 extern cipherinfo aes128_cts_hmac_sha1_96_info;
161 extern cipherinfo aes256_cts_hmac_sha1_96_info;
162 extern checksuminfo hmac_sha1_96_aes128_info;
163 extern checksuminfo hmac_sha1_96_aes256_info;
165 extern cipherinfo arcfour_hmac_info;
166 extern cipherinfo arcfour_hmac_exp_info;
167 extern checksuminfo arcfour_hmac_md5_info;
169 #endif