7 #include "chiark-tcl.h"
11 void memxor(Byte *dest, const Byte *src, int l);
18 extern Tcl_ObjType cht_blockcipherkey_type;
20 /* from algtables.c */
25 } BlockCipherPropInfo, HashAlgPropInfo;
29 int hashsize, blocksize, statesize;
30 void (*init)(void *state);
31 void (*update)(void *state, const void *data, int len);
32 void (*final)(void *state, void *digest);
33 void (*oneshot)(void *digest, const void *data, int len);
36 extern const HashAlgInfo cht_hashalginfo_entries[];
39 void (*make_schedule)(void *schedule, const void *key, int keylen);
40 void (*crypt)(const void *schedule, const void *in, void *out);
41 /* in and out may be the same, but if they aren't they may not overlap */
42 /* in and out for crypt will have been through block_byteswap */
43 } BlockCipherPerDirectionInfo;
47 int blocksize, schedule_size, key_min, key_max;
48 BlockCipherPerDirectionInfo encrypt, decrypt;
51 extern const BlockCipherAlgInfo cht_blockcipheralginfo_entries[];
57 int iv_blocks, buf_blocks, mac_blocks;
59 /* Each function is allowed to use up to buf_blocks * blocksize
60 * bytes of space in buf. data is blocks * blocksize bytes
61 * long. data should be modified in place by encrypt and decrypt;
62 * modes may not change the size of data. iv is always provided and
63 * is always of length iv_blocks * blocksize; encrypt and
64 * decrypt may modify the iv value (in which case the Tcl caller
65 * will get the modified IV) but this is not recommended. mac
66 * should leave the mac, which must be mac_blocks * blocksize
67 * bytes, in buf. (Therefore mac_blocks must be at least
70 const char *(*encrypt)(Byte *data, int nblocks,
71 const Byte *iv, Byte *buf,
72 const BlockCipherAlgInfo *alg, int encr,
74 const char *(*decrypt)(Byte *data, int nblocks,
75 const Byte *iv, Byte *buf,
76 const BlockCipherAlgInfo *alg, int encr,
78 const char *(*mac)(const Byte *data, int nblocks,
79 const Byte *iv, Byte *buf,
80 const BlockCipherAlgInfo *alg,
82 } BlockCipherModeInfo;
84 extern const BlockCipherModeInfo cht_blockciphermodeinfo_entries[];
86 #include "crypto+tcmdif.h"