生成密钥对:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "e_os.h"
#include "sm2ToOC.h"
#include "string.h"
# include <openssl/bn.h>
# include <openssl/ec.h>
# include <openssl/evp.h>
# include <openssl/rand.h>
# include <openssl/engine.h>
# include <openssl/sm2.h>
# include "sm2_lcl.h"
# include "pkcs12.h"
#include <openssl/pem.h>
#include "ec/ec_lcl.h"
#include "bn/bn_lcl.h"
int genkey()
{
EC_KEY *keypair = NULL;
EC_GROUP *group1 = NULL;
keypair = EC_KEY_new();
if(!keypair) {
printf("Failed to Gen Key");
exit(1);
}
group1 = EC_GROUP_new_by_curve_name(NID_sm2p256v1