| 1343 | } |
| 1344 | |
| 1345 | int 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 | //{ |
no test coverage detected