Mercurial > dropbear
annotate common-runopts.c @ 686:983a817f8e41 insecure-nocrypto
- Only request "none" cipher after auth has succeeded
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 17 May 2012 20:52:57 +0800 |
parents | 4edea9f363d0 |
children | 167fdc091c05 |
rev | line source |
---|---|
33 | 1 /* |
2 * Dropbear - a SSH2 server | |
3 * | |
4 * Copyright (c) 2002,2003 Matt Johnston | |
5 * All rights reserved. | |
6 * | |
7 * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 * of this software and associated documentation files (the "Software"), to deal | |
9 * in the Software without restriction, including without limitation the rights | |
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 * copies of the Software, and to permit persons to whom the Software is | |
12 * furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be included in | |
15 * all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 * SOFTWARE. */ | |
24 | |
25 #include "includes.h" | |
26 #include "runopts.h" | |
47 | 27 #include "signkey.h" |
28 #include "buffer.h" | |
29 #include "dbutil.h" | |
30 #include "auth.h" | |
682
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
31 #include "algo.h" |
33 | 32 |
33 runopts opts; /* GLOBAL */ | |
47 | 34 |
35 /* returns success or failure, and the keytype in *type. If we want | |
36 * to restrict the type, type can contain a type to return */ | |
37 int readhostkey(const char * filename, sign_key * hostkey, int *type) { | |
38 | |
39 int ret = DROPBEAR_FAILURE; | |
40 buffer *buf; | |
41 | |
42 buf = buf_new(MAX_PRIVKEY_SIZE); | |
43 | |
44 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) { | |
45 goto out; | |
46 } | |
47 buf_setpos(buf, 0); | |
48 if (buf_get_priv_key(buf, hostkey, type) == DROPBEAR_FAILURE) { | |
49 goto out; | |
50 } | |
51 | |
52 ret = DROPBEAR_SUCCESS; | |
53 out: | |
54 | |
55 buf_burn(buf); | |
56 buf_free(buf); | |
57 return ret; | |
58 } | |
682
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
59 |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
60 #ifdef ENABLE_USER_ALGO_LIST |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
61 void |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
62 parse_ciphers_macs() |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
63 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
64 if (opts.cipher_list) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
65 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
66 if (strcmp(opts.cipher_list, "help") == 0) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
67 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
68 char *ciphers = algolist_string(sshciphers); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
69 dropbear_log(LOG_INFO, "Available ciphers:\n%s\n", ciphers); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
70 m_free(ciphers); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
71 dropbear_exit("."); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
72 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
73 |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
74 if (check_user_algos(opts.cipher_list, sshciphers, "cipher") == 0) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
75 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
76 dropbear_exit("No valid ciphers specified for '-c'"); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
77 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
78 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
79 |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
80 if (opts.mac_list) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
81 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
82 if (strcmp(opts.mac_list, "help") == 0) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
83 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
84 char *macs = algolist_string(sshhashes); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
85 dropbear_log(LOG_INFO, "Available MACs:\n%s\n", macs); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
86 m_free(macs); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
87 dropbear_exit("."); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
88 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
89 |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
90 if (check_user_algos(opts.mac_list, sshhashes, "MAC") == 0) |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
91 { |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
92 dropbear_exit("No valid MACs specified for '-m'"); |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
93 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
94 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
95 } |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
96 #endif |
4edea9f363d0
Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents:
47
diff
changeset
|
97 |