[BACK]Return to cipher.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/cipher.h, Revision 1.3

1.1       deraadt     1: /*
                      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: */
                     13:
1.3     ! deraadt    14: /* RCSID("$Id: cipher.h,v 1.2 1999/09/26 21:02:15 deraadt Exp $"); */
1.1       deraadt    15:
                     16: #ifndef CIPHER_H
                     17: #define CIPHER_H
                     18:
                     19: #include "des.h"
                     20: #ifdef WITH_RC4
                     21: #include "rc4.h"
                     22: #endif
                     23: #include "blowfish.h"
                     24:
                     25: /* Cipher types.  New types can be added, but old types should not be removed
                     26:    for compatibility.  The maximum allowed value is 31. */
                     27: #define SSH_CIPHER_NOT_SET     -1 /* None selected (invalid number). */
                     28: #define SSH_CIPHER_NONE                0 /* no encryption */
1.2       deraadt    29: #define SSH_CIPHER_IDEA                1 /* IDEA CFB -- not implemented */
1.1       deraadt    30: #define SSH_CIPHER_DES         2 /* DES CBC */
                     31: #define SSH_CIPHER_3DES                3 /* 3DES CBC */
                     32: #define SSH_CIPHER_TSS         4 /* TRI's Simple Stream encryption CBC */
                     33: #define SSH_CIPHER_RC4         5 /* Alleged RC4 */
                     34: #define SSH_CIPHER_BLOWFISH    6
                     35:
                     36: typedef struct {
                     37:   unsigned int type;
                     38:   union {
                     39: #ifdef WITH_DES
                     40:     struct {
                     41:       des_key_schedule key;
                     42:       des_cblock iv;
                     43:     } des;
                     44: #endif /* WITH_DES */
                     45:     struct {
                     46:       des_key_schedule key1;
                     47:       des_key_schedule key2;
                     48:       des_cblock iv2;
                     49:       des_key_schedule key3;
                     50:       des_cblock iv3;
                     51:     } des3;
                     52: #ifdef WITH_RC4
                     53:     RC4Context rc4;
                     54: #endif
                     55:     struct {
                     56:       struct bf_key_st key;
                     57:       unsigned char iv[8];
                     58:     } bf;
                     59:   } u;
                     60: } CipherContext;
                     61:
                     62: /* Returns a bit mask indicating which ciphers are supported by this
                     63:    implementation.  The bit mask has the corresponding bit set of each
                     64:    supported cipher. */
                     65: unsigned int cipher_mask();
                     66:
                     67: /* Returns the name of the cipher. */
                     68: const char *cipher_name(int cipher);
                     69:
                     70: /* Parses the name of the cipher.  Returns the number of the corresponding
                     71:    cipher, or -1 on error. */
                     72: int cipher_number(const char *name);
                     73:
                     74: /* Selects the cipher to use and sets the key.  If for_encryption is true,
                     75:    the key is setup for encryption; otherwise it is setup for decryption. */
                     76: void cipher_set_key(CipherContext *context, int cipher,
                     77:                    const unsigned char *key, int keylen, int for_encryption);
                     78:
                     79: /* Sets key for the cipher by computing the MD5 checksum of the passphrase,
                     80:    and using the resulting 16 bytes as the key. */
                     81: void cipher_set_key_string(CipherContext *context, int cipher,
                     82:                           const char *passphrase, int for_encryption);
                     83:
                     84: /* Encrypts data using the cipher. */
                     85: void cipher_encrypt(CipherContext *context, unsigned char *dest,
                     86:                    const unsigned char *src, unsigned int len);
                     87:
                     88: /* Decrypts data using the cipher. */
                     89: void cipher_decrypt(CipherContext *context, unsigned char *dest,
                     90:                    const unsigned char *src, unsigned int len);
                     91:
                     92: /* If and CRC-32 attack is detected this function is called. Defaults
                     93:  * to fatal, changed to packet_disconnect in sshd and ssh. */
                     94: extern void (*cipher_attack_detected)(const char *fmt, ...);
                     95:
                     96: #endif /* CIPHER_H */