Annotation of src/usr.bin/ssh/kex.h, Revision 1.6
1.1 markus 1: /*
2: * Copyright (c) 2000 Markus Friedl. All rights reserved.
3: *
4: * Redistribution and use in source and binary forms, with or without
5: * modification, are permitted provided that the following conditions
6: * are met:
7: * 1. Redistributions of source code must retain the above copyright
8: * notice, this list of conditions and the following disclaimer.
9: * 2. Redistributions in binary form must reproduce the above copyright
10: * notice, this list of conditions and the following disclaimer in the
11: * documentation and/or other materials provided with the distribution.
12: *
13: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: */
24: #ifndef KEX_H
25: #define KEX_H
26:
1.5 provos 27: #define KEX_DH1 "diffie-hellman-group1-sha1"
28: #define KEX_DHGEX "diffie-hellman-group-exchange-sha1"
29: #define KEX_DSS "ssh-dss"
1.1 markus 30:
31: enum kex_init_proposals {
32: PROPOSAL_KEX_ALGS,
33: PROPOSAL_SERVER_HOST_KEY_ALGS,
34: PROPOSAL_ENC_ALGS_CTOS,
35: PROPOSAL_ENC_ALGS_STOC,
36: PROPOSAL_MAC_ALGS_CTOS,
37: PROPOSAL_MAC_ALGS_STOC,
38: PROPOSAL_COMP_ALGS_CTOS,
39: PROPOSAL_COMP_ALGS_STOC,
40: PROPOSAL_LANG_CTOS,
41: PROPOSAL_LANG_STOC,
42: PROPOSAL_MAX
43: };
44:
45: enum kex_modes {
46: MODE_IN,
47: MODE_OUT,
48: MODE_MAX
49: };
50:
1.5 provos 51: enum kex_exchange {
52: DH_GRP1_SHA1,
53: DH_GEX_SHA1
54: };
55:
1.1 markus 56: typedef struct Kex Kex;
57: typedef struct Mac Mac;
58: typedef struct Comp Comp;
59: typedef struct Enc Enc;
60:
61: struct Enc {
1.6 ! markus 62: char *name;
1.1 markus 63: int type;
1.6 ! markus 64: Cipher *cipher;
1.1 markus 65: int enabled;
66: unsigned char *key;
67: unsigned char *iv;
68: };
69: struct Mac {
1.6 ! markus 70: char *name;
! 71: int enabled;
1.1 markus 72: EVP_MD *md;
73: int mac_len;
74: unsigned char *key;
75: int key_len;
76: };
77: struct Comp {
78: int type;
79: int enabled;
80: char *name;
81: };
82: struct Kex {
83: Enc enc [MODE_MAX];
84: Mac mac [MODE_MAX];
85: Comp comp[MODE_MAX];
86: int we_need;
87: int server;
88: char *name;
89: char *hostkeyalg;
1.5 provos 90: int kex_type;
1.1 markus 91: };
92:
93: Buffer *kex_init(char *myproposal[PROPOSAL_MAX]);
1.3 markus 94: void
95: kex_exchange_kexinit(
96: Buffer *my_kexinit, Buffer *peer_kexint,
97: char *peer_proposal[PROPOSAL_MAX]);
98: Kex *
99: kex_choose_conf(char *cprop[PROPOSAL_MAX],
100: char *sprop[PROPOSAL_MAX], int server);
101: int kex_derive_keys(Kex *k, unsigned char *hash, BIGNUM *shared_secret);
102: void packet_set_kex(Kex *k);
1.2 markus 103: int dh_pub_is_valid(DH *dh, BIGNUM *dh_pub);
1.5 provos 104: DH *dh_new_group_asc(const char *, const char *);
105: DH *dh_new_group(BIGNUM *, BIGNUM *);
1.2 markus 106: DH *dh_new_group1();
1.1 markus 107:
108: unsigned char *
109: kex_hash(
110: char *client_version_string,
111: char *server_version_string,
112: char *ckexinit, int ckexinitlen,
113: char *skexinit, int skexinitlen,
114: char *serverhostkeyblob, int sbloblen,
115: BIGNUM *client_dh_pub,
116: BIGNUM *server_dh_pub,
117: BIGNUM *shared_secret);
118:
1.5 provos 119: unsigned char *
120: kex_hash_gex(
121: char *client_version_string,
122: char *server_version_string,
123: char *ckexinit, int ckexinitlen,
124: char *skexinit, int skexinitlen,
125: char *serverhostkeyblob, int sbloblen,
126: int minbits, BIGNUM *prime, BIGNUM *gen,
127: BIGNUM *client_dh_pub,
128: BIGNUM *server_dh_pub,
129: BIGNUM *shared_secret);
1.1 markus 130: #endif