MCPcopy Create free account
hub / github.com/Tencent/mars / ECPriKeyToString

Function ECPriKeyToString

mars/openssl/export/crypto/iCoreCrypt.cpp:1345–1365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1343}
1344
1345int ECPriKeyToString(EC_KEY* pPriKey, std::string* pKeyString)
1346{
1347 if(!pKeyString)
1348 {
1349 MMERR("ERR %s invalid",__func__);
1350 return CRYPT_ERR_INVALID_PARAM;
1351 }
1352 int ret = 0;
1353 int r_len = 0;
1354 unsigned char* out =NULL;
1355 r_len = i2d_ECPrivateKey(pPriKey,&out);
1356 if( r_len == 0 || (!out))
1357 {
1358 MMERR("ERR %s seralize key fail.ret %d len %d",__func__,ret,r_len);
1359 if(out) { OPENSSL_free(out),out=NULL;}
1360 return CRYPT_ERR_INVALID_PARAM;
1361 }
1362 pKeyString->assign((const char*)out,r_len);
1363 if(out) { OPENSSL_free(out),out=NULL;}
1364 return CRYPT_OK;
1365}
1366
1367//int ECNewKeyToString(EC_KEY* pPriKey, enECKeyType eType, std::string* pKeyString)
1368//{

Callers 2

ECKeyToStringFunction · 0.85
ComputerEcdhKeyWrapperFunction · 0.85

Calls 1

assignMethod · 0.45

Tested by

no test coverage detected