5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
10 * Created: Wed Apr 19 16:50:42 1995 ylo
22 #include <openssl/des.h>
23 #include <openssl/blowfish.h>
24 #include <openssl/rc4.h>
25 #include <openssl/cast.h>
29 #include <ssl/blowfish.h>
34 /* Cipher types. New types can be added, but old types should not be removed
35 for compatibility. The maximum allowed value is 31. */
36 #define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */
37 #define SSH_CIPHER_NONE 0 /* no encryption */
38 #define SSH_CIPHER_IDEA 1 /* IDEA CFB */
39 #define SSH_CIPHER_DES 2 /* DES CBC */
40 #define SSH_CIPHER_3DES 3 /* 3DES CBC */
41 #define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */
42 #define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */
43 #define SSH_CIPHER_BLOWFISH 6
44 #define SSH_CIPHER_RESERVED 7
46 /* these ciphers are used in SSH2: */
47 #define SSH_CIPHER_BLOWFISH_CBC 8
48 #define SSH_CIPHER_3DES_CBC 9
49 #define SSH_CIPHER_ARCFOUR 10 /* Alleged RC4 */
50 #define SSH_CIPHER_CAST128_CBC 11
56 des_key_schedule key1;
57 des_key_schedule key2;
59 des_key_schedule key3;
74 * Returns a bit mask indicating which ciphers are supported by this
75 * implementation. The bit mask has the corresponding bit set of each
78 unsigned int cipher_mask();
79 unsigned int cipher_mask1();
80 unsigned int cipher_mask2();
82 /* Returns the name of the cipher. */
83 const char *cipher_name(int cipher);
86 * Parses the name of the cipher. Returns the number of the corresponding
87 * cipher, or -1 on error.
89 int cipher_number(const char *name);
92 * Selects the cipher to use and sets the key. If for_encryption is true,
93 * the key is setup for encryption; otherwise it is setup for decryption.
96 cipher_set_key(CipherContext * context, int cipher,
97 const unsigned char *key, int keylen);
99 cipher_set_key_iv(CipherContext * context, int cipher,
100 const unsigned char *key, int keylen,
101 const unsigned char *iv, int ivlen);
104 * Sets key for the cipher by computing the MD5 checksum of the passphrase,
105 * and using the resulting 16 bytes as the key.
108 cipher_set_key_string(CipherContext * context, int cipher,
109 const char *passphrase);
111 /* Encrypts data using the cipher. */
113 cipher_encrypt(CipherContext * context, unsigned char *dest,
114 const unsigned char *src, unsigned int len);
116 /* Decrypts data using the cipher. */
118 cipher_decrypt(CipherContext * context, unsigned char *dest,
119 const unsigned char *src, unsigned int len);
121 #endif /* CIPHER_H */