当前位置: 首页>>代码示例>>C++>>正文


C++ PANSC_ASN1_CERTIFICATE::VerifySignature方法代码示例

本文整理汇总了C++中PANSC_ASN1_CERTIFICATE::VerifySignature方法的典型用法代码示例。如果您正苦于以下问题:C++ PANSC_ASN1_CERTIFICATE::VerifySignature方法的具体用法?C++ PANSC_ASN1_CERTIFICATE::VerifySignature怎么用?C++ PANSC_ASN1_CERTIFICATE::VerifySignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PANSC_ASN1_CERTIFICATE的用法示例。


在下文中一共展示了PANSC_ASN1_CERTIFICATE::VerifySignature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if


//.........这里部分代码省略.........
    {
        pX509Cert->Signing          = ANSC_CERT_signing_rsa;
        pX509Cert->KeyType          = ANSC_CERT_keyType_rsa;
    }
    else if( pAsnCert->GetKeyType(pAsnCert) == PKI_DSA_KEY)
    {
        pX509Cert->Signing          = ANSC_CERT_signing_dsa;
        pX509Cert->KeyType          = ANSC_CERT_keyType_dsa;
    }
    else
    {
        pX509Cert->KeyType          = ANSC_CERT_keyType_diffieHellman;
    }

    /* get the key length */
    pX509Cert->KeyBits              = pAsnCert->GetKeyBits(pAsnCert);

    /* get the key usage; */
    if( ANSC_STATUS_SUCCESS == pAsnCert->GetKeyUsage(pAsnCert, &keyUsage))
    {
        /* the value has to be reversed */
        pX509Cert->KeyUsage         = 0;

        if( keyUsage >= 0x0100)
        {
            pX509Cert->KeyUsage     +=  ANSC_CERT_keyUsage_deciperOnly;
        }

        keyUsage            = keyUsage & 0x000000FF;

        if( keyUsage & 0x00000001)
        {
            pX509Cert->KeyUsage += 0x000000080;
        }
        if( keyUsage & 0x00000002)
        {
            pX509Cert->KeyUsage += 0x000000040;
        }
        if( keyUsage & 0x00000004)
        {
            pX509Cert->KeyUsage += 0x000000020;
        }
        if( keyUsage & 0x00000008)
        {
            pX509Cert->KeyUsage += 0x000000010;
        }
        if( keyUsage & 0x00000010)
        {
            pX509Cert->KeyUsage += 0x000000008;
        }
        if( keyUsage & 0x00000020)
        {
            pX509Cert->KeyUsage += 0x000000004;
        }
        if( keyUsage & 0x00000040)
        {
            pX509Cert->KeyUsage += 0x000000002;
        }
        if( keyUsage & 0x00000080)
        {
            pX509Cert->KeyUsage += 0x000000001;
        }
    }
    else
    {
        /*
         * For the old cert without KeyUsage extension, we assume it
         * has all the usages
         */
        pX509Cert->KeyUsage = 0x000000FF;
    }

    /* get the md5 hash of the raw stream and set it as the CertID */
    hash.Length = ANSC_MD5_OUTPUT_SIZE;

    hash.Length  = AnscCryptoMd5Digest(raw_cert_data, raw_cert_size, &hash);

    AnscCopyMemory
        (
            pX509Cert->CertID,
            hash.Value,
            hash.Length
        );

#if 1
    if( pAsnCert->IsSelfSigned(pAsnCert))
    {
        if(!pAsnCert->VerifySignature(pAsnCert, NULL))
        {
            AnscTrace("Warning: Failed to verify the self-signed certificate.\n");
        }
    }
#endif

EXIT:

    anscFreeCertHandle((ANSC_HANDLE)pAsnCert);

    return  pX509Cert;
}
开发者ID:rdkcmf,项目名称:rdkb-CcspCommonLibrary,代码行数:101,代码来源:ansc_x509_cert.c


注:本文中的PANSC_ASN1_CERTIFICATE::VerifySignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。