mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
New function to get all digests of a public key
This commit is contained in:
parent
bc2d9357f5
commit
dcf69a9e12
@ -1249,6 +1249,32 @@ crypto_pk_get_digest(crypto_pk_env_t *pk, char *digest_out)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compute all digests of the DER encoding of <b>pk</b>, and store them
|
||||||
|
* in <b>digests_out</b>. Return 0 on success, -1 on failure. */
|
||||||
|
int
|
||||||
|
crypto_pk_get_all_digests(crypto_pk_env_t *pk, digests_t *digests_out)
|
||||||
|
{
|
||||||
|
unsigned char *buf, *bufp;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = i2d_RSAPublicKey(pk->key, NULL);
|
||||||
|
if (len < 0)
|
||||||
|
return -1;
|
||||||
|
buf = bufp = tor_malloc(len+1);
|
||||||
|
len = i2d_RSAPublicKey(pk->key, &bufp);
|
||||||
|
if (len < 0) {
|
||||||
|
crypto_log_errors(LOG_WARN,"encoding public key");
|
||||||
|
tor_free(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (crypto_digest_all(digests_out, (char*)buf, len) < 0) {
|
||||||
|
tor_free(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tor_free(buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Copy <b>in</b> to the <b>outlen</b>-byte buffer <b>out</b>, adding spaces
|
/** Copy <b>in</b> to the <b>outlen</b>-byte buffer <b>out</b>, adding spaces
|
||||||
* every four spaces. */
|
* every four spaces. */
|
||||||
/* static */ void
|
/* static */ void
|
||||||
|
@ -150,6 +150,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env, char *to,
|
|||||||
int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, size_t dest_len);
|
int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, size_t dest_len);
|
||||||
crypto_pk_env_t *crypto_pk_asn1_decode(const char *str, size_t len);
|
crypto_pk_env_t *crypto_pk_asn1_decode(const char *str, size_t len);
|
||||||
int crypto_pk_get_digest(crypto_pk_env_t *pk, char *digest_out);
|
int crypto_pk_get_digest(crypto_pk_env_t *pk, char *digest_out);
|
||||||
|
int crypto_pk_get_all_digests(crypto_pk_env_t *pk, digests_t *digests_out);
|
||||||
int crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out,int add_space);
|
int crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out,int add_space);
|
||||||
int crypto_pk_check_fingerprint_syntax(const char *s);
|
int crypto_pk_check_fingerprint_syntax(const char *s);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user