comparison algo.h @ 502:43bbe17d6ba0

- Add Counter Mode support
author Matt Johnston <matt@ucc.asn.au>
date Mon, 29 Sep 2008 13:53:31 +0000
parents e972be139cb5
children f9b5dc0cba61
comparison
equal deleted inserted replaced
501:d58c478bd399 502:43bbe17d6ba0
27 #define _ALGO_H_ 27 #define _ALGO_H_
28 28
29 #include "includes.h" 29 #include "includes.h"
30 #include "buffer.h" 30 #include "buffer.h"
31 31
32 #define DROPBEAR_MODE_UNUSED 0
33 #define DROPBEAR_MODE_CBC 1
34 #define DROPBEAR_MODE_CTR 2
35
32 struct Algo_Type { 36 struct Algo_Type {
33 37
34 unsigned char *name; /* identifying name */ 38 unsigned char *name; /* identifying name */
35 char val; /* a value for this cipher, or -1 for invalid */ 39 char val; /* a value for this cipher, or -1 for invalid */
36 void *data; /* algorithm specific data */ 40 const void *data; /* algorithm specific data */
37 unsigned usable : 1; /* whether we can use this algorithm */ 41 char usable; /* whether we can use this algorithm */
38 42 const void *mode; /* the mode, currently only used for ciphers,
43 points to a 'struct dropbear_cipher_mode' */
39 }; 44 };
40 45
41 typedef struct Algo_Type algo_type; 46 typedef struct Algo_Type algo_type;
42 47
43 /* lists mapping ssh types of algorithms to internal values */ 48 /* lists mapping ssh types of algorithms to internal values */
46 extern algo_type sshciphers[]; 51 extern algo_type sshciphers[];
47 extern algo_type sshhashes[]; 52 extern algo_type sshhashes[];
48 extern algo_type sshcompress[]; 53 extern algo_type sshcompress[];
49 54
50 extern const struct dropbear_cipher dropbear_nocipher; 55 extern const struct dropbear_cipher dropbear_nocipher;
56 extern const struct dropbear_cipher_mode dropbear_mode_none;
51 extern const struct dropbear_hash dropbear_nohash; 57 extern const struct dropbear_hash dropbear_nohash;
52 58
53 struct dropbear_cipher { 59 struct dropbear_cipher {
54 const struct ltc_cipher_descriptor *cipherdesc; 60 const struct ltc_cipher_descriptor *cipherdesc;
55 unsigned long keysize; 61 unsigned long keysize;
56 unsigned char blocksize; 62 unsigned char blocksize;
63 };
64
65 struct dropbear_cipher_mode {
66 int (*start)(int cipher, const unsigned char *IV,
67 const unsigned char *key,
68 int keylen, int num_rounds, void *cipher_state);
69 int (*encrypt)(const unsigned char *pt, unsigned char *ct,
70 unsigned long len, void *cipher_state);
71 int (*decrypt)(const unsigned char *ct, unsigned char *pt,
72 unsigned long len, void *cipher_state);
57 }; 73 };
58 74
59 struct dropbear_hash { 75 struct dropbear_hash {
60 const struct ltc_hash_descriptor *hashdesc; 76 const struct ltc_hash_descriptor *hashdesc;
61 unsigned long keysize; 77 unsigned long keysize;