/*++ /* NAME /* tls_fprint 3 /* SUMMARY /* Digests fingerprints and all that. /* SYNOPSIS /* #include <tls.h> /* /* EVP_MD *tls_digest_byname(const char *mdalg, EVP_MD_CTX **mdctxPtr) /* const char *mdalg; /* EVP_MD_CTX **mdctxPtr; /* /* char *tls_serverid_digest(TLScontext, props, ciphers) /* TLS_SESS_STATE *TLScontext; /* const TLS_CLIENT_START_PROPS *props; /* const char *ciphers; /* /* char *tls_digest_encode(md_buf, md_len) /* const unsigned char *md_buf; /* const char *md_len; /* /* char *tls_cert_fprint(peercert, mdalg) /* X509 *peercert; /* const char *mdalg; /* /* char *tls_pkey_fprint(peercert, mdalg) /* EVP_PKEY *peerpkey; /* const char *mdalg; /* DESCRIPTION /* tls_digest_byname() constructs, and optionally returns, an EVP_MD_CTX /* handle for performing digest operations with the algorithm named by the /* mdalg parameter. The return value is non-null on success, and holds a /* digest algorithm handle. If the mdctxPtr argument is non-null the /* created context is returned to the caller, who is then responsible for /* deleting it by calling EVP_MD_ctx_free() once it is no longer needed. /* /* tls_digest_encode() converts a binary message digest to a hex ASCII /* format with ':' separators between each pair of hex digits. /* The return value is dynamically allocated with mymalloc(), /* and the caller must eventually free it with myfree(). /* /* tls_cert_fprint() returns a fingerprint of the given /* certificate using the requested message digest, formatted /* with tls_digest_encode(). Panics if the /* (previously verified) digest algorithm is not found. The return /* value is dynamically allocated with mymalloc(), and the caller /* must eventually free it with myfree(). /* /* tls_pkey_fprint() returns a public-key fingerprint; in all /* other respects the function behaves as tls_cert_fprint(). /* The return value is dynamically allocated with mymalloc(), /* and the caller must eventually free it with myfree(). /* /* tls_serverid_digest() suffixes props->serverid computed by the SMTP /* client with "&" plus a digest of additional parameters needed to ensure /* that re-used sessions are more likely to be reused and that they will /* satisfy all protocol and security requirements. The return value is /* dynamically allocated with mymalloc(), and the caller must eventually /* free it with myfree(). /* /* Arguments: /* .IP mdalg /* A digest algorithm name, such as "sha256". /* .IP peercert /* Server or client X.509 certificate. /* .IP md_buf /* The raw binary digest. /* .IP md_len /* The digest length in bytes. /* .IP mdalg /* Name of a message digest algorithm suitable for computing secure /* (1st pre-image resistant) message digests of certificates. For now, /* md5, sha1, or member of SHA-2 family if supported by OpenSSL. /* .IP mdctxPtr /* Pointer to an (EVP_MD_CTX *) handle, or NULL if only probing for /* algorithm support without immediate use in mind. /* .IP buf /* Input data for the message digest algorithm mdalg. /* .IP len /* The length of the input data. /* .IP props /* The client start properties for the session, which contains the /* initial serverid from the SMTP client and the DANE verification /* parameters. /* .IP protomask /* The mask of protocol exclusions. /* .IP ciphers /* The SSL client cipherlist. /* LICENSE /* .ad /* .fi /* This software is free. You can do with it whatever you want. /* The original author kindly requests that you acknowledge /* the use of his software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Viktor Dukhovni
/*--*/
/* tls_digest_tlsa - fold in digest of TLSA records */
staticint tls_digest_tlsa(EVP_MD_CTX *mdctx, TLS_TLSA *tlsa)
{
TLS_TLSA *p;
TLS_TLSA **arr; int ok = 1; int n; int i;
for (n = 0, p = tlsa; p != 0; p = p->next)
++n;
arr = (TLS_TLSA **) mymalloc(n * sizeof(*arr)); for (i = 0, p = tlsa; p; p = p->next)
arr[i++] = (void *) p;
qsort(arr, n, sizeof(arr[0]), tlsa_cmp);
CHECK_OK_AND_DIGEST_OBJECT(mdctx, &n); for (i = 0; i < n; ++i) {
CHECK_OK_AND_DIGEST_OBJECT(mdctx, &arr[i]->usage);
CHECK_OK_AND_DIGEST_OBJECT(mdctx, &arr[i]->selector);
CHECK_OK_AND_DIGEST_OBJECT(mdctx, &arr[i]->mtype);
CHECK_OK_AND_DIGEST_OBJECT(mdctx, &arr[i]->length);
CHECK_OK_AND_DIGEST_DATA(mdctx, arr[i]->data, arr[i]->length);
}
myfree((void *) arr); return (ok);
}
/* tls_digest_byname - test availability or prepare to use digest */
const EVP_MD *tls_digest_byname(constchar *mdalg, EVP_MD_CTX **mdctxPtr)
{ const EVP_MD *md;
EVP_MD_CTX *mdctx = NULL; int ok = 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.