diff options
author | Rich Salz <rsalz@openssl.org> | 2017-01-12 16:39:41 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-01-12 16:39:41 -0500 |
commit | 3e5d9da5fc45a5d129e0daa7211125eba097c3dd (patch) | |
tree | 2f2bc3a49465c6347ccdf2c87aed899e37df1f72 /crypto/x509 | |
parent | d49661ced5c2b426ce57f1016077674bfcfa7daf (diff) |
Make X509_Digest,others public
Also, if want SHA1 then use the pre-computed value if there.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2223)
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x_all.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index d9f42edaab..86f4d70042 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -362,6 +362,13 @@ int X509_pubkey_digest(const X509 *data, const EVP_MD *type, int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { + if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0) { + /* Asking for SHA1 and we already computed it. */ + if (len != NULL) + *len = sizeof(data->sha1_hash); + memcpy(md, data->sha1_hash, sizeof(data->sha1_hash)); + return 1; + } return (ASN1_item_digest (ASN1_ITEM_rptr(X509), type, (char *)data, md, len)); } @@ -369,6 +376,13 @@ int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { + if (type == EVP_sha1()) { + /* Asking for SHA1; always computed in CRL d2i. */ + if (len != NULL) + *len = sizeof(data->sha1_hash); + memcpy(md, data->sha1_hash, sizeof(data->sha1_hash)); + return 1; + } return (ASN1_item_digest (ASN1_ITEM_rptr(X509_CRL), type, (char *)data, md, len)); } |