blob: 1a591cd7fd46deccad4a776582a3bff7b68435df [file] [log] [blame]
dtucker@openbsd.org7f8e66f2020-01-23 10:24:29 +00001/* $OpenBSD: cipher.h,v 1.55 2020/01/23 10:24:29 dtucker Exp $ */
Ben Lindstrom05764b92002-03-05 01:53:02 +00002
Damien Millerd4a8b7e1999-10-27 13:42:43 +10003/*
Damien Miller95def091999-11-25 00:26:21 +11004 * Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller95def091999-11-25 00:26:21 +11005 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10007 *
Damien Millere4340be2000-09-16 13:29:08 +11008 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this
10 * software must be clearly marked as such, and if the derived work is
11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell".
Damien Miller874d77b2000-10-14 16:23:11 +110013 *
14 * Copyright (c) 2000 Markus Friedl. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Damien Miller95def091999-11-25 00:26:21 +110035 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100036
Damien Millerd4a8b7e1999-10-27 13:42:43 +100037#ifndef CIPHER_H
38#define CIPHER_H
39
Damien Miller86687062014-07-02 15:28:02 +100040#include <sys/types.h>
djm@openbsd.org670104b2019-09-06 05:23:55 +000041#ifdef WITH_OPENSSL
Damien Miller21cf4e02002-02-19 15:26:42 +110042#include <openssl/evp.h>
djm@openbsd.org670104b2019-09-06 05:23:55 +000043#endif
Damien Miller0fde8ac2013-11-21 14:12:23 +110044#include "cipher-chachapoly.h"
Damien Miller1f0311c2014-05-15 14:24:09 +100045#include "cipher-aesctr.h"
Damien Miller0fde8ac2013-11-21 14:12:23 +110046
Damien Miller963f6b22002-02-19 15:21:23 +110047#define CIPHER_ENCRYPT 1
48#define CIPHER_DECRYPT 0
49
Damien Miller86687062014-07-02 15:28:02 +100050struct sshcipher;
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000051struct sshcipher_ctx;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100052
Damien Miller86687062014-07-02 15:28:02 +100053const struct sshcipher *cipher_by_name(const char *);
markus@openbsd.org60c2c4e2015-01-14 10:24:42 +000054const char *cipher_warning_message(const struct sshcipher_ctx *);
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000055int ciphers_valid(const char *);
Damien Miller0fde8ac2013-11-21 14:12:23 +110056char *cipher_alg_list(char, int);
dtucker@openbsd.org7f8e66f2020-01-23 10:24:29 +000057const char *compression_alg_list(int);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000058int cipher_init(struct sshcipher_ctx **, const struct sshcipher *,
Damien Miller86687062014-07-02 15:28:02 +100059 const u_char *, u_int, const u_char *, u_int, int);
Damien Miller86687062014-07-02 15:28:02 +100060int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *,
Damien Miller1d75abf2013-01-09 16:12:19 +110061 u_int, u_int, u_int);
Damien Miller86687062014-07-02 15:28:02 +100062int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int,
Damien Miller0fde8ac2013-11-21 14:12:23 +110063 const u_char *, u_int);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000064void cipher_free(struct sshcipher_ctx *);
Damien Miller86687062014-07-02 15:28:02 +100065u_int cipher_blocksize(const struct sshcipher *);
66u_int cipher_keylen(const struct sshcipher *);
67u_int cipher_seclen(const struct sshcipher *);
68u_int cipher_authlen(const struct sshcipher *);
69u_int cipher_ivlen(const struct sshcipher *);
70u_int cipher_is_cbc(const struct sshcipher *);
Ben Lindstrom212faca2002-03-22 01:39:44 +000071
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000072u_int cipher_ctx_is_plaintext(struct sshcipher_ctx *);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000073
djm@openbsd.org482d23b2018-09-13 02:08:33 +000074int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, size_t);
75int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *, size_t);
Damien Miller86687062014-07-02 15:28:02 +100076int cipher_get_keyiv_len(const struct sshcipher_ctx *);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000077
Damien Miller95def091999-11-25 00:26:21 +110078#endif /* CIPHER_H */