src/lib/crypto.c
static ASN1_OCTET_STRING *openssl_cert_keyid(X509 *cert) {
   X509_EXTENSION *ext;
   const X509V3_EXT_METHOD *method;
   ASN1_OCTET_STRING *keyid;
   int i;
   const ASN1_STRING *asn1_ext_val;
   const unsigned char *ext_value_data;

   /* Find the index to the subjectKeyIdentifier extension */
   i = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1);
   if (i < 0) {
      /* Not found */
      return NULL;
   }

   /* Grab the extension */
   ext = X509_get_ext(cert, i);

   /* Get x509 extension method structure */
   if (!(method = X509V3_EXT_get(ext))) {
      return NULL;
   }

   asn1_ext_val = X509_EXTENSION_get_data(ext);
   ext_value_data = ASN1_STRING_get0_data(asn1_ext_val);

   if (method->it) {
      /* New style ASN1 */

      /* Decode ASN1 item in data */
      keyid = (ASN1_OCTET_STRING *) ASN1_item_d2i(NULL, &ext_value_data, ASN1_STRING_length(asn1_ext_val),
                                                  ASN1_ITEM_ptr(method->it));
   } else {
      /* Old style ASN1 */

      /* Decode ASN1 item in data */
      keyid = (ASN1_OCTET_STRING *) method->d2i(NULL, &ext_value_data, ASN1_STRING_length(asn1_ext_val));
   }

   return keyid;
}
/*
 * Extract subjectKeyIdentifier from x509 certificate.
 * Returns: On success, an ASN1_OCTET_STRING that must be freed via ASN1_OCTET_STRING_free().
 *          NULL on failure.
 */
Extract subjectKeyIdentifier from x509 certificate.
Returns: On success, an ASN1_OCTET_STRING that must be freed via ASN1_OCTET_STRING_free().
NULL on failure.
Extract subjectKeyIdentifier from x509 certificate . Returns : On success an ASN1_OCTET_STRING that must be freed via ASN1_OCTET_STRING_free () . NULL on failure .
static ASN1_OCTET_STRING *openssl_cert_keyid(X509 *cert) {
   X509_EXTENSION *ext;
   const X509V3_EXT_METHOD *method;
   ASN1_OCTET_STRING *keyid;
   int i;
   const ASN1_STRING *asn1_ext_val;
   const unsigned char *ext_value_data;
   i = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1);
   if (i < 0) {
      return NULL;
   }
   ext = X509_get_ext(cert, i);
   if (!(method = X509V3_EXT_get(ext))) {
      return NULL;
   }
   asn1_ext_val = X509_EXTENSION_get_data(ext);
   ext_value_data = ASN1_STRING_get0_data(asn1_ext_val);
   if (method->it) {
      keyid = (ASN1_OCTET_STRING *) ASN1_item_d2i(NULL, &ext_value_data, ASN1_STRING_length(asn1_ext_val),
                                                  ASN1_ITEM_ptr(method->it));
   } else {
      keyid = (ASN1_OCTET_STRING *) method->d2i(NULL, &ext_value_data, ASN1_STRING_length(asn1_ext_val));
   }
   return keyid;
}
static ASN1_OCTET_STRING * openssl_cert_keyid ( X509 * cert ) { X509_EXTENSION * ext ; const X509V3_EXT_METHOD * method ; ASN1_OCTET_STRING * keyid ; int i ; const ASN1_STRING * asn1_ext_val ; const unsigned char * ext_value_data ; i = X509_get_ext_by_NID ( cert , NID_subject_key_identifier , -1 ) ; if ( i < 0 ) { return NULL ; } ext = X509_get_ext ( cert , i ) ; if ( ! ( method = X509V3_EXT_get ( ext ) ) ) { return NULL ; } asn1_ext_val = X509_EXTENSION_get_data ( ext ) ; ext_value_data = ASN1_STRING_get0_data ( asn1_ext_val ) ; if ( method -> it ) { keyid = ( ASN1_OCTET_STRING * ) ASN1_item_d2i ( NULL , & ext_value_data , ASN1_STRING_length ( asn1_ext_val ) , ASN1_ITEM_ptr ( method -> it ) ) ; } else { keyid = ( ASN1_OCTET_STRING * ) method -> d2i ( NULL , & ext_value_data , ASN1_STRING_length ( asn1_ext_val ) ) ; } return keyid ; }
Extract subjectKeyIdentifier from x509 certificate.
Extract subjectKeyIdentifier from x509 certificate .
/* Find the index to the subjectKeyIdentifier extension */ /* Not found */ /* Grab the extension */ /* Get x509 extension method structure */ /* New style ASN1 */ /* Decode ASN1 item in data */ /* Old style ASN1 */ /* Decode ASN1 item in data */