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