mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
Assorted further migration to ptrlen.
The local put_mp_*_from_string functions in import.c now take ptrlen (which simplifies essentially all their call sites); so does the local function logwrite() in logging.c, and so does ssh2_fingerprint_blob.
This commit is contained in:
10
sshpubk.c
10
sshpubk.c
@ -1474,7 +1474,7 @@ void ssh2_write_pubkey(FILE *fp, const char *comment,
|
||||
/* ----------------------------------------------------------------------
|
||||
* Utility functions to compute SSH-2 fingerprints in a uniform way.
|
||||
*/
|
||||
char *ssh2_fingerprint_blob(const void *blob, int bloblen)
|
||||
char *ssh2_fingerprint_blob(ptrlen blob)
|
||||
{
|
||||
unsigned char digest[16];
|
||||
char fingerprint_str[16*3];
|
||||
@ -1486,19 +1486,19 @@ char *ssh2_fingerprint_blob(const void *blob, int bloblen)
|
||||
/*
|
||||
* The fingerprint hash itself is always just the MD5 of the blob.
|
||||
*/
|
||||
hash_simple(&ssh_md5, make_ptrlen(blob, bloblen), digest);
|
||||
hash_simple(&ssh_md5, blob, digest);
|
||||
for (i = 0; i < 16; i++)
|
||||
sprintf(fingerprint_str + i*3, "%02x%s", digest[i], i==15 ? "" : ":");
|
||||
|
||||
/*
|
||||
* Identify the key algorithm, if possible.
|
||||
*/
|
||||
BinarySource_BARE_INIT(src, blob, bloblen);
|
||||
BinarySource_BARE_INIT_PL(src, blob);
|
||||
algname = get_string(src);
|
||||
if (!get_err(src)) {
|
||||
alg = find_pubkey_alg_len(algname);
|
||||
if (alg) {
|
||||
int bits = ssh_key_public_bits(alg, make_ptrlen(blob, bloblen));
|
||||
int bits = ssh_key_public_bits(alg, blob);
|
||||
return dupprintf("%.*s %d %s", PTRLEN_PRINTF(algname),
|
||||
bits, fingerprint_str);
|
||||
} else {
|
||||
@ -1518,7 +1518,7 @@ char *ssh2_fingerprint(ssh_key *data)
|
||||
{
|
||||
strbuf *blob = strbuf_new();
|
||||
ssh_key_public_blob(data, BinarySink_UPCAST(blob));
|
||||
char *ret = ssh2_fingerprint_blob(blob->s, blob->len);
|
||||
char *ret = ssh2_fingerprint_blob(ptrlen_from_strbuf(blob));
|
||||
strbuf_free(blob);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user