Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Refactor sshkey #10

wants to merge 11 commits into from

Conversation

djmdjm
Copy link
Owner

@djmdjm djmdjm commented Feb 4, 2022

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.

ssh-dss.c Outdated Show resolved Hide resolved
ssh-ed25519.c Outdated Show resolved Hide resolved
sshkey.c Show resolved Hide resolved
ssh-ecdsa.c Outdated Show resolved Hide resolved
ssh-ed25519.c Outdated Show resolved Hide resolved
sshd.c Outdated Show resolved Hide resolved
sshkey.c Outdated Show resolved Hide resolved
sshkey.h Outdated Show resolved Hide resolved
Copy link
Contributor

@mfriedl mfriedl left a 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.

@djmdjm
Copy link
Owner Author

djmdjm commented Mar 17, 2022

sorry for the useless commit names, but they should address all your comments @mfriedl :)

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;
Copy link
Contributor

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

Copy link
Contributor

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)
Copy link
Contributor

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 ||
Copy link
Contributor

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)
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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 */
Copy link
Contributor

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

@djmdjm djmdjm closed this Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants