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

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