EVP_PKEY_CTX *openssl_ctx = NULL;
openssl_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_ED25519, NULL);
if (NULL == openssl_ctx)
{
printf("New Key fail...\n");
goto cleanup;
}
if (EVP_PKEY_keygen_init(openssl_ctx)<=0)
{
printf("EVP_PKEY_keygen_init fail\n");
goto cleanup;
}
if (EVP_PKEY_keygen(openssl_ctx, ppKey)<=0)
{
printf("EVP_PKEY_kengen fail\n");
goto cleanup;
}
ret = ERR_OK;
unsigned char sk[2048], pk[2048];[enter image description here][1]
size_t skLen, pkLen;
if (1 != EVP_PKEY_get_raw_public_key(*ppKey, pk, &pkLen))
{
printf("EVP_PKEY_get_raw_public_key fail");
char *errStr;
int line;
unsigned long err = ERR_get_error_line((const char **)&errStr, &line);
printf("show me the error: %lu, %s:%i\n", err, errStr, line);
}
int p = EVP_PKEY_get_raw_private_key(*ppKey, sk, &skLen);
if (p != 1)
{
printf("EVP_PKEY_get_raw_private_key fail\n");
char *errStr;
int line;
unsigned long err = ERR_get_error_line((const char **)&errStr, &line);
printf("show me the error: %lu, %s:%i\n", err, errStr, line);
}
我想从 EVP_PKEY 导出 ed25519 的私钥和公钥,当我同时使用 EVP_PKEY_get_raw_public_key() 和 EVP_PKEY_get_raw_private_key() 时,它返回错误:EVP_PKEY_get_raw_public_key failshow me the error: 101494966, ../crypto/evp/p_lib.c: 310
但是当我只使用 EVP_PKEY_get_raw_public_key() 或 EVP_PKEY_get_raw_private_key() 时,它不会报告任何错误。EVP_PKEY_get_raw_public_key() 是否与 EVP_PKEY_get_raw_private_key() 不兼容?