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

Function ComputerEcdhKeyWrapper

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

Source from the content-addressed store, hash-verified

1537}
1538
1539int ComputerEcdhKeyWrapper(int nid,const std::string& sPubKey1, std::string* sPubKey2, std::string* sPriKey2, std::string* sEcdhKey)
1540{
1541 EC_KEY* pCliPubKey= NULL;
1542 int ret = Comm::LoadECPubKeyFromString(sPubKey1,nid,&pCliPubKey);
1543 if( CRYPT_OK != ret || !pCliPubKey )
1544 {
1545 MMERR("ERR %s load ec pubkey fail.nid %u ret %d",__func__,nid,ret);
1546 Free_EC_KEY(&pCliPubKey);
1547 return ret;
1548 }
1549
1550 EC_KEY* pPriKey2 = GenerateECKey(nid);
1551 if( !pPriKey2 )
1552 {
1553 MMERR("ERR %s generater ec key fail. nid %d",__func__,nid);
1554 Free_EC_KEY(&pCliPubKey);
1555 return CRYPT_ERR_INVALID_PARAM;
1556 }
1557
1558 ret = ComputeECDHKey(pCliPubKey, pPriKey2, sEcdhKey, eECDH_KDF_MD5);
1559 if( CRYPT_OK != ret)
1560 {
1561 MMERR("ERR %s computer ecdh key fail.ret %d",__func__,ret);
1562 Free_EC_KEY(&pCliPubKey);
1563 Free_EC_KEY(&pPriKey2);
1564 return ret;
1565 }
1566 ret = ECPriKeyToString(pPriKey2,sPriKey2);
1567 if( CRYPT_OK != ret)
1568 {
1569 MMERR("ERR %s pri key to string fail.ret %d",__func__,ret);
1570 Free_EC_KEY(&pCliPubKey);
1571 Free_EC_KEY(&pPriKey2);
1572 return ret;
1573 }
1574 ret = ECPubKeyToString(pPriKey2,sPubKey2);
1575 if( CRYPT_OK != ret)
1576 {
1577 Free_EC_KEY(&pCliPubKey);
1578 Free_EC_KEY(&pPriKey2);
1579 MMERR("ERR %s pub key to string fail.ret %d",__func__,ret);
1580 return ret;
1581 }
1582 Free_EC_KEY(&pCliPubKey);
1583 Free_EC_KEY(&pPriKey2);
1584 return CRYPT_OK;
1585}
1586
1587unsigned int GenSignature(unsigned int iUin, const std::string &sEcdhKey, const unsigned char *pcBuff, unsigned int iBuffLen)
1588{

Callers

nothing calls this directly

Calls 6

LoadECPubKeyFromStringFunction · 0.85
Free_EC_KEYFunction · 0.85
GenerateECKeyFunction · 0.85
ComputeECDHKeyFunction · 0.85
ECPriKeyToStringFunction · 0.85
ECPubKeyToStringFunction · 0.85

Tested by

no test coverage detected