libpurple/plugins/ssl/ssl-nss.c

branch
soc.2007.certmgr
changeset 19014
1a67cc27fb12
parent 19013
60c74d9597f3
child 19023
547e94194c7a
equal deleted inserted replaced
19013:60c74d9597f3 19014:1a67cc27fb12
471 } 471 }
472 472
473 static GByteArray * 473 static GByteArray *
474 x509_sha1sum(PurpleCertificate *crt) 474 x509_sha1sum(PurpleCertificate *crt)
475 { 475 {
476 return NULL; 476 CERTCertificate *crt_dat;
477 size_t hashlen = 20; /* Size of an sha1sum */
478 GByteArray *sha1sum;
479 SECItem *derCert; /* DER representation of the cert */
480 SECStatus st;
481
482 g_return_val_if_fail(crt, NULL);
483 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
484
485 crt_dat = X509_NSS_DATA(crt);
486 g_return_val_if_fail(crt_dat, NULL);
487
488 /* Get the certificate DER representation */
489 derCert = &(crt_dat->derCert);
490
491 /* Make a hash! */
492 sha1sum = g_byte_array_sized_new(hashlen);
493 st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data,
494 derCert->data, derCert->len);
495
496 /* Check for errors */
497 if (st != SECSuccess) {
498 g_byte_array_free(sha1sum, TRUE);
499 purple_debug_error("nss/x509",
500 "Error: hashing failed!\n");
501 return NULL;
502 }
503
504 return sha1sum;
477 } 505 }
478 506
479 static gchar * 507 static gchar *
480 x509_common_name (PurpleCertificate *crt) 508 x509_common_name (PurpleCertificate *crt)
481 { 509 {

mercurial