annotate dss.c @ 1561:02b226c2675e fuzz

clean some fuzzing conditionals
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Feb 2018 22:10:43 +0800
parents 5916af64acd4
children 1051e4eea25a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * Dropbear - a SSH2 server
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * Copyright (c) 2002,2003 Matt Johnston
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 * All rights reserved.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 * of this software and associated documentation files (the "Software"), to deal
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * in the Software without restriction, including without limitation the rights
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 * copies of the Software, and to permit persons to whom the Software is
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * furnished to do so, subject to the following conditions:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 * The above copyright notice and this permission notice shall be included in
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 * all copies or substantial portions of the Software.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 * SOFTWARE. */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 #include "includes.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 #include "dbutil.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 #include "bignum.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 #include "dss.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 #include "buffer.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 #include "ssh.h"
858
220f55d540ae rename random.h to dbrandom.h since some OSes have a system random.h
Matt Johnston <matt@ucc.asn.au>
parents: 805
diff changeset
31 #include "dbrandom.h"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 /* Handle DSS (Digital Signature Standard), aka DSA (D.S. Algorithm),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 * operations, such as key reading, signing, verification. Key generation
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 * is in gendss.c, since it isn't required in the server itself.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 * See FIPS186 or the Handbook of Applied Cryptography for details of the
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 * algorithm */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39
1295
750ec4ec4cbe Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents: 1122
diff changeset
40 #if DROPBEAR_DSS
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 /* Load a dss key from a buffer, initialising the values.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 * The key will have the same format as buf_put_dss_key.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 * These should be freed with dss_key_free.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
586
b50f0107e505 Rename rsa_key to dropbear_rsa_key (and same for dss too) so
Matt Johnston <matt@ucc.asn.au>
parents: 378
diff changeset
46 int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
47 int ret = DROPBEAR_FAILURE;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 150
diff changeset
49 TRACE(("enter buf_get_dss_pub_key"))
241
c5d3ef11155f * use own assertions which should get logged properly
Matt Johnston <matt@ucc.asn.au>
parents: 188
diff changeset
50 dropbear_assert(key != NULL);
805
724c3e0c8734 Add m_mp_alloc_init_multi() helper
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
51 m_mp_alloc_init_multi(&key->p, &key->q, &key->g, &key->y, NULL);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 key->x = NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 buf_incrpos(buf, 4+SSH_SIGNKEY_DSS_LEN); /* int + "ssh-dss" */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 || buf_getmpint(buf, key->q) == DROPBEAR_FAILURE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57 || buf_getmpint(buf, key->g) == DROPBEAR_FAILURE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 || buf_getmpint(buf, key->y) == DROPBEAR_FAILURE) {
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 150
diff changeset
59 TRACE(("leave buf_get_dss_pub_key: failed reading mpints"))
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
60 ret = DROPBEAR_FAILURE;
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
61 goto out;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63
1430
7aebe7da3a35 test dss key parameter lengths exactly
Matt Johnston <matt@ucc.asn.au>
parents: 1418
diff changeset
64 if (mp_count_bits(key->p) != DSS_P_BITS) {
1418
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
65 dropbear_log(LOG_WARNING, "Bad DSS p");
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
66 ret = DROPBEAR_FAILURE;
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
67 goto out;
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
68 }
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
69
1430
7aebe7da3a35 test dss key parameter lengths exactly
Matt Johnston <matt@ucc.asn.au>
parents: 1418
diff changeset
70 if (mp_count_bits(key->q) != DSS_Q_BITS) {
1418
92717c0fec39 check p and q lengths
Matt Johnston <matt@ucc.asn.au>
parents: 1412
diff changeset
71 dropbear_log(LOG_WARNING, "Bad DSS q");
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
72 ret = DROPBEAR_FAILURE;
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
73 goto out;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75
1450
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
76 /* test 1 < g < p */
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
77 if (mp_cmp_d(key->g, 1) != MP_GT) {
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
78 dropbear_log(LOG_WARNING, "Bad DSS g");
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
79 ret = DROPBEAR_FAILURE;
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
80 goto out;
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
81 }
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
82 if (mp_cmp(key->g, key->p) != MP_LT) {
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
83 dropbear_log(LOG_WARNING, "Bad DSS g");
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
84 ret = DROPBEAR_FAILURE;
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
85 goto out;
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
86 }
5b25d86b865b check dss g range
Matt Johnston <matt@ucc.asn.au>
parents: 1432
diff changeset
87
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
88 ret = DROPBEAR_SUCCESS;
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 150
diff changeset
89 TRACE(("leave buf_get_dss_pub_key: success"))
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
90 out:
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
91 if (ret == DROPBEAR_FAILURE) {
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
92 m_mp_free_multi(&key->p, &key->q, &key->g, &key->y, NULL);
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
93 }
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
94 return ret;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97 /* Same as buf_get_dss_pub_key, but reads a private "x" key at the end.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98 * Loads a private dss key from a buffer
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
586
b50f0107e505 Rename rsa_key to dropbear_rsa_key (and same for dss too) so
Matt Johnston <matt@ucc.asn.au>
parents: 378
diff changeset
100 int buf_get_dss_priv_key(buffer* buf, dropbear_dss_key *key) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 int ret = DROPBEAR_FAILURE;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103
241
c5d3ef11155f * use own assertions which should get logged properly
Matt Johnston <matt@ucc.asn.au>
parents: 188
diff changeset
104 dropbear_assert(key != NULL);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 ret = buf_get_dss_pub_key(buf, key);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 if (ret == DROPBEAR_FAILURE) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 return DROPBEAR_FAILURE;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110
805
724c3e0c8734 Add m_mp_alloc_init_multi() helper
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
111 m_mp_alloc_init_multi(&key->x, NULL);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 ret = buf_getmpint(buf, key->x);
368
ed910547d449 Free x component of DSS key upon failure to load
Matt Johnston <matt@ucc.asn.au>
parents: 241
diff changeset
113 if (ret == DROPBEAR_FAILURE) {
1412
a54b22f4058d fix missing arglist NULL terminator
Matt Johnston <matt@ucc.asn.au>
parents: 1410
diff changeset
114 m_mp_free_multi(&key->x, NULL);
368
ed910547d449 Free x component of DSS key upon failure to load
Matt Johnston <matt@ucc.asn.au>
parents: 241
diff changeset
115 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
116
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
117 return ret;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
121 /* Clear and free the memory used by a public or private key */
586
b50f0107e505 Rename rsa_key to dropbear_rsa_key (and same for dss too) so
Matt Johnston <matt@ucc.asn.au>
parents: 378
diff changeset
122 void dss_key_free(dropbear_dss_key *key) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123
731
9a5438271556 Move the more verbose TRACE() statements into TRACE2()
Matt Johnston <matt@ucc.asn.au>
parents: 696
diff changeset
124 TRACE2(("enter dsa_key_free"))
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
125 if (key == NULL) {
731
9a5438271556 Move the more verbose TRACE() statements into TRACE2()
Matt Johnston <matt@ucc.asn.au>
parents: 696
diff changeset
126 TRACE2(("enter dsa_key_free: key == NULL"))
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 return;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 }
1381
c98e242dc505 add m_mp_free_multi, be more careful freeing when failing to load keys
Matt Johnston <matt@ucc.asn.au>
parents: 1295
diff changeset
129 m_mp_free_multi(&key->p, &key->q, &key->g, &key->y, &key->x, NULL);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 m_free(key);
731
9a5438271556 Move the more verbose TRACE() statements into TRACE2()
Matt Johnston <matt@ucc.asn.au>
parents: 696
diff changeset
131 TRACE2(("leave dsa_key_free"))
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134 /* put the dss public key into the buffer in the required format:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136 * string "ssh-dss"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 * mpint p
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 * mpint q
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 * mpint g
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 * mpint y
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 */
1459
06d52bcb8094 Pointer parameter could be declared as pointing to const
Francois Perrad <francois.perrad@gadz.org>
parents: 1430
diff changeset
142 void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143
241
c5d3ef11155f * use own assertions which should get logged properly
Matt Johnston <matt@ucc.asn.au>
parents: 188
diff changeset
144 dropbear_assert(key != NULL);
1122
aaf576b27a10 Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents: 1094
diff changeset
145 buf_putstring(buf, SSH_SIGNKEY_DSS, SSH_SIGNKEY_DSS_LEN);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 buf_putmpint(buf, key->p);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 buf_putmpint(buf, key->q);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
148 buf_putmpint(buf, key->g);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149 buf_putmpint(buf, key->y);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
150
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 /* Same as buf_put_dss_pub_key, but with the private "x" key appended */
1459
06d52bcb8094 Pointer parameter could be declared as pointing to const
Francois Perrad <francois.perrad@gadz.org>
parents: 1430
diff changeset
154 void buf_put_dss_priv_key(buffer* buf, const dropbear_dss_key *key) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155
241
c5d3ef11155f * use own assertions which should get logged properly
Matt Johnston <matt@ucc.asn.au>
parents: 188
diff changeset
156 dropbear_assert(key != NULL);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 buf_put_dss_pub_key(buf, key);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158 buf_putmpint(buf, key->x);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161
1295
750ec4ec4cbe Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents: 1122
diff changeset
162 #if DROPBEAR_SIGNKEY_VERIFY
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 /* Verify a DSS signature (in buf) made on data by the key given.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 * returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
1459
06d52bcb8094 Pointer parameter could be declared as pointing to const
Francois Perrad <francois.perrad@gadz.org>
parents: 1430
diff changeset