1*ba1276acSMatthew Dillon /* $OpenBSD: cipher.h,v 1.56 2023/10/10 06:49:54 tb Exp $ */ 218de8d7fSPeter Avalos 318de8d7fSPeter Avalos /* 418de8d7fSPeter Avalos * Author: Tatu Ylonen <ylo@cs.hut.fi> 518de8d7fSPeter Avalos * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 618de8d7fSPeter Avalos * All rights reserved 718de8d7fSPeter Avalos * 818de8d7fSPeter Avalos * As far as I am concerned, the code I have written for this software 918de8d7fSPeter Avalos * can be used freely for any purpose. Any derived versions of this 1018de8d7fSPeter Avalos * software must be clearly marked as such, and if the derived work is 1118de8d7fSPeter Avalos * incompatible with the protocol description in the RFC file, it must be 1218de8d7fSPeter Avalos * called by a name other than "ssh" or "Secure Shell". 1318de8d7fSPeter Avalos * 1418de8d7fSPeter Avalos * Copyright (c) 2000 Markus Friedl. All rights reserved. 1518de8d7fSPeter Avalos * 1618de8d7fSPeter Avalos * Redistribution and use in source and binary forms, with or without 1718de8d7fSPeter Avalos * modification, are permitted provided that the following conditions 1818de8d7fSPeter Avalos * are met: 1918de8d7fSPeter Avalos * 1. Redistributions of source code must retain the above copyright 2018de8d7fSPeter Avalos * notice, this list of conditions and the following disclaimer. 2118de8d7fSPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 2218de8d7fSPeter Avalos * notice, this list of conditions and the following disclaimer in the 2318de8d7fSPeter Avalos * documentation and/or other materials provided with the distribution. 2418de8d7fSPeter Avalos * 2518de8d7fSPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2618de8d7fSPeter Avalos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2718de8d7fSPeter Avalos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2818de8d7fSPeter Avalos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2918de8d7fSPeter Avalos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 3018de8d7fSPeter Avalos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3118de8d7fSPeter Avalos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3218de8d7fSPeter Avalos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3318de8d7fSPeter Avalos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3418de8d7fSPeter Avalos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3518de8d7fSPeter Avalos */ 3618de8d7fSPeter Avalos 3718de8d7fSPeter Avalos #ifndef CIPHER_H 3818de8d7fSPeter Avalos #define CIPHER_H 3918de8d7fSPeter Avalos 4036e94dc5SPeter Avalos #include <sys/types.h> 410cbfa66cSDaniel Fojt #ifdef WITH_OPENSSL 4218de8d7fSPeter Avalos #include <openssl/evp.h> 430cbfa66cSDaniel Fojt #endif 4436e94dc5SPeter Avalos #include "cipher-chachapoly.h" 4536e94dc5SPeter Avalos #include "cipher-aesctr.h" 4636e94dc5SPeter Avalos 4718de8d7fSPeter Avalos #define CIPHER_ENCRYPT 1 4818de8d7fSPeter Avalos #define CIPHER_DECRYPT 0 4918de8d7fSPeter Avalos 5036e94dc5SPeter Avalos struct sshcipher; 51ce74bacaSMatthew Dillon struct sshcipher_ctx; 5218de8d7fSPeter Avalos 5336e94dc5SPeter Avalos const struct sshcipher *cipher_by_name(const char *); 54e9778795SPeter Avalos const char *cipher_warning_message(const struct sshcipher_ctx *); 5518de8d7fSPeter Avalos int ciphers_valid(const char *); 5636e94dc5SPeter Avalos char *cipher_alg_list(char, int); 570cbfa66cSDaniel Fojt const char *compression_alg_list(int); 58ce74bacaSMatthew Dillon int cipher_init(struct sshcipher_ctx **, const struct sshcipher *, 5936e94dc5SPeter Avalos const u_char *, u_int, const u_char *, u_int, int); 6036e94dc5SPeter Avalos int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *, 6136e94dc5SPeter Avalos u_int, u_int, u_int); 6236e94dc5SPeter Avalos int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int, 6336e94dc5SPeter Avalos const u_char *, u_int); 64ce74bacaSMatthew Dillon void cipher_free(struct sshcipher_ctx *); 6536e94dc5SPeter Avalos u_int cipher_blocksize(const struct sshcipher *); 6636e94dc5SPeter Avalos u_int cipher_keylen(const struct sshcipher *); 6736e94dc5SPeter Avalos u_int cipher_seclen(const struct sshcipher *); 6836e94dc5SPeter Avalos u_int cipher_authlen(const struct sshcipher *); 6936e94dc5SPeter Avalos u_int cipher_ivlen(const struct sshcipher *); 7036e94dc5SPeter Avalos u_int cipher_is_cbc(const struct sshcipher *); 7118de8d7fSPeter Avalos 72ce74bacaSMatthew Dillon u_int cipher_ctx_is_plaintext(struct sshcipher_ctx *); 73ce74bacaSMatthew Dillon 74664f4763Szrj int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, size_t); 75664f4763Szrj int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *, size_t); 76ce74bacaSMatthew Dillon 7718de8d7fSPeter Avalos #endif /* CIPHER_H */ 78