1*069ac184SEd Maste /* $OpenBSD: cipher.h,v 1.56 2023/10/10 06:49:54 tb Exp $ */ 2af12a3e7SDag-Erling Smørgrav 3511b41d2SMark Murray /* 4511b41d2SMark Murray * Author: Tatu Ylonen <ylo@cs.hut.fi> 5511b41d2SMark Murray * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 6511b41d2SMark Murray * All rights reserved 7511b41d2SMark Murray * 8c2d3a559SKris Kennaway * As far as I am concerned, the code I have written for this software 9c2d3a559SKris Kennaway * can be used freely for any purpose. Any derived versions of this 10c2d3a559SKris Kennaway * software must be clearly marked as such, and if the derived work is 11c2d3a559SKris Kennaway * incompatible with the protocol description in the RFC file, it must be 12c2d3a559SKris Kennaway * called by a name other than "ssh" or "Secure Shell". 1309958426SBrian Feldman * 1409958426SBrian Feldman * Copyright (c) 2000 Markus Friedl. All rights reserved. 1509958426SBrian Feldman * 1609958426SBrian Feldman * Redistribution and use in source and binary forms, with or without 1709958426SBrian Feldman * modification, are permitted provided that the following conditions 1809958426SBrian Feldman * are met: 1909958426SBrian Feldman * 1. Redistributions of source code must retain the above copyright 2009958426SBrian Feldman * notice, this list of conditions and the following disclaimer. 2109958426SBrian Feldman * 2. Redistributions in binary form must reproduce the above copyright 2209958426SBrian Feldman * notice, this list of conditions and the following disclaimer in the 2309958426SBrian Feldman * documentation and/or other materials provided with the distribution. 2409958426SBrian Feldman * 2509958426SBrian Feldman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2609958426SBrian Feldman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2709958426SBrian Feldman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2809958426SBrian Feldman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2909958426SBrian Feldman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 3009958426SBrian Feldman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3109958426SBrian Feldman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3209958426SBrian Feldman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3309958426SBrian Feldman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3409958426SBrian Feldman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35511b41d2SMark Murray */ 36511b41d2SMark Murray 37511b41d2SMark Murray #ifndef CIPHER_H 38511b41d2SMark Murray #define CIPHER_H 39511b41d2SMark Murray 40a0ee8cc6SDag-Erling Smørgrav #include <sys/types.h> 4119261079SEd Maste #ifdef WITH_OPENSSL 42af12a3e7SDag-Erling Smørgrav #include <openssl/evp.h> 4319261079SEd Maste #endif 44f7167e0eSDag-Erling Smørgrav #include "cipher-chachapoly.h" 45a0ee8cc6SDag-Erling Smørgrav #include "cipher-aesctr.h" 46f7167e0eSDag-Erling Smørgrav 47af12a3e7SDag-Erling Smørgrav #define CIPHER_ENCRYPT 1 48af12a3e7SDag-Erling Smørgrav #define CIPHER_DECRYPT 0 49af12a3e7SDag-Erling Smørgrav 50a0ee8cc6SDag-Erling Smørgrav struct sshcipher; 51ca86bcf2SDag-Erling Smørgrav struct sshcipher_ctx; 52511b41d2SMark Murray 53a0ee8cc6SDag-Erling Smørgrav const struct sshcipher *cipher_by_name(const char *); 54bc5531deSDag-Erling Smørgrav const char *cipher_warning_message(const struct sshcipher_ctx *); 55af12a3e7SDag-Erling Smørgrav int ciphers_valid(const char *); 56f7167e0eSDag-Erling Smørgrav char *cipher_alg_list(char, int); 5719261079SEd Maste const char *compression_alg_list(int); 58ca86bcf2SDag-Erling Smørgrav int cipher_init(struct sshcipher_ctx **, const struct sshcipher *, 59a0ee8cc6SDag-Erling Smørgrav const u_char *, u_int, const u_char *, u_int, int); 60a0ee8cc6SDag-Erling Smørgrav int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *, 616888a9beSDag-Erling Smørgrav u_int, u_int, u_int); 62a0ee8cc6SDag-Erling Smørgrav int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int, 63f7167e0eSDag-Erling Smørgrav const u_char *, u_int); 64ca86bcf2SDag-Erling Smørgrav void cipher_free(struct sshcipher_ctx *); 65a0ee8cc6SDag-Erling Smørgrav u_int cipher_blocksize(const struct sshcipher *); 66a0ee8cc6SDag-Erling Smørgrav u_int cipher_keylen(const struct sshcipher *); 67a0ee8cc6SDag-Erling Smørgrav u_int cipher_seclen(const struct sshcipher *); 68a0ee8cc6SDag-Erling Smørgrav u_int cipher_authlen(const struct sshcipher *); 69a0ee8cc6SDag-Erling Smørgrav u_int cipher_ivlen(const struct sshcipher *); 70a0ee8cc6SDag-Erling Smørgrav u_int cipher_is_cbc(const struct sshcipher *); 7180628bacSDag-Erling Smørgrav 72ca86bcf2SDag-Erling Smørgrav u_int cipher_ctx_is_plaintext(struct sshcipher_ctx *); 73ca86bcf2SDag-Erling Smørgrav 742a01feabSEd Maste int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, size_t); 752a01feabSEd Maste int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *, size_t); 76ca86bcf2SDag-Erling Smørgrav 77511b41d2SMark Murray #endif /* CIPHER_H */ 78