Skip to content

Commit

Permalink
update SSH API
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaeckel authored and karel-m committed Apr 11, 2021
1 parent d96dd76 commit 230b1fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pk/ecc/ecc_sign_hash_rfc5656.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int ecc_sign_hash_rfc5656(const unsigned char *in, unsigned long inlen,
if ((err = ecc_ssh_ecdsa_encode_name(name, &namelen, key)) != CRYPT_OK) goto error;
/* Store as SSH data sequence, per RFC4251 */
err = ssh_encode_sequence_multi(out, outlen,
LTC_SSHDATA_STRING, name,
LTC_SSHDATA_STRING, name, namelen,
LTC_SSHDATA_MPINT, r,
LTC_SSHDATA_MPINT, s,
LTC_SSHDATA_EOL, NULL);
Expand Down
10 changes: 6 additions & 4 deletions src/pk/ecc/ecc_verify_hash_rfc5656.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,24 @@ int ecc_verify_hash_rfc5656(const unsigned char *sig, unsigned long siglen,
void *r, *s;
int err;
char name[64], name2[64];
unsigned long namelen = sizeof(name2);
unsigned long namelen = sizeof(name);
unsigned long name2len = sizeof(name2);
unsigned long slen = siglen;

LTC_ARGCHK(sig != NULL);
LTC_ARGCHK(key != NULL);

if ((err = mp_init_multi(&r, &s, NULL)) != CRYPT_OK) return err;

/* Decode as SSH data sequence, per RFC4251 */
if ((err = ssh_decode_sequence_multi(sig, siglen,
LTC_SSHDATA_STRING, name, 64,
if ((err = ssh_decode_sequence_multi(sig, &slen,
LTC_SSHDATA_STRING, name, &namelen,
LTC_SSHDATA_MPINT, r,
LTC_SSHDATA_MPINT, s,
LTC_SSHDATA_EOL, NULL)) != CRYPT_OK) goto error;

/* Check curve matches identifier string */
if ((err = ecc_ssh_ecdsa_encode_name(name2, &namelen, key)) != CRYPT_OK) goto error;
if ((err = ecc_ssh_ecdsa_encode_name(name2, &name2len, key)) != CRYPT_OK) goto error;
if (XSTRCMP(name,name2) != 0) {
err = CRYPT_INVALID_ARG;
goto error;
Expand Down

0 comments on commit 230b1fc

Please sign in to comment.