Annotation of src/usr.bin/ssh/cipher.h, Revision 1.45
1.45 ! markus 1: /* $OpenBSD: cipher.h,v 1.44 2014/01/25 10:12:50 dtucker Exp $ */
1.32 stevesk 2:
1.1 deraadt 3: /*
1.9 deraadt 4: * Author: Tatu Ylonen <ylo@cs.hut.fi>
5: * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6: * All rights reserved
1.16 markus 7: *
1.19 deraadt 8: * 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".
1.20 markus 13: *
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.
1.9 deraadt 35: */
1.1 deraadt 36:
37: #ifndef CIPHER_H
38: #define CIPHER_H
39:
1.31 markus 40: #include <openssl/evp.h>
1.42 djm 41: #include "cipher-chachapoly.h"
1.45 ! markus 42: #include "cipher-aesctr.h"
1.42 djm 43:
1.20 markus 44: /*
45: * Cipher types for SSH-1. New types can be added, but old types should not
46: * be removed for compatibility. The maximum allowed value is 31.
47: */
48: #define SSH_CIPHER_SSH2 -3
1.35 markus 49: #define SSH_CIPHER_INVALID -2 /* No valid cipher selected. */
1.9 deraadt 50: #define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */
51: #define SSH_CIPHER_NONE 0 /* no encryption */
52: #define SSH_CIPHER_IDEA 1 /* IDEA CFB */
53: #define SSH_CIPHER_DES 2 /* DES CBC */
54: #define SSH_CIPHER_3DES 3 /* 3DES CBC */
55: #define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */
56: #define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */
1.1 deraadt 57: #define SSH_CIPHER_BLOWFISH 6
1.12 markus 58: #define SSH_CIPHER_RESERVED 7
1.20 markus 59: #define SSH_CIPHER_MAX 31
1.12 markus 60:
1.30 markus 61: #define CIPHER_ENCRYPT 1
62: #define CIPHER_DECRYPT 0
63:
1.20 markus 64: typedef struct Cipher Cipher;
65: typedef struct CipherContext CipherContext;
1.1 deraadt 66:
1.30 markus 67: struct Cipher;
1.20 markus 68: struct CipherContext {
1.30 markus 69: int plaintext;
1.39 markus 70: int encrypt;
1.31 markus 71: EVP_CIPHER_CTX evp;
1.42 djm 72: struct chachapoly_ctx cp_ctx; /* XXX union with evp? */
1.45 ! markus 73: struct aesctr_ctx ac_ctx; /* XXX union with evp? */
1.40 djm 74: const Cipher *cipher;
1.20 markus 75: };
76:
1.28 markus 77: u_int cipher_mask_ssh1(int);
1.40 djm 78: const Cipher *cipher_by_name(const char *);
79: const Cipher *cipher_by_number(int);
1.28 markus 80: int cipher_number(const char *);
81: char *cipher_name(int);
82: int ciphers_valid(const char *);
1.42 djm 83: char *cipher_alg_list(char, int);
1.40 djm 84: void cipher_init(CipherContext *, const Cipher *, const u_char *, u_int,
1.30 markus 85: const u_char *, u_int, int);
1.43 markus 86: int cipher_crypt(CipherContext *, u_int, u_char *, const u_char *,
1.39 markus 87: u_int, u_int, u_int);
1.42 djm 88: int cipher_get_length(CipherContext *, u_int *, u_int,
89: const u_char *, u_int);
1.30 markus 90: void cipher_cleanup(CipherContext *);
1.40 djm 91: void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int);
1.34 jakob 92: u_int cipher_blocksize(const Cipher *);
93: u_int cipher_keylen(const Cipher *);
1.44 dtucker 94: u_int cipher_seclen(const Cipher *);
1.39 markus 95: u_int cipher_authlen(const Cipher *);
96: u_int cipher_ivlen(const Cipher *);
1.37 markus 97: u_int cipher_is_cbc(const Cipher *);
1.33 markus 98:
1.34 jakob 99: u_int cipher_get_number(const Cipher *);
1.33 markus 100: void cipher_get_keyiv(CipherContext *, u_char *, u_int);
101: void cipher_set_keyiv(CipherContext *, u_char *);
1.34 jakob 102: int cipher_get_keyiv_len(const CipherContext *);
103: int cipher_get_keycontext(const CipherContext *, u_char *);
1.33 markus 104: void cipher_set_keycontext(CipherContext *, u_char *);
1.9 deraadt 105: #endif /* CIPHER_H */