summaryrefslogtreecommitdiff
path: root/cipher.h
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-02 15:28:02 +1000
committerDamien Miller <djm@mindrot.org>2014-07-02 15:28:02 +1000
commit8668706d0f52654fe64c0ca41a96113aeab8d2b8 (patch)
tree73e78e1ea3d39206e39870bbe0af17d6c430fb51 /cipher.h
parent2cd7929250cf9e9f658d70dcd452f529ba08c942 (diff)
- djm@cvs.openbsd.org 2014/06/24 01:13:21
[Makefile.in auth-bsdauth.c auth-chall.c auth-options.c auth-rsa.c [auth2-none.c auth2-pubkey.c authfile.c authfile.h cipher-3des1.c [cipher-chachapoly.c cipher-chachapoly.h cipher.c cipher.h [digest-libc.c digest-openssl.c digest.h dns.c entropy.c hmac.h [hostfile.c key.c key.h krl.c monitor.c packet.c rsa.c rsa.h [ssh-add.c ssh-agent.c ssh-dss.c ssh-ecdsa.c ssh-ed25519.c [ssh-keygen.c ssh-pkcs11-client.c ssh-pkcs11-helper.c ssh-pkcs11.c [ssh-rsa.c sshbuf-misc.c sshbuf.h sshconnect.c sshconnect1.c [sshconnect2.c sshd.c sshkey.c sshkey.h [openbsd-compat/openssl-compat.c openbsd-compat/openssl-compat.h] New key API: refactor key-related functions to be more library-like, existing API is offered as a set of wrappers. with and ok markus@ Thanks also to Ben Hawkes, David Tomaschik, Ivan Fratric, Matthew Dempsky and Ron Bowes for a detailed review a few months ago. NB. This commit also removes portable OpenSSH support for OpenSSL <0.9.8e.
Diffstat (limited to 'cipher.h')
-rw-r--r--cipher.h57
1 files changed, 30 insertions, 27 deletions
diff --git a/cipher.h b/cipher.h
index 5aa778f14..de74c1e3b 100644
--- a/cipher.h
+++ b/cipher.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher.h,v 1.45 2014/04/29 18:01:49 markus 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,6 +37,7 @@
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"
42#include "cipher-aesctr.h" 43#include "cipher-aesctr.h"
@@ -61,45 +62,47 @@
61#define CIPHER_ENCRYPT 1 62#define CIPHER_ENCRYPT 1
62#define CIPHER_DECRYPT 0 63#define CIPHER_DECRYPT 0
63 64
64typedef struct Cipher Cipher; 65struct sshcipher;
65typedef struct CipherContext CipherContext; 66struct sshcipher_ctx {
66
67struct Cipher;
68struct CipherContext {
69 int plaintext; 67 int plaintext;
70 int encrypt; 68 int encrypt;
71 EVP_CIPHER_CTX evp; 69 EVP_CIPHER_CTX evp;
72 struct chachapoly_ctx cp_ctx; /* XXX union with evp? */ 70 struct chachapoly_ctx cp_ctx; /* XXX union with evp? */
73 struct aesctr_ctx ac_ctx; /* XXX union with evp? */ 71 struct aesctr_ctx ac_ctx; /* XXX union with evp? */
74 const Cipher *cipher; 72 const struct sshcipher *cipher;
75}; 73};
76 74
75typedef struct sshcipher Cipher ;
76typedef struct sshcipher_ctx CipherContext ;
77
77u_int cipher_mask_ssh1(int); 78u_int cipher_mask_ssh1(int);
78const Cipher *cipher_by_name(const char *); 79const struct sshcipher *cipher_by_name(const char *);
79const Cipher *cipher_by_number(int); 80const struct sshcipher *cipher_by_number(int);
80int cipher_number(const char *); 81int cipher_number(const char *);
81char *cipher_name(int); 82char *cipher_name(int);
82int ciphers_valid(const char *); 83int ciphers_valid(const char *);
83char *cipher_alg_list(char, int); 84char *cipher_alg_list(char, int);
84void cipher_init(CipherContext *, const Cipher *, const u_char *, u_int, 85int cipher_init(struct sshcipher_ctx *, const struct sshcipher *,
85 const u_char *, u_int, int); 86 const u_char *, u_int, const u_char *, u_int, int);
86int cipher_crypt(CipherContext *, u_int, u_char *, const u_char *, 87const char* cipher_warning_message(const struct sshcipher_ctx *);
88int cipher_crypt(struct sshcipher_ctx *, u_int, u_char *, const u_char *,
87 u_int, u_int, u_int); 89 u_int, u_int, u_int);
88int cipher_get_length(CipherContext *, u_int *, u_int, 90int cipher_get_length(struct sshcipher_ctx *, u_int *, u_int,
89 const u_char *, u_int); 91 const u_char *, u_int);
90void cipher_cleanup(CipherContext *); 92int cipher_cleanup(struct sshcipher_ctx *);
91void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int); 93int cipher_set_key_string(struct sshcipher_ctx *, const struct sshcipher *,
92u_int cipher_blocksize(const Cipher *); 94 const char *, int);
93u_int cipher_keylen(const Cipher *); 95u_int cipher_blocksize(const struct sshcipher *);
94u_int cipher_seclen(const Cipher *); 96u_int cipher_keylen(const struct sshcipher *);
95u_int cipher_authlen(const Cipher *); 97u_int cipher_seclen(const struct sshcipher *);
96u_int cipher_ivlen(const Cipher *); 98u_int cipher_authlen(const struct sshcipher *);
97u_int cipher_is_cbc(const Cipher *); 99u_int cipher_ivlen(const struct sshcipher *);
100u_int cipher_is_cbc(const struct sshcipher *);
98 101
99u_int cipher_get_number(const Cipher *); 102u_int cipher_get_number(const struct sshcipher *);
100void cipher_get_keyiv(CipherContext *, u_char *, u_int); 103int cipher_get_keyiv(struct sshcipher_ctx *, u_char *, u_int);
101void cipher_set_keyiv(CipherContext *, u_char *); 104int cipher_set_keyiv(struct sshcipher_ctx *, const u_char *);
102int cipher_get_keyiv_len(const CipherContext *); 105int cipher_get_keyiv_len(const struct sshcipher_ctx *);
103int cipher_get_keycontext(const CipherContext *, u_char *); 106int cipher_get_keycontext(const struct sshcipher_ctx *, u_char *);
104void cipher_set_keycontext(CipherContext *, u_char *); 107void cipher_set_keycontext(struct sshcipher_ctx *, const u_char *);
105#endif /* CIPHER_H */ 108#endif /* CIPHER_H */