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