30820122300D06092A864886F70D01010105000382010F003082010A0282010100D45C30CB6FBB1D394CE5A87B49DB6DCF1434B0FA4E0AA371F850EE8BAE7F2DC3C548D51CBDA3DD01F0D6553BFB79851E731543984B22E362B4FC1DD3D6DE82377D20132CC63965DD0AD2DD689E985291613540F30E75A558F915B2E9E40DD421CAC6BDB74590F4428AB4684ECB4294D3BAD212F6662200EEF7DDC301316FBA676B7120FB91893C2BA311A84F73AF2163B5604405FD760BB152689CF5204F20CBBD97623B5DB96CCF6BA3826AC38790D3C2C66CD7EBFD5C9F1E70CBC77F558F95501A9A9CB4AB3DFDA265D010A49AB702A0015DF0F6E08D0CE36330641C4DC75EA8FE7DD5EA6B37BD64328577F8550D3F015AA56F1AB5F25E55F59340AF53F9550203010001 请根据以上数据生成一个EVP_KEY 对象
时间: 2024-04-04 19:31:34 浏览: 53
以下是生成EVP_KEY对象的示例代码:
```c
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
int main()
{
// 解析CSR数据
unsigned char csr_data[] = {
0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09,
0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,
0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00,
0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01,
0x00, 0xD4, 0x5C, 0x30, 0xCB, 0x6F, 0xBB, 0x1D,
0x39, 0x4C, 0xE5, 0xA8, 0x7B, 0x49, 0xDB, 0x6D,
0xCF, 0x14, 0x34, 0xB0, 0xFA, 0x4E, 0x0A, 0xA3,
0x71, 0xF8, 0x50, 0xEE, 0x8B, 0xAE, 0x7F, 0x2D,
0xC3, 0xC5, 0x48, 0xD5, 0x1C, 0xBD, 0xA3, 0xDD,
0x01, 0xF0, 0xD6, 0x55, 0x3B, 0xFB, 0x79, 0x85,
0x1E, 0x73, 0x15, 0x43, 0x98, 0x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 0x57, 0x7F, 0x85, 0x50,
0xD3, 0xF0, 0x15, 0xAA, 0x56, 0xF1, 0xAB, 0x5F,
0x25, 0xE5, 0x5F, 0x59, 0x34, 0x0A, 0xF5, 0x3F,
0x95, 0x50, 0x20, 0x30, 0x10, 0x00, 0x01
};
X509_REQ *req = X509_REQ_new();
const unsigned char *p = csr_data;
d2i_X509_REQ(&req, &p, sizeof(csr_data));
// 生成EVP_KEY对象
EVP_PKEY *pkey = X509_REQ_get_pubkey(req);
// 输出EVP_KEY对象
PEM_write_EVP_PUBKEY(stdout, pkey);
// 释放内存
X509_REQ_free(req);
EVP_PKEY_free(pkey);
return 0;
}
```
在运行该程序之前,需要将CSR数据赋值给变量csr_data。程序会输出生成的EVP_KEY对象。
阅读全文