blob: dc7ecf1139d440d7fd9a8f274e387f449748546c [file] [log] [blame]
djm@openbsd.orgacaf34f2017-05-07 23:12:57 +00001/* $OpenBSD: cipher.h,v 1.52 2017/05/07 23:12:57 djm 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>
Damien Miller21cf4e02002-02-19 15:26:42 +110041#include <openssl/evp.h>
Damien Miller0fde8ac2013-11-21 14:12:23 +110042#include "cipher-chachapoly.h"
Damien Miller1f0311c2014-05-15 14:24:09 +100043#include "cipher-aesctr.h"
Damien Miller0fde8ac2013-11-21 14:12:23 +110044
Damien Miller963f6b22002-02-19 15:21:23 +110045#define CIPHER_ENCRYPT 1
46#define CIPHER_DECRYPT 0
47
Damien Miller86687062014-07-02 15:28:02 +100048struct sshcipher;
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000049struct sshcipher_ctx;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100050
Damien Miller86687062014-07-02 15:28:02 +100051const struct sshcipher *cipher_by_name(const char *);
markus@openbsd.org60c2c4e2015-01-14 10:24:42 +000052const char *cipher_warning_message(const struct sshcipher_ctx *);
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000053int ciphers_valid(const char *);
Damien Miller0fde8ac2013-11-21 14:12:23 +110054char *cipher_alg_list(char, int);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000055int cipher_init(struct sshcipher_ctx **, const struct sshcipher *,
Damien Miller86687062014-07-02 15:28:02 +100056 const u_char *, u_int, const u_char *, u_int, int);
Damien Miller86687062014-07-02 15:28:02 +100057int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *,
Damien Miller1d75abf2013-01-09 16:12:19 +110058 u_int, u_int, u_int);
Damien Miller86687062014-07-02 15:28:02 +100059int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int,
Damien Miller0fde8ac2013-11-21 14:12:23 +110060 const u_char *, u_int);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000061void cipher_free(struct sshcipher_ctx *);
Damien Miller86687062014-07-02 15:28:02 +100062u_int cipher_blocksize(const struct sshcipher *);
63u_int cipher_keylen(const struct sshcipher *);
64u_int cipher_seclen(const struct sshcipher *);
65u_int cipher_authlen(const struct sshcipher *);
66u_int cipher_ivlen(const struct sshcipher *);
67u_int cipher_is_cbc(const struct sshcipher *);
Ben Lindstrom212faca2002-03-22 01:39:44 +000068
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000069u_int cipher_ctx_is_plaintext(struct sshcipher_ctx *);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000070
Damien Miller86687062014-07-02 15:28:02 +100071int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, u_int);
72int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *);
73int cipher_get_keyiv_len(const struct sshcipher_ctx *);
djm@openbsd.org4706c1d2016-08-03 05:41:57 +000074
Damien Miller95def091999-11-25 00:26:21 +110075#endif /* CIPHER_H */