ANSC_HANDLE AnscAsn1CloneOctetString ( ANSC_HANDLE hSrcAsn1OctetString ) { PANSC_ASN1_OCTET_STRING pSrcAsn1OctetString = (PANSC_ASN1_OCTET_STRING)hSrcAsn1OctetString; PANSC_ASN1_OCTET_STRING pNewAsn1OctetString = NULL; if ( pSrcAsn1OctetString ) { pNewAsn1OctetString = (PANSC_ASN1_OCTET_STRING)AnscAsn1AllocOctetString ( pSrcAsn1OctetString->Octets, pSrcAsn1OctetString->Length ); } else { return (ANSC_HANDLE)NULL; } return (ANSC_HANDLE)pNewAsn1OctetString; }
ANSC_ASN1_OCTET_STRING* AnscX509CertGetSubjectKeyID ( void* raw_cert_data, ULONG raw_cert_size ) { PANSC_ASN1_CERTIFICATE pAsnCert = NULL; ANSC_ASN1_OCTET_STRING* pOctets = NULL; PUCHAR pKeyID = NULL; ULONG length = 0; /* decode the asn.1 certificate handle */ pAsnCert = (PANSC_ASN1_CERTIFICATE) anscGetCertHandle ( raw_cert_data, raw_cert_size ); if( pAsnCert == NULL) { goto EXIT; } /* get the subject key identifier */ if( ANSC_STATUS_SUCCESS != pAsnCert->GetSubjectKeyIdentifier(pAsnCert, &pKeyID, &length)) { length = 0; } if( length > 0 && pKeyID != NULL) { pOctets = (ANSC_ASN1_OCTET_STRING*) AnscAsn1AllocOctetString( pKeyID, length); } EXIT: anscFreeCertHandle((ANSC_HANDLE)pAsnCert); if( pKeyID != NULL) { AnscFreeMemory(pKeyID); } return pOctets; }