1323134Sdes/* $OpenBSD: cipher.h,v 1.49 2016/08/03 05:41:57 djm Exp $ */ 292559Sdes 357429Smarkm/* 457429Smarkm * Author: Tatu Ylonen <ylo@cs.hut.fi> 557429Smarkm * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 657429Smarkm * All rights reserved 760576Skris * 865674Skris * As far as I am concerned, the code I have written for this software 965674Skris * can be used freely for any purpose. Any derived versions of this 1065674Skris * software must be clearly marked as such, and if the derived work is 1165674Skris * incompatible with the protocol description in the RFC file, it must be 1265674Skris * called by a name other than "ssh" or "Secure Shell". 1369591Sgreen * 1469591Sgreen * Copyright (c) 2000 Markus Friedl. All rights reserved. 1569591Sgreen * 1669591Sgreen * Redistribution and use in source and binary forms, with or without 1769591Sgreen * modification, are permitted provided that the following conditions 1869591Sgreen * are met: 1969591Sgreen * 1. Redistributions of source code must retain the above copyright 2069591Sgreen * notice, this list of conditions and the following disclaimer. 2169591Sgreen * 2. Redistributions in binary form must reproduce the above copyright 2269591Sgreen * notice, this list of conditions and the following disclaimer in the 2369591Sgreen * documentation and/or other materials provided with the distribution. 2469591Sgreen * 2569591Sgreen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2669591Sgreen * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2769591Sgreen * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2869591Sgreen * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2969591Sgreen * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 3069591Sgreen * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3169591Sgreen * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3269591Sgreen * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3369591Sgreen * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3469591Sgreen * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3557429Smarkm */ 3657429Smarkm 3757429Smarkm#ifndef CIPHER_H 3857429Smarkm#define CIPHER_H 3957429Smarkm 40294328Sdes#include <sys/types.h> 4192559Sdes#include <openssl/evp.h> 42261320Sdes#include "cipher-chachapoly.h" 43294328Sdes#include "cipher-aesctr.h" 44261320Sdes 4569591Sgreen/* 4669591Sgreen * Cipher types for SSH-1. New types can be added, but old types should not 4769591Sgreen * be removed for compatibility. The maximum allowed value is 31. 4869591Sgreen */ 4969591Sgreen#define SSH_CIPHER_SSH2 -3 50137019Sdes#define SSH_CIPHER_INVALID -2 /* No valid cipher selected. */ 5157429Smarkm#define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */ 5257429Smarkm#define SSH_CIPHER_NONE 0 /* no encryption */ 5357429Smarkm#define SSH_CIPHER_IDEA 1 /* IDEA CFB */ 5457429Smarkm#define SSH_CIPHER_DES 2 /* DES CBC */ 5557429Smarkm#define SSH_CIPHER_3DES 3 /* 3DES CBC */ 5657429Smarkm#define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */ 5757429Smarkm#define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */ 5857429Smarkm#define SSH_CIPHER_BLOWFISH 6 5960576Skris#define SSH_CIPHER_RESERVED 7 6069591Sgreen#define SSH_CIPHER_MAX 31 6157429Smarkm 6292559Sdes#define CIPHER_ENCRYPT 1 6392559Sdes#define CIPHER_DECRYPT 0 6492559Sdes 65294328Sdesstruct sshcipher; 66323134Sdesstruct sshcipher_ctx; 6757429Smarkm 6892559Sdesu_int cipher_mask_ssh1(int); 69294328Sdesconst struct sshcipher *cipher_by_name(const char *); 70294328Sdesconst struct sshcipher *cipher_by_number(int); 7192559Sdesint cipher_number(const char *); 7292559Sdeschar *cipher_name(int); 73294332Sdesconst char *cipher_warning_message(const struct sshcipher_ctx *); 7492559Sdesint ciphers_valid(const char *); 75261320Sdeschar *cipher_alg_list(char, int); 76323134Sdesint cipher_init(struct sshcipher_ctx **, const struct sshcipher *, 77294328Sdes const u_char *, u_int, const u_char *, u_int, int); 78294328Sdesint cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *, 79248619Sdes u_int, u_int, u_int); 80294328Sdesint cipher_get_length(struct sshcipher_ctx *, u_int *, u_int, 81261320Sdes const u_char *, u_int); 82323134Sdesvoid cipher_free(struct sshcipher_ctx *); 83323134Sdesint cipher_set_key_string(struct sshcipher_ctx **, 84323134Sdes const struct sshcipher *, const char *, int); 85294328Sdesu_int cipher_blocksize(const struct sshcipher *); 86294328Sdesu_int cipher_keylen(const struct sshcipher *); 87294328Sdesu_int cipher_seclen(const struct sshcipher *); 88294328Sdesu_int cipher_authlen(const struct sshcipher *); 89294328Sdesu_int cipher_ivlen(const struct sshcipher *); 90294328Sdesu_int cipher_is_cbc(const struct sshcipher *); 9198684Sdes 92323134Sdesu_int cipher_ctx_is_plaintext(struct sshcipher_ctx *); 93323134Sdesu_int cipher_ctx_get_number(struct sshcipher_ctx *); 94323134Sdes 95294328Sdesu_int cipher_get_number(const struct sshcipher *); 96294328Sdesint cipher_get_keyiv(struct sshcipher_ctx *, u_char *, u_int); 97294328Sdesint cipher_set_keyiv(struct sshcipher_ctx *, const u_char *); 98294328Sdesint cipher_get_keyiv_len(const struct sshcipher_ctx *); 99294328Sdesint cipher_get_keycontext(const struct sshcipher_ctx *, u_char *); 100294328Sdesvoid cipher_set_keycontext(struct sshcipher_ctx *, const u_char *); 101323134Sdes 10257429Smarkm#endif /* CIPHER_H */ 103