7 #define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
10 #define SSH_CIPHER_IDEA 1
11 #define SSH_CIPHER_DES 2
12 #define SSH_CIPHER_3DES 3
13 #define SSH_CIPHER_BLOWFISH 6
22 * A Bignum is stored as a sequence of `unsigned short' words. The
23 * first tells how many remain; the remaining ones are digits, LS
26 typedef unsigned short *Bignum;
32 unsigned long exponent;
33 unsigned char *modulus;
37 Bignum private_exponent;
42 int makekey(unsigned char *data, struct RSAKey *result,
43 unsigned char **keystr, int order);
44 int makeprivate(unsigned char *data, struct RSAKey *result);
45 void rsaencrypt(unsigned char *data, int length, struct RSAKey *key);
46 Bignum rsadecrypt(Bignum input, struct RSAKey *key);
47 void rsasign(unsigned char *data, int length, struct RSAKey *key);
48 void rsasanitise(struct RSAKey *key);
49 int rsastr_len(struct RSAKey *key);
50 void rsastr_fmt(char *str, struct RSAKey *key);
51 void freersakey(struct RSAKey *key);
53 typedef unsigned int word32;
54 typedef unsigned int uint32;
56 unsigned long crc32(const void *s, size_t len);
67 unsigned char block[64];
73 void MD5Init(struct MD5Context *context);
74 void MD5Update(struct MD5Context *context, unsigned char const *buf,
76 void MD5Final(unsigned char digest[16], struct MD5Context *context);
80 unsigned char block[64];
85 void SHA_Init(SHA_State *s);
86 void SHA_Bytes(SHA_State *s, void *p, int len);
87 void SHA_Final(SHA_State *s, unsigned char *output);
88 void SHA_Simple(void *p, int len, unsigned char *output);
91 void (*sesskey)(unsigned char *key); /* for ssh 1 */
92 void (*setcsiv)(unsigned char *key); /* for ssh 2 */
93 void (*setcskey)(unsigned char *key); /* for ssh 2 */
94 void (*setsciv)(unsigned char *key); /* for ssh 2 */
95 void (*setsckey)(unsigned char *key); /* for ssh 2 */
96 void (*encrypt)(unsigned char *blk, int len);
97 void (*decrypt)(unsigned char *blk, int len);
103 void (*setcskey)(unsigned char *key);
104 void (*setsckey)(unsigned char *key);
105 void (*generate)(unsigned char *blk, int len, unsigned long seq);
106 int (*verify)(unsigned char *blk, int len, unsigned long seq);
113 * Plugging in another KEX algorithm requires structural chaos,
114 * so it's hard to abstract them into nice little structures
115 * like this. Hence, for the moment, this is just a
116 * placeholder. I claim justification in the fact that OpenSSH
123 void (*setkey)(char *data, int len);
124 char *(*fmtkey)(void);
125 int (*verifysig)(char *sig, int siglen, char *data, int datalen);
129 struct ssh_compress {
134 void SHATransform(word32 *digest, word32 *data);
137 int random_byte(void);
138 void random_add_noise(void *noise, int length);
140 void logevent (char *);
142 Bignum newbn(int length);
143 Bignum copybn(Bignum b);
144 void freebn(Bignum b);
145 void modpow(Bignum base, Bignum exp, Bignum mod, Bignum result);
146 void modmul(Bignum a, Bignum b, Bignum mod, Bignum result);
147 void decbn(Bignum n);
148 extern Bignum Zero, One;
149 int ssh1_read_bignum(unsigned char *data, Bignum *result);
150 int ssh1_bignum_bitcount(Bignum bn);
151 int ssh1_bignum_length(Bignum bn);
152 int bignum_byte(Bignum bn, int i);
153 int ssh1_write_bignum(void *data, Bignum bn);
155 Bignum dh_create_e(void);
156 Bignum dh_find_K(Bignum f);
158 int loadrsakey(char *filename, struct RSAKey *key, char *passphrase);
159 int rsakey_encrypted(char *filename, char **comment);
161 void des3_decrypt_pubkey(unsigned char *key,
162 unsigned char *blk, int len);