New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor sshkey #10
Refactor sshkey #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks very good. some comments inline.
sorry for the useless commit names, but they should address all your comments @mfriedl :) |
98c5649
to
82842ed
Compare
Move keytypes data and some of the type-specific code (allocation, cleanup, etc) out into each key type's implementation.
also share some cleanup code for SK
82842ed
to
829426b
Compare
static int | ||
ssh_dss_equal(const struct sshkey *a, const struct sshkey *b) | ||
{ | ||
const BIGNUM *dsa_p_a, *dsa_q_a, *dsa_g_a, *dsa_pub_key_a; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to me, but my brain works different and I would have written dsa_a_p and dsa_b_p, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind
u_int32_t left; | ||
size_t pklen; | ||
|
||
if ((r = sshkey_xmss_init(n, from->xmss_name)) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'n' should read 'to'
if (from->xmss_pk == NULL) | ||
return 0; /* XXX SSH_ERR_INTERNAL_ERROR ? */ | ||
|
||
if ((pklen = sshkey_xmss_pklen(k)) == 0 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'k' should read 'to'
return 0; /* XXX SSH_ERR_INTERNAL_ERROR ? */ | ||
|
||
if ((pklen = sshkey_xmss_pklen(k)) == 0 || | ||
sshkey_xmss_pklen(n) != pklen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n -> from
return SSH_ERR_ALLOC_FAIL; /* caller will free to->xmss_pk */ | ||
memcpy(to->xmss_pk, from->xmss_pk, pklen); | ||
/* simulate number of signatures left on pubkey */ | ||
left = sshkey_xmss_signatures_left(k); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
/* simulate number of signatures left on pubkey */ | ||
left = sshkey_xmss_signatures_left(k); | ||
if (left) | ||
sshkey_xmss_enable_maxsign(n, left); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
sshkey_xmss_pklen(n) != pklen) | ||
return SSH_ERR_INTERNAL_ERROR; | ||
if ((to->xmss_pk = malloc(pklen)) == NULL) | ||
return SSH_ERR_ALLOC_FAIL; /* caller will free to->xmss_pk */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to free since malloc failed
This factors most of the algorithm-specific code from sshkey.c to the algorithm-specific files (e.g. ssh-rsa.c). There's probably more to do, like cleaning up the various ECDSA NID helpers, etc.