guanzhi / GmSSL

支持国密SM2/SM3/SM4/SM9/SSL的密码工具箱
http://gmssl.org
Apache License 2.0
5.19k stars 1.67k forks source link

version 2.0 SM9_extract_private_key return NULL #434

Closed kevinhewanjun closed 3 years ago

kevinhewanjun commented 6 years ago

hi,完全copy官网的代码测试SM9功能,在keygen的时候返回NULL,希望得到帮助,谢谢!

<<<<<<<<<<<<<<< int testSM9() { int err = 1; int curve_id = NID_sm2p256v1; //FIXME //int curve_id = NID_sm2sign; char id = "guanzhi1980@gmail.com"; char in = "message to be signed or encrypted"; SM9PublicParameters mpk = NULL; SM9MasterSecret msk = NULL; SM9PrivateKey sk = NULL; unsigned char dgst[32] = { 0x01, 0x00 }; unsigned char c = NULL; unsigned char m = NULL; unsigned char sig = NULL; size_t clen, mlen, siglen;

/* setup */
if (!SM9_setup_by_pairing_name(curve_id, SM9_HID_SIGN, &mpk, &msk)) {
    goto end;
}

/* keygen */
if (!(sk = SM9_extract_private_key(mpk, msk, id, strlen(id)))) {
    goto end;
}

<<<<<<<<<<<<<<<<<<

出错的地方sm9_keygen.c文件中位置: <<<<<<<<<<<<<<<

/* EC_GROUP */
if (!(group = EC_GROUP_new_type1curve_ex(mpk->p,
    mpk->a, mpk->b, mpk->pointP1->data, mpk->pointP1->length,
    mpk->order, mpk->cofactor, bn_ctx))) {
    SM9err(SM9_F_SM9_EXTRACT_PRIVATE_KEY, SM9_R_INVALID_TYPE1CURVE);
    goto end;
}

<<<<<<<<<<<<<<<

guanzhi commented 6 years ago

SM9尚未正式支持!敬请期待

kevinhewanjun commented 6 years ago

好的,谢谢你们无私的奉献

chengfang0911 commented 6 years ago

@guanzhi guan老师,请问sm9什么时候能正式支持?

guanzhi commented 6 years ago

主分支已经全面支持SM9的全部算法和推荐参数

kevinhe79 commented 6 years ago

谢谢你们无私的奉献

github-actions[bot] commented 4 years ago

Marked as stale issue. Will be closed later if no activity for a while.