CpSetKeyParam函数原型为:

 

BOOL CPSetKeyParam(

  __in          HCRYPTPROV hProv,

  __in          HCRYPTKEY hKey,

  __in          DWORD dwParam,

  __in          BYTE* pbData,

  __in          DWORD dwFlags

);

MSDN中说到当参数 dwParam KP_CERTFICATE时,导入证书。


KP_CERTIFICATE

pbData is the address of a buffer that contains the DER-encoded X.509 certificate. The public key in the certificate must match the corresponding signature or exchange key.

问题是参数 pbData数据的长度和格式是什么呢?在MSDN中没有相关方档说明。

 

问题答案是:证书二进制采用TLVTAG-LENGTH-VALUE)格式。证书二进制数据总是以0x30,0x82,SizeHighByte,SizeLowByte,….这些开头。证书大小不包括开始4个字节,因此应该加上4字节去计算证书的大小。

证书为DER编码

相关文章:

  • 2021-08-15
  • 2021-07-27
  • 2021-11-23
  • 2021-06-06
  • 2021-09-20
  • 2021-06-11
猜你喜欢
  • 2021-07-27
  • 2021-08-11
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2021-11-13
  • 2022-01-26
相关资源
相似解决方案