91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2021-05-13
  • 語言: 其他
  • 標簽: gmssl??sm2??sm3??

資源簡介

在GmSSL 2.0 - OpenSSL 1.1.0d 26 Jan 2017 版本上,編寫的sm2 加解密 ,簽名驗簽,sm3摘要的測試程序

資源截圖

代碼片段和文件信息

/*
update?time?:?
author?:?create?by?helloworld
need:???GmSSL?2.0?-?OpenSSL?1.1.0d??26?Jan?2017
*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?



#define?ERROR(...)?\
do{?\
????fprintf(stderr?“[ERROR??]%s?%s(Line?%d):?“__FILE____FUNCTION____LINE__);?\
????fprintf(stderr?__VA_ARGS__);?\
????printf(“\n“);?\
}while(0)?;

#define?INFO(...)?\
do{?\
????fprintf(stdout?“[INFO??]%s?%s(Line?%d):?“__FILE____FUNCTION____LINE__);?\
????fprintf(stdout?__VA_ARGS__);?\
????printf(“\n“);?\
}while(0)?;


void?print_arr(const?char?*string?unsigned?char*data?int?size)
{
int?i;

printf(“---------------------------------------------\n“);
printf(“%s?len=%d\n“?stringsize);
for(i=0;?i {
printf(“%02x?“?data[i]);
if((i%16)?==?15)
printf(“\n“);
}
if(size%16)
printf(“\n“);
printf(“---------------------------------------------\n“);
}


BIO?*bio_err?;
BIO?*bio_stdout?;

?char?g_pubkey[]?=?““
“-----BEGIN?PUBLIC?KEY-----\r\n“
“MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEu4kSnox0T5SND9KGGlpTvcQ5hiz0\r\n“
“Wm7kigVRTEc0+5wrSoyvnZYuYKLFSSzK2ZbMH+etX7UeRSiPplD63fChNw==\r\n“
“-----END?PUBLIC?KEY-----\r\n“
““;

?char?g_prikey[]?=?““
“-----BEGIN?PRIVATE?KEY-----\r\n“
“MIGHAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBG0wawIBAQQgQnx5UCnYOJv558pc\r\n“
“rU9mgorePGbbF8/JxsR9N8LrKAmhRANCAAS7iRKejHRPlI0P0oYaWlO9xDmGLPRa\r\n“
“buSKBVFMRzT7nCtKjK+dli5gosVJLMrZlswf561ftR5FKI+mUPrd8KE3\r\n“
“-----END?PRIVATE?KEY-----\r\n“
““;





static?EVP_PKEY?*getPEMPublicKeyFromBuf(const?char*?bufsize_t?len)
{
EVP_PKEY?*pkey?=?NULL;
BIO*?key?=?NULL;
key?=?BIO_new(BIO_s_mem());
BIO_write(keybuflen);
BIO_seek(key0);
pkey?=?PEM_read_bio_PUBKEY(key?NULL?0?NULL);
BIO_free(key);
return?pkey;
}

static?EVP_PKEY?*getPEMPrivateKeyFromBuf(const?char*?bufsize_t?len)
{
EVP_PKEY?*pkey?=?NULL;
BIO*?key?=?NULL;
key?=?BIO_new(BIO_s_mem());
BIO_write(keybuflen);
BIO_seek(key0);
pkey?=?PEM_read_bio_PrivateKey(key?NULL?0?NULL);
BIO_free(key);
return?pkey;
}

static?int?test_sm2_encrypt(EVP_PKEY?*pkey?unsigned?char?*cbuf?size_t?buflenunsigned?char?*?out?size_t*?poutlen)
{
int?ret?=?0;

if(SM2_encrypt_with_recommended(cbuf?buflen?out?poutlen?EVP_PKEY_get0_EC_KEY(pkey))?!=?1){
ERR_print_errors_fp(stderr);
printf(“SM2_encrypt_with_recommended?failed?\n“);
ret?=?-1;?goto?end;
}
size_t?i;
printf(“ciphertext?(%d?bytes)?=?\n“?*poutlen);
for?(i?=?0;?i? printf(“%02X?“?out[i]);
if(i?%?16?==?15){
printf(“\n“);
}
}
printf(“\n“);


ret?=?1;
end:

return?ret;
}

static?int?test_sm2_decrypt(EVP_PKEY?*pkey?unsigned?char?*cbuf?size_t?cbuflen)
{
int?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????6868??2018-12-14?16:57??test-gmssl.cpp

評論

共有 條評論