cipher.h revision 98684
1/* $OpenBSD: cipher.h,v 1.33 2002/03/18 17:13:15 markus Exp $ */ 2/* $FreeBSD: head/crypto/openssh/cipher.h 98684 2002-06-23 16:09:08Z des $ */ 3 4/* 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * All rights reserved 8 * 9 * As far as I am concerned, the code I have written for this software 10 * can be used freely for any purpose. Any derived versions of this 11 * software must be clearly marked as such, and if the derived work is 12 * incompatible with the protocol description in the RFC file, it must be 13 * called by a name other than "ssh" or "Secure Shell". 14 * 15 * Copyright (c) 2000 Markus Friedl. All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions 19 * are met: 20 * 1. Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#ifndef CIPHER_H 39#define CIPHER_H 40 41#include <openssl/evp.h> 42/* 43 * Cipher types for SSH-1. New types can be added, but old types should not 44 * be removed for compatibility. The maximum allowed value is 31. 45 */ 46#define SSH_CIPHER_SSH2 -3 47#define SSH_CIPHER_ILLEGAL -2 /* No valid cipher selected. */ 48#define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */ 49#define SSH_CIPHER_NONE 0 /* no encryption */ 50#define SSH_CIPHER_IDEA 1 /* IDEA CFB */ 51#define SSH_CIPHER_DES 2 /* DES CBC */ 52#define SSH_CIPHER_3DES 3 /* 3DES CBC */ 53#define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */ 54#define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */ 55#define SSH_CIPHER_BLOWFISH 6 56#define SSH_CIPHER_RESERVED 7 57#define SSH_CIPHER_MAX 31 58 59#define CIPHER_ENCRYPT 1 60#define CIPHER_DECRYPT 0 61 62typedef struct Cipher Cipher; 63typedef struct CipherContext CipherContext; 64 65struct Cipher; 66struct CipherContext { 67 int plaintext; 68 EVP_CIPHER_CTX evp; 69 Cipher *cipher; 70}; 71 72u_int cipher_mask_ssh1(int); 73Cipher *cipher_by_name(const char *); 74Cipher *cipher_by_number(int); 75int cipher_number(const char *); 76char *cipher_name(int); 77int ciphers_valid(const char *); 78void cipher_init(CipherContext *, Cipher *, const u_char *, u_int, 79 const u_char *, u_int, int); 80void cipher_crypt(CipherContext *, u_char *, const u_char *, u_int); 81void cipher_cleanup(CipherContext *); 82void cipher_set_key_string(CipherContext *, Cipher *, const char *, int); 83u_int cipher_blocksize(Cipher *); 84u_int cipher_keylen(Cipher *); 85 86u_int cipher_get_number(Cipher *); 87void cipher_get_keyiv(CipherContext *, u_char *, u_int); 88void cipher_set_keyiv(CipherContext *, u_char *); 89int cipher_get_keyiv_len(CipherContext *); 90int cipher_get_keycontext(CipherContext *, u_char *); 91void cipher_set_keycontext(CipherContext *, u_char *); 92#endif /* CIPHER_H */ 93