[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.12

1.1       deraadt     1: /*
1.9       deraadt     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:  */
1.1       deraadt    13:
1.12    ! markus     14: /* RCSID("$Id: cipher.h,v 1.12 2000/03/22 13:40:45 markus Exp $"); */
1.1       deraadt    15:
                     16: #ifndef CIPHER_H
                     17: #define CIPHER_H
                     18:
1.8       markus     19: #include <ssl/des.h>
1.7       deraadt    20: #include <ssl/blowfish.h>
1.12    ! markus     21: #include <ssl/rc4.h>
        !            22: #include <ssl/cast.h>
1.1       deraadt    23:
                     24: /* Cipher types.  New types can be added, but old types should not be removed
                     25:    for compatibility.  The maximum allowed value is 31. */
1.9       deraadt    26: #define SSH_CIPHER_NOT_SET     -1      /* None selected (invalid number). */
                     27: #define SSH_CIPHER_NONE                0       /* no encryption */
                     28: #define SSH_CIPHER_IDEA                1       /* IDEA CFB */
                     29: #define SSH_CIPHER_DES         2       /* DES CBC */
                     30: #define SSH_CIPHER_3DES                3       /* 3DES CBC */
                     31: #define SSH_CIPHER_BROKEN_TSS  4       /* TRI's Simple Stream encryption CBC */
                     32: #define SSH_CIPHER_BROKEN_RC4  5       /* Alleged RC4 */
1.1       deraadt    33: #define SSH_CIPHER_BLOWFISH    6
1.12    ! markus     34: #define SSH_CIPHER_RESERVED    7
        !            35:
        !            36: /* these ciphers are used in SSH2: */
        !            37: #define SSH_CIPHER_BLOWFISH_CBC        8
        !            38: #define SSH_CIPHER_3DES_CBC    9
        !            39: #define SSH_CIPHER_ARCFOUR     10      /* Alleged RC4 */
        !            40: #define SSH_CIPHER_CAST128_CBC 11
1.1       deraadt    41:
                     42: typedef struct {
1.9       deraadt    43:        unsigned int type;
                     44:        union {
                     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:                struct {
                     53:                        struct bf_key_st key;
                     54:                        unsigned char iv[8];
                     55:                }       bf;
1.12    ! markus     56:                struct {
        !            57:                        CAST_KEY key;
        !            58:                        unsigned char iv[8];
        !            59:                } cast;
        !            60:                RC4_KEY rc4;
1.9       deraadt    61:        }       u;
                     62: }       CipherContext;
1.10      markus     63: /*
                     64:  * Returns a bit mask indicating which ciphers are supported by this
                     65:  * implementation.  The bit mask has the corresponding bit set of each
                     66:  * supported cipher.
                     67:  */
1.1       deraadt    68: unsigned int cipher_mask();
                     69:
                     70: /* Returns the name of the cipher. */
                     71: const char *cipher_name(int cipher);
                     72:
1.10      markus     73: /*
                     74:  * Parses the name of the cipher.  Returns the number of the corresponding
                     75:  * cipher, or -1 on error.
                     76:  */
1.9       deraadt    77: int     cipher_number(const char *name);
1.1       deraadt    78:
1.10      markus     79: /*
                     80:  * Selects the cipher to use and sets the key.  If for_encryption is true,
                     81:  * the key is setup for encryption; otherwise it is setup for decryption.
                     82:  */
1.9       deraadt    83: void
                     84: cipher_set_key(CipherContext * context, int cipher,
                     85:     const unsigned char *key, int keylen, int for_encryption);
1.12    ! markus     86: void
        !            87: cipher_set_key_iv(CipherContext * context, int cipher,
        !            88:     const unsigned char *key, int keylen,
        !            89:     const unsigned char *iv, int ivlen);
1.1       deraadt    90:
1.10      markus     91: /*
                     92:  * Sets key for the cipher by computing the MD5 checksum of the passphrase,
                     93:  * and using the resulting 16 bytes as the key.
                     94:  */
1.9       deraadt    95: void
                     96: cipher_set_key_string(CipherContext * context, int cipher,
                     97:     const char *passphrase, int for_encryption);
1.1       deraadt    98:
                     99: /* Encrypts data using the cipher. */
1.9       deraadt   100: void
                    101: cipher_encrypt(CipherContext * context, unsigned char *dest,
                    102:     const unsigned char *src, unsigned int len);
1.1       deraadt   103:
                    104: /* Decrypts data using the cipher. */
1.9       deraadt   105: void
                    106: cipher_decrypt(CipherContext * context, unsigned char *dest,
                    107:     const unsigned char *src, unsigned int len);
1.1       deraadt   108:
1.9       deraadt   109: #endif                         /* CIPHER_H */