return TRUE;
}
-static char *blobfp(char *alg, int bits, unsigned char *blob, int bloblen)
-{
- char buffer[128];
- unsigned char digest[16];
- struct MD5Context md5c;
- int i;
-
- MD5Init(&md5c);
- MD5Update(&md5c, blob, bloblen);
- MD5Final(digest, &md5c);
-
- sprintf(buffer, "%s ", alg);
- if (bits > 0)
- sprintf(buffer + strlen(buffer), "%d ", bits);
- for (i = 0; i < 16; i++)
- sprintf(buffer + strlen(buffer), "%s%02x", i ? ":" : "",
- digest[i]);
-
- return dupstr(buffer);
-}
-
int main(int argc, char **argv)
{
char *infile = NULL;
ec_generate(ec, bits, progressfn, &prog);
ssh2key = snew(struct ssh2_userkey);
ssh2key->data = ec;
- if (bits == 256) {
- ssh2key->alg = &ssh_ecdsa_nistp256;
- } else if (bits == 384) {
- ssh2key->alg = &ssh_ecdsa_nistp384;
- } else {
- ssh2key->alg = &ssh_ecdsa_nistp521;
- }
+ ssh2key->alg = ec->signalg;
ssh1key = NULL;
} else if (keytype == ED25519) {
struct ec_key *ec = snew(struct ec_key);
if (ssh2blob) {
ssh2algf = find_pubkey_alg(ssh2alg);
if (ssh2algf)
- bits = ssh2algf->pubkey_bits(ssh2blob, ssh2bloblen);
+ bits = ssh2algf->pubkey_bits(ssh2algf,
+ ssh2blob, ssh2bloblen);
else
bits = -1;
}
+ sfree(ssh2alg);
} else {
ssh2key = ssh2_load_userkey(infilename, passphrase, &error);
}
rsa_fingerprint(fingerprint, 128, ssh1key);
} else {
if (ssh2key) {
- fingerprint = ssh2key->alg->fingerprint(ssh2key->data);
+ fingerprint = ssh2_fingerprint(ssh2key->alg,
+ ssh2key->data);
} else {
assert(ssh2blob);
- fingerprint = blobfp(ssh2alg, bits, ssh2blob, ssh2bloblen);
+ fingerprint = ssh2_fingerprint_blob(ssh2blob, ssh2bloblen);
}
}