diff options
Diffstat (limited to 'cipher.h')
-rw-r--r-- | cipher.h | 59 |
1 files changed, 32 insertions, 27 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cipher.h,v 1.44 2014/01/25 10:12:50 dtucker Exp $ */ | 1 | /* $OpenBSD: cipher.h,v 1.46 2014/06/24 01:13:21 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -37,8 +37,10 @@ | |||
37 | #ifndef CIPHER_H | 37 | #ifndef CIPHER_H |
38 | #define CIPHER_H | 38 | #define CIPHER_H |
39 | 39 | ||
40 | #include <sys/types.h> | ||
40 | #include <openssl/evp.h> | 41 | #include <openssl/evp.h> |
41 | #include "cipher-chachapoly.h" | 42 | #include "cipher-chachapoly.h" |
43 | #include "cipher-aesctr.h" | ||
42 | 44 | ||
43 | /* | 45 | /* |
44 | * Cipher types for SSH-1. New types can be added, but old types should not | 46 | * Cipher types for SSH-1. New types can be added, but old types should not |
@@ -60,44 +62,47 @@ | |||
60 | #define CIPHER_ENCRYPT 1 | 62 | #define CIPHER_ENCRYPT 1 |
61 | #define CIPHER_DECRYPT 0 | 63 | #define CIPHER_DECRYPT 0 |
62 | 64 | ||
63 | typedef struct Cipher Cipher; | 65 | struct sshcipher; |
64 | typedef struct CipherContext CipherContext; | 66 | struct sshcipher_ctx { |
65 | |||
66 | struct Cipher; | ||
67 | struct CipherContext { | ||
68 | int plaintext; | 67 | int plaintext; |
69 | int encrypt; | 68 | int encrypt; |
70 | EVP_CIPHER_CTX evp; | 69 | EVP_CIPHER_CTX evp; |
71 | struct chachapoly_ctx cp_ctx; /* XXX union with evp? */ | 70 | struct chachapoly_ctx cp_ctx; /* XXX union with evp? */ |
72 | const Cipher *cipher; | 71 | struct aesctr_ctx ac_ctx; /* XXX union with evp? */ |
72 | const struct sshcipher *cipher; | ||
73 | }; | 73 | }; |
74 | 74 | ||
75 | typedef struct sshcipher Cipher ; | ||
76 | typedef struct sshcipher_ctx CipherContext ; | ||
77 | |||
75 | u_int cipher_mask_ssh1(int); | 78 | u_int cipher_mask_ssh1(int); |
76 | const Cipher *cipher_by_name(const char *); | 79 | const struct sshcipher *cipher_by_name(const char *); |
77 | const Cipher *cipher_by_number(int); | 80 | const struct sshcipher *cipher_by_number(int); |
78 | int cipher_number(const char *); | 81 | int cipher_number(const char *); |
79 | char *cipher_name(int); | 82 | char *cipher_name(int); |
80 | int ciphers_valid(const char *); | 83 | int ciphers_valid(const char *); |
81 | char *cipher_alg_list(char, int); | 84 | char *cipher_alg_list(char, int); |
82 | void cipher_init(CipherContext *, const Cipher *, const u_char *, u_int, | 85 | int cipher_init(struct sshcipher_ctx *, const struct sshcipher *, |
83 | const u_char *, u_int, int); | 86 | const u_char *, u_int, const u_char *, u_int, int); |
84 | int cipher_crypt(CipherContext *, u_int, u_char *, const u_char *, | 87 | const char* cipher_warning_message(const struct sshcipher_ctx *); |
88 | int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *, | ||
85 | u_int, u_int, u_int); | 89 | u_int, u_int, u_int); |
86 | int cipher_get_length(CipherContext *, u_int *, u_int, | 90 | int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int, |
87 | const u_char *, u_int); | 91 | const u_char *, u_int); |
88 | void cipher_cleanup(CipherContext *); | 92 | int cipher_cleanup(struct sshcipher_ctx *); |
89 | void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int); | 93 | int cipher_set_key_string(struct sshcipher_ctx *, const struct sshcipher *, |
90 | u_int cipher_blocksize(const Cipher *); | 94 | const char *, int); |
91 | u_int cipher_keylen(const Cipher *); | 95 | u_int cipher_blocksize(const struct sshcipher *); |
92 | u_int cipher_seclen(const Cipher *); | 96 | u_int cipher_keylen(const struct sshcipher *); |
93 | u_int cipher_authlen(const Cipher *); | 97 | u_int cipher_seclen(const struct sshcipher *); |
94 | u_int cipher_ivlen(const Cipher *); | 98 | u_int cipher_authlen(const struct sshcipher *); |
95 | u_int cipher_is_cbc(const Cipher *); | 99 | u_int cipher_ivlen(const struct sshcipher *); |
100 | u_int cipher_is_cbc(const struct sshcipher *); | ||
96 | 101 | ||
97 | u_int cipher_get_number(const Cipher *); | 102 | u_int cipher_get_number(const struct sshcipher *); |
98 | void cipher_get_keyiv(CipherContext *, u_char *, u_int); | 103 | int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, u_int); |
99 | void cipher_set_keyiv(CipherContext *, u_char *); | 104 | int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *); |
100 | int cipher_get_keyiv_len(const CipherContext *); | 105 | int cipher_get_keyiv_len(const struct sshcipher_ctx *); |
101 | int cipher_get_keycontext(const CipherContext *, u_char *); | 106 | int cipher_get_keycontext(const struct sshcipher_ctx *, u_char *); |
102 | void cipher_set_keycontext(CipherContext *, u_char *); | 107 | void cipher_set_keycontext(struct sshcipher_ctx *, const u_char *); |
103 | #endif /* CIPHER_H */ | 108 | #endif /* CIPHER_H */ |