source: swig/perl/SSL_keyid.c @ 756011e

abac0-leak
Last change on this file since 756011e was 756011e, checked in by Ted Faber <faber@…>, 11 years ago

Now we pass -Wall with no warnings.

  • Property mode set to 100644
File size: 387 bytes
Line 
1#include <stdio.h>
2
3#include <openssl/x509.h>
4
5char *SSL_keyid(void *ptr) {
6    int i;
7    unsigned char sha1_hash[SHA_DIGEST_LENGTH];
8    X509 *x = (X509 *)ptr;
9
10    X509_pubkey_digest(x, EVP_sha1(), sha1_hash, NULL);
11
12    char *hash = malloc(SHA_DIGEST_LENGTH * 2 + 1);
13    for (i = 0; i < SHA_DIGEST_LENGTH; ++i)
14        sprintf(&hash[2*i], "%02x", sha1_hash[i]);
15
16    return hash;
17}
Note: See TracBrowser for help on using the repository browser.