本文整理汇总了C++中PANSC_ASN1_CERTIFICATE类的典型用法代码示例。如果您正苦于以下问题:C++ PANSC_ASN1_CERTIFICATE类的具体用法?C++ PANSC_ASN1_CERTIFICATE怎么用?C++ PANSC_ASN1_CERTIFICATE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PANSC_ASN1_CERTIFICATE类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/*********************************************************************************
*
* static functions implemented by Bin
*
*********************************************************************************/
static ANSC_HANDLE
anscGetCertHandle
(
void* raw_cert_data,
ULONG raw_cert_size
)
{
PANSC_ASN1_CERTIFICATE pAsnCert = NULL;
PUCHAR pBack = (PUCHAR)raw_cert_data;
if( raw_cert_size < 32 || raw_cert_data == NULL)
{
return NULL;
}
/* create the asn.1 certificate handle */
pAsnCert = (PANSC_ASN1_CERTIFICATE)AnscAsn1CreateCertificate(NULL);
if( pAsnCert == NULL)
{
return NULL;
}
/* decode it */
if( ANSC_STATUS_SUCCESS != pAsnCert->DecodingData(pAsnCert, (PVOID*)&pBack))
{
pAsnCert->AsnFree(pAsnCert);
return NULL;
}
return (ANSC_HANDLE)pAsnCert;
}
示例2: anscFreeCertHandle
BOOL
AnscX509CertIsSelfSigned
(
void* raw_cert_data,
ULONG raw_cert_size
)
{
PANSC_ASN1_CERTIFICATE pAsnCert = NULL;
BOOL bIsSelfSigned = FALSE;
/* decode the asn.1 certificate handle */
pAsnCert = (PANSC_ASN1_CERTIFICATE)
anscGetCertHandle
(
raw_cert_data,
raw_cert_size
);
if( pAsnCert == NULL)
{
goto EXIT;
}
bIsSelfSigned = pAsnCert->IsSelfSigned(pAsnCert);
EXIT:
anscFreeCertHandle((ANSC_HANDLE)pAsnCert);
return bIsSelfSigned;
}
示例3:
static void
anscFreeCertHandle
(
ANSC_HANDLE hThisObject
)
{
PANSC_ASN1_CERTIFICATE pThisObject = (PANSC_ASN1_CERTIFICATE)hThisObject;
if( pThisObject != NULL)
{
pThisObject->AsnFree(pThisObject);
}
}
示例4: AnscTrace
/*************************************************************************
*
* This is the api to init the KeyGenParams from the given certificate
* and private key info
*
*************************************************************************/
ANSC_STATUS
PKIUtilityInitKeyGenParams
(
ANSC_HANDLE hSSLCrypto,
PANSC_ASN1_CERTIFICATE pCert,
PANSC_ASN1_PRIVATEKEYINFO pKeyInfo,
ANSC_HANDLE hKeyGenParams
)
{
PANSC_CRYPTO_PUB_KEY_GEN_PARAMS pKeyGenParams = (PANSC_CRYPTO_PUB_KEY_GEN_PARAMS)hKeyGenParams;
PANSC_CRYPTO_PUB_SSLEAY_OBJECT pSSLCrypto = (PANSC_CRYPTO_PUB_SSLEAY_OBJECT)hSSLCrypto;
BOOLEAN bKeyPair = TRUE;
PKI_KEY_TYPE keyType;
if( pCert == NULL || pKeyInfo == NULL || hKeyGenParams == NULL)
{
return ANSC_STATUS_FAILURE;
}
keyType = pCert->GetKeyType(pCert);
if( keyType != PKI_RSA_KEY && keyType != PKI_DSA_KEY)
{
return ANSC_STATUS_FAILURE;
}
if( keyType != pKeyInfo->GetKeyType(pKeyInfo))
{
AnscTrace("The key pair is not in the same key type.\n");
return ANSC_STATUS_FAILURE;
}
/* init the public key */
if( ANSC_STATUS_SUCCESS !=
pCert->ExportPublicKey
(
pCert,
hKeyGenParams
))
{
return ANSC_STATUS_FAILURE;
}
/* init the private key */
if( ANSC_STATUS_SUCCESS !=
pKeyInfo->ExportKey
(
pKeyInfo,
hKeyGenParams
))
{
return ANSC_STATUS_FAILURE;
}
/* verify the key pair */
if( pSSLCrypto != NULL)
{
if( keyType == PKI_RSA_KEY)
{
bKeyPair =
pSSLCrypto->KeyPairMatch
(
pSSLCrypto,
ANSC_CRYPTO_PUB_KEY_RSA,
&pKeyGenParams->PublicKey.RSA,
&pKeyGenParams->PrivateKey.RSA
);
}
else
{
bKeyPair =
pSSLCrypto->KeyPairMatch
(
pSSLCrypto,
ANSC_CRYPTO_PUB_KEY_DSA,
&pKeyGenParams->PublicKey.DSA,
&pKeyGenParams->PrivateKey.DSA
);
}
}
if( bKeyPair)
{
return ANSC_STATUS_SUCCESS;
}
else
{
return ANSC_STATUS_FAILURE;
}
}
示例5: if
ULONG
AnscX509CertGetKeyType
(
void* raw_cert_data,
ULONG raw_cert_size,
PULONG cert_signing,
PULONG cert_key_usage,
PULONG cert_key_bits
)
{
PANSC_ASN1_CERTIFICATE pAsnCert = NULL;
ULONG keyType = ANSC_CERT_keyType_rsa;
ULONG keyUsage;
/* decode the asn.1 certificate handle */
pAsnCert = (PANSC_ASN1_CERTIFICATE)
anscGetCertHandle
(
raw_cert_data,
raw_cert_size
);
if( pAsnCert == NULL)
{
goto EXIT;
}
if( pAsnCert->GetKeyType(pAsnCert) == PKI_RSA_KEY)
{
keyType = ANSC_CERT_keyType_rsa;
*cert_signing = ANSC_CERT_signing_rsa;
}
else if( pAsnCert->GetKeyType(pAsnCert) == PKI_DSA_KEY)
{
keyType = ANSC_CERT_keyType_dsa;
*cert_signing = ANSC_CERT_signing_dsa;
}
else
{
keyType = ANSC_CERT_keyType_diffieHellman;
}
*cert_key_bits = pAsnCert->GetKeyBits(pAsnCert);
/* get the key usage; */
if( ANSC_STATUS_SUCCESS == pAsnCert->GetKeyUsage(pAsnCert, &keyUsage))
{
if( keyUsage >= 0x0100)
{
*cert_key_usage |= ANSC_CERT_keyUsage_deciperOnly;
}
*cert_key_usage += keyUsage & 0x000000FF;
}
EXIT:
anscFreeCertHandle((ANSC_HANDLE)pAsnCert);
return keyType;
}
示例6: AnscSListPushEntryAtBack
/**************************************************************************************
*
* static callback functions to get cert and key info from PKCS12.
*
**************************************************************************************/
ANSC_STATUS
initProc
(
ANSC_HANDLE hContext,
PUCHAR pCertEncoding,
ULONG ulCertSize,
PUCHAR pKeyEncoding,
ULONG ulKeyInfoSize
)
{
PPKI_CLIENT_ENTITY pThisObject = (PPKI_CLIENT_ENTITY)hContext;
PALCERT_CONTEXT pCertContext = NULL;
PANSC_ASN1_CERTIFICATE pNewCert;
PUCHAR pEncoding;
if( pCertEncoding == NULL || ulCertSize == 0)
{
return ANSC_STATUS_FAILURE;
}
pCertContext = (PALCERT_CONTEXT)pThisObject->hContainerContext;
if( pKeyEncoding == NULL || ulKeyInfoSize == 0)
{
/* add the ca cert */
if( pCertContext == NULL)
{
pNewCert = (PANSC_ASN1_CERTIFICATE)AnscAsn1CreateCertificate(NULL);
pEncoding= pCertEncoding;
pNewCert->DecodingData(pNewCert,(PVOID*)&pEncoding);
AnscSListPushEntryAtBack(&pThisObject->sCAList, &pNewCert->Linkage);
}
else
{
pCertContext->AddTrustedCA
(
pCertContext,
"",
pCertEncoding,
ulCertSize
);
}
}
else
{
pThisObject->SetIssuedCert(pThisObject, pCertEncoding, ulCertSize);
pThisObject->SetPrivateKeyInfo(pThisObject, pKeyEncoding, ulKeyInfoSize);
}
if( pThisObject->pCertAttr != NULL)
{
pThisObject->pCertAttr->Remove(pThisObject->pCertAttr);
}
pThisObject->pCertAttr = GenerateAttrByCertificate(pThisObject->hUserCert);
return ANSC_STATUS_SUCCESS;
}