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