]> andersk Git - openssh.git/blame - cipher.h
- OpenBSD CVS updates:
[openssh.git] / cipher.h
CommitLineData
8efc0c15 1/*
5260325f 2 *
3 * cipher.h
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
10 * Created: Wed Apr 19 16:50:42 1995 ylo
11 *
12 */
8efc0c15 13
14/* RCSID("$Id$"); */
15
16#ifndef CIPHER_H
17#define CIPHER_H
18
4d195447 19#include "config.h"
20
5881cd60 21#ifdef HAVE_OPENSSL
8efc0c15 22#include <openssl/des.h>
23#include <openssl/blowfish.h>
7368a6c8 24#include <openssl/rc4.h>
25#include <openssl/cast.h>
5881cd60 26#endif
27#ifdef HAVE_SSL
28#include <ssl/des.h>
29#include <ssl/blowfish.h>
7368a6c8 30#include <ssl/rc4.h>
31#include <ssl/cast.h>
5881cd60 32#endif
8efc0c15 33
34/* Cipher types. New types can be added, but old types should not be removed
35 for compatibility. The maximum allowed value is 31. */
5260325f 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 */
8efc0c15 43#define SSH_CIPHER_BLOWFISH 6
7368a6c8 44#define SSH_CIPHER_RESERVED 7
45
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
8efc0c15 51
52typedef struct {
5260325f 53 unsigned int type;
54 union {
55 struct {
56 des_key_schedule key1;
57 des_key_schedule key2;
58 des_cblock iv2;
59 des_key_schedule key3;
60 des_cblock iv3;
61 } des3;
62 struct {
63 struct bf_key_st key;
64 unsigned char iv[8];
65 } bf;
7368a6c8 66 struct {
67 CAST_KEY key;
68 unsigned char iv[8];
69 } cast;
70 RC4_KEY rc4;
5260325f 71 } u;
72} CipherContext;
aa3378df 73/*
74 * Returns a bit mask indicating which ciphers are supported by this
75 * implementation. The bit mask has the corresponding bit set of each
76 * supported cipher.
77 */
8efc0c15 78unsigned int cipher_mask();
8ce64345 79unsigned int cipher_mask1();
80unsigned int cipher_mask2();
8efc0c15 81
82/* Returns the name of the cipher. */
83const char *cipher_name(int cipher);
84
aa3378df 85/*
86 * Parses the name of the cipher. Returns the number of the corresponding
87 * cipher, or -1 on error.
88 */
5260325f 89int cipher_number(const char *name);
8efc0c15 90
a8be9f80 91/* returns 1 if all ciphers are supported (ssh2 only) */
92int ciphers_valid(const char *names);
93
aa3378df 94/*
95 * Selects the cipher to use and sets the key. If for_encryption is true,
96 * the key is setup for encryption; otherwise it is setup for decryption.
97 */
5260325f 98void
99cipher_set_key(CipherContext * context, int cipher,
8ce64345 100 const unsigned char *key, int keylen);
7368a6c8 101void
102cipher_set_key_iv(CipherContext * context, int cipher,
103 const unsigned char *key, int keylen,
104 const unsigned char *iv, int ivlen);
8efc0c15 105
aa3378df 106/*
107 * Sets key for the cipher by computing the MD5 checksum of the passphrase,
108 * and using the resulting 16 bytes as the key.
109 */
5260325f 110void
111cipher_set_key_string(CipherContext * context, int cipher,
8ce64345 112 const char *passphrase);
8efc0c15 113
114/* Encrypts data using the cipher. */
5260325f 115void
116cipher_encrypt(CipherContext * context, unsigned char *dest,
117 const unsigned char *src, unsigned int len);
8efc0c15 118
119/* Decrypts data using the cipher. */
5260325f 120void
121cipher_decrypt(CipherContext * context, unsigned char *dest,
122 const unsigned char *src, unsigned int len);
8efc0c15 123
5260325f 124#endif /* CIPHER_H */
This page took 0.365392 seconds and 5 git commands to generate.