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

Function LoadECPubKeyFromString

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

Source from the content-addressed store, hash-verified

1503}
1504
1505int LoadECPubKeyFromString(const std::string& sKeyString,int nid, EC_KEY** ppPriKey)
1506{
1507 if( !ppPriKey)
1508 {
1509 MMERR("ERR %s prikey point null",__func__);
1510 return CRYPT_ERR_INVALID_PARAM;
1511 }
1512 EC_KEY *pPriKey = *ppPriKey;
1513 if( pPriKey )
1514 {
1515 EC_KEY_free(pPriKey);
1516 pPriKey = NULL;
1517 }
1518 *ppPriKey = EC_KEY_new_by_curve_name(nid);
1519 const unsigned char* pcKey = (const unsigned char*)sKeyString.data();
1520 *ppPriKey = o2i_ECPublicKey(ppPriKey,&pcKey,sKeyString.length());
1521 if( !(*ppPriKey))
1522 {
1523 MMERR("ERR %s fail fail",__func__);
1524 if( *ppPriKey) { EC_KEY_free( *ppPriKey);*ppPriKey = NULL;}
1525 return CRYPT_ERR_TRANSFORM_KEY;
1526 }
1527 return CRYPT_OK;
1528}
1529
1530void Free_EC_KEY(EC_KEY**ppKey)
1531{

Callers 2

ComputeECDHKeyFunction · 0.85
ComputerEcdhKeyWrapperFunction · 0.85

Calls 2

dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected