comparison libtomcrypt/src/headers/tomcrypt_mac.h @ 382:0cbe8f6dbf9e

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f) to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:41:05 +0000
parents 1b9e69c058d2
children f849a5ca2efc
comparison
equal deleted inserted replaced
379:b66a00272a90 382:0cbe8f6dbf9e
1 #ifdef HMAC 1 #ifdef LTC_HMAC
2 typedef struct Hmac_state { 2 typedef struct Hmac_state {
3 hash_state md; 3 hash_state md;
4 int hash; 4 int hash;
5 hash_state hashstate; 5 hash_state hashstate;
6 unsigned char *key; 6 unsigned char *key;
21 int hmac_file(int hash, const char *fname, const unsigned char *key, 21 int hmac_file(int hash, const char *fname, const unsigned char *key,
22 unsigned long keylen, 22 unsigned long keylen,
23 unsigned char *dst, unsigned long *dstlen); 23 unsigned char *dst, unsigned long *dstlen);
24 #endif 24 #endif
25 25
26 #ifdef OMAC 26 #ifdef LTC_OMAC
27 27
28 typedef struct { 28 typedef struct {
29 int cipher_idx, 29 int cipher_idx,
30 buflen, 30 buflen,
31 blklen; 31 blklen;
51 const char *filename, 51 const char *filename,
52 unsigned char *out, unsigned long *outlen); 52 unsigned char *out, unsigned long *outlen);
53 int omac_test(void); 53 int omac_test(void);
54 #endif /* OMAC */ 54 #endif /* OMAC */
55 55
56 #ifdef PMAC 56 #ifdef LTC_PMAC
57 57
58 typedef struct { 58 typedef struct {
59 unsigned char Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */ 59 unsigned char Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */
60 Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */ 60 Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */
61 Lr[MAXBLOCKSIZE], /* L * x^-1 */ 61 Lr[MAXBLOCKSIZE], /* L * x^-1 */
96 96
97 #endif /* PMAC */ 97 #endif /* PMAC */
98 98
99 #ifdef EAX_MODE 99 #ifdef EAX_MODE
100 100
101 #if !(defined(OMAC) && defined(CTR)) 101 #if !(defined(LTC_OMAC) && defined(LTC_CTR_MODE))
102 #error EAX_MODE requires OMAC and CTR 102 #error EAX_MODE requires OMAC and CTR
103 #endif 103 #endif
104 104
105 typedef struct { 105 typedef struct {
106 unsigned char N[MAXBLOCKSIZE]; 106 unsigned char N[MAXBLOCKSIZE];
198 #define CCM_ENCRYPT 0 198 #define CCM_ENCRYPT 0
199 #define CCM_DECRYPT 1 199 #define CCM_DECRYPT 1
200 200
201 int ccm_memory(int cipher, 201 int ccm_memory(int cipher,
202 const unsigned char *key, unsigned long keylen, 202 const unsigned char *key, unsigned long keylen,
203 symmetric_key *uskey,
203 const unsigned char *nonce, unsigned long noncelen, 204 const unsigned char *nonce, unsigned long noncelen,
204 const unsigned char *header, unsigned long headerlen, 205 const unsigned char *header, unsigned long headerlen,
205 unsigned char *pt, unsigned long ptlen, 206 unsigned char *pt, unsigned long ptlen,
206 unsigned char *ct, 207 unsigned char *ct,
207 unsigned char *tag, unsigned long *taglen, 208 unsigned char *tag, unsigned long *taglen,
208 int direction); 209 int direction);
209 210
210 int ccm_test(void); 211 int ccm_test(void);
211 212
212 #endif /* CCM_MODE */ 213 #endif /* CCM_MODE */
214
215 #if defined(LRW_MODE) || defined(GCM_MODE)
216 void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c);
217 #endif
218
219
220 /* table shared between GCM and LRW */
221 #if defined(GCM_TABLES) || defined(LRW_TABLES) || ((defined(GCM_MODE) || defined(GCM_MODE)) && defined(LTC_FAST))
222 extern const unsigned char gcm_shift_table[];
223 #endif
213 224
214 #ifdef GCM_MODE 225 #ifdef GCM_MODE
215 226
216 #define GCM_ENCRYPT 0 227 #define GCM_ENCRYPT 0
217 #define GCM_DECRYPT 1 228 #define GCM_DECRYPT 1
235 246
236 ulong64 totlen, /* 64-bit counter used for IV and AAD */ 247 ulong64 totlen, /* 64-bit counter used for IV and AAD */
237 pttotlen; /* 64-bit counter for the PT */ 248 pttotlen; /* 64-bit counter for the PT */
238 249
239 #ifdef GCM_TABLES 250 #ifdef GCM_TABLES
240 unsigned char PC[16][256][16]; /* 16 tables of 8x128 */ 251 unsigned char PC[16][256][16] /* 16 tables of 8x128 */
252 #ifdef GCM_TABLES_SSE2
253 __attribute__ ((aligned (16)))
254 #endif
255 ;
241 #endif 256 #endif
242
243 } gcm_state; 257 } gcm_state;
244 258
245 void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c);
246 void gcm_mult_h(gcm_state *gcm, unsigned char *I); 259 void gcm_mult_h(gcm_state *gcm, unsigned char *I);
247 260
248 int gcm_init(gcm_state *gcm, int cipher, 261 int gcm_init(gcm_state *gcm, int cipher,
249 const unsigned char *key, int keylen); 262 const unsigned char *key, int keylen);
250 263
294 const unsigned char *in, unsigned long inlen, 307 const unsigned char *in, unsigned long inlen,
295 unsigned char *out); 308 unsigned char *out);
296 309
297 #endif 310 #endif
298 311
312 #ifdef LTC_XCBC
313
314 typedef struct {
315 unsigned char K[3][MAXBLOCKSIZE],
316 IV[MAXBLOCKSIZE];
317
318 symmetric_key key;
319
320 int cipher,
321 buflen,
322 blocksize;
323 } xcbc_state;
324
325 int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen);
326 int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen);
327 int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen);
328 int xcbc_memory(int cipher,
329 const unsigned char *key, unsigned long keylen,
330 const unsigned char *in, unsigned long inlen,
331 unsigned char *out, unsigned long *outlen);
332 int xcbc_memory_multi(int cipher,
333 const unsigned char *key, unsigned long keylen,
334 unsigned char *out, unsigned long *outlen,
335 const unsigned char *in, unsigned long inlen, ...);
336 int xcbc_file(int cipher,
337 const unsigned char *key, unsigned long keylen,
338 const char *filename,
339 unsigned char *out, unsigned long *outlen);
340 int xcbc_test(void);
341
342 #endif
343
344 #ifdef LTC_F9_MODE
345
346 typedef struct {
347 unsigned char akey[MAXBLOCKSIZE],
348 ACC[MAXBLOCKSIZE],
349 IV[MAXBLOCKSIZE];
350
351 symmetric_key key;
352
353 int cipher,
354 buflen,
355 keylen,
356 blocksize;
357 } f9_state;
358
359 int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen);
360 int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen);
361 int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen);
362 int f9_memory(int cipher,
363 const unsigned char *key, unsigned long keylen,
364 const unsigned char *in, unsigned long inlen,
365 unsigned char *out, unsigned long *outlen);
366 int f9_memory_multi(int cipher,
367 const unsigned char *key, unsigned long keylen,
368 unsigned char *out, unsigned long *outlen,
369 const unsigned char *in, unsigned long inlen, ...);
370 int f9_file(int cipher,
371 const unsigned char *key, unsigned long keylen,
372 const char *filename,
373 unsigned char *out, unsigned long *outlen);
374 int f9_test(void);
375
376 #endif
377
378
299 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_mac.h,v $ */ 379 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_mac.h,v $ */
300 /* $Revision: 1.7 $ */ 380 /* $Revision: 1.20 $ */
301 /* $Date: 2005/05/05 14:35:58 $ */ 381 /* $Date: 2006/11/08 21:57:04 $ */