cipher.h revision 1.16
1/* $NetBSD: cipher.h,v 1.16 2023/07/28 04:25:22 rin Exp $ */ 2/* $OpenBSD: cipher.h,v 1.55 2020/01/23 10:24:29 dtucker Exp $ */ 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 <sys/types.h> 42#ifdef WITH_OPENSSL 43#include <openssl/evp.h> 44#endif 45#include "cipher-chachapoly.h" 46#include "cipher-aesctr.h" 47 48#define CIPHER_ENCRYPT 1 49#define CIPHER_DECRYPT 0 50 51struct sshcipher; 52struct sshcipher_ctx; 53 54const struct sshcipher *cipher_by_name(const char *); 55const char *cipher_warning_message(const struct sshcipher_ctx *); 56int ciphers_valid(const char *); 57char *cipher_alg_list(char, int); 58const char *compression_alg_list(int); 59int cipher_init(struct sshcipher_ctx **, const struct sshcipher *, 60 const u_char *, u_int, const u_char *, u_int, int); 61int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *, 62 u_int, u_int, u_int); 63int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int, 64 const u_char *, u_int); 65void cipher_free(struct sshcipher_ctx *); 66u_int cipher_blocksize(const struct sshcipher *); 67u_int cipher_keylen(const struct sshcipher *); 68u_int cipher_seclen(const struct sshcipher *); 69u_int cipher_authlen(const struct sshcipher *); 70u_int cipher_ivlen(const struct sshcipher *); 71u_int cipher_is_cbc(const struct sshcipher *); 72 73u_int cipher_ctx_is_plaintext(struct sshcipher_ctx *); 74 75int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, size_t); 76int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *, size_t); 77int cipher_get_keyiv_len(const struct sshcipher_ctx *); 78 79#endif /* CIPHER_H */ 80