source: swig/perl/SSL_keyid.c @ aa2bd1e

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since aa2bd1e was 17ec3b0, checked in by Mike Ryan <mikeryan@…>, 14 years ago

get SSL public key hash instead of whole cert has

this still differs from libabac hash since this only hashes the
modulus

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