comparison ed25519.c @ 1728:01fb08c43b85

merge
author Matt Johnston <matt@ucc.asn.au>
date Tue, 23 Jun 2020 22:25:57 +0800
parents 93dcc97c3f3f
children 35d504d59c05
comparison
equal deleted inserted replaced
1726:57f85129670f 1728:01fb08c43b85
82 memcpy(key->priv, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN); 82 memcpy(key->priv, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
83 buf_incrpos(buf, CURVE25519_LEN); 83 buf_incrpos(buf, CURVE25519_LEN);
84 memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN); 84 memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
85 buf_incrpos(buf, CURVE25519_LEN); 85 buf_incrpos(buf, CURVE25519_LEN);
86 86
87 TRACE(("leave buf_get_ed25519_pub_key: success")) 87 TRACE(("leave buf_get_ed25519_priv_key: success"))
88 return DROPBEAR_SUCCESS; 88 return DROPBEAR_SUCCESS;
89 } 89 }
90 90
91 /* Clear and free the memory used by a public or private key */ 91 /* Clear and free the memory used by a public or private key */
92 void ed25519_key_free(dropbear_ed25519_key *key) { 92 void ed25519_key_free(dropbear_ed25519_key *key) {
98 return; 98 return;
99 } 99 }
100 m_burn(key->priv, CURVE25519_LEN); 100 m_burn(key->priv, CURVE25519_LEN);
101 m_free(key); 101 m_free(key);
102 102
103 TRACE2(("leave rsa_key_free")) 103 TRACE2(("leave ed25519_key_free"))
104 } 104 }
105 105
106 /* Put the public ed25519 key into the buffer in the required format */ 106 /* Put the public ed25519 key into the buffer in the required format */
107 void buf_put_ed25519_pub_key(buffer *buf, const dropbear_ed25519_key *key) { 107 void buf_put_ed25519_pub_key(buffer *buf, const dropbear_ed25519_key *key) {
108 108
158 TRACE(("enter buf_ed25519_verify")) 158 TRACE(("enter buf_ed25519_verify"))
159 dropbear_assert(key != NULL); 159 dropbear_assert(key != NULL);
160 160
161 slen = buf_getint(buf); 161 slen = buf_getint(buf);
162 if (slen != 64 || buf->len - buf->pos < slen) { 162 if (slen != 64 || buf->len - buf->pos < slen) {
163 TRACE(("bad size")) 163 TRACE(("leave buf_ed25519_verify: bad size"))
164 goto out; 164 goto out;
165 } 165 }
166 s = buf_getptr(buf, slen); 166 s = buf_getptr(buf, slen);
167 167
168 if (dropbear_ed25519_verify(data_buf->data, data_buf->len, 168 if (dropbear_ed25519_verify(data_buf->data, data_buf->len,
169 s, slen, key->pub) == 0) { 169 s, slen, key->pub) == 0) {
170 /* signature is valid */ 170 /* signature is valid */
171 TRACE(("success!")) 171 TRACE(("leave buf_ed25519_verify: success!"))
172 ret = DROPBEAR_SUCCESS; 172 ret = DROPBEAR_SUCCESS;
173 } 173 }
174 174
175 out: 175 out:
176 TRACE(("leave buf_ed25519_verify: ret %d", ret)) 176 TRACE(("leave buf_ed25519_verify: ret %d", ret))