0

I need to validate the incoming connection in my application. The incoming connection will be sending a public key and the finger print of the public key. I need to validate this public key by calculating the finger print for the public key and then compare the calculated finger print with the finger print sent by the client. I am not able to find a way to calculate this finger print for the public key. I am using open-ssl library in C platform.

Any help regarding the calculation of this finger print of the public key will be very much appreciated.

Kranthi Kumar
  • 1,184
  • 3
  • 13
  • 26
  • So... you need to hash the public key. Not sure what you're really looking for beyond that. `libcrypto` provides plenty of digest algorithms for doing this, though it would likely be typical for you to use either sha1 or sha256. – WhozCraig Feb 17 '14 at 19:33

1 Answers1

0

I computed SHA1 hash which can be used as fingerprint as following:

X509 * cert = ... /*Initialize certificate*/
unsigned char buffer[SHA1_DIGEST_LENGTH];
X509_check_purpose (cert, -1, 0);
/*Copy sha1_hash from the certificate.*/
memcpy(abuffer, rCert->sha1_hash, SHA1_DIGEST_LENGTH);

I hope this would help you.

doptimusprime
  • 9,115
  • 6
  • 52
  • 90