mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanups.
This commit is contained in:
@@ -122,6 +122,7 @@ std::vector<unsigned char> CKey::encryptECIES(CKey& otherKey, const std::vector<
|
|||||||
|
|
||||||
ECIES_ENC_KEY_TYPE secret;
|
ECIES_ENC_KEY_TYPE secret;
|
||||||
ECIES_HMAC_KEY_TYPE hmacKey;
|
ECIES_HMAC_KEY_TYPE hmacKey;
|
||||||
|
|
||||||
getECIESSecret(otherKey, secret, hmacKey);
|
getECIESSecret(otherKey, secret, hmacKey);
|
||||||
ECIES_HMAC_TYPE hmac = makeHMAC(hmacKey, plaintext);
|
ECIES_HMAC_TYPE hmac = makeHMAC(hmacKey, plaintext);
|
||||||
hmacKey.zero();
|
hmacKey.zero();
|
||||||
@@ -169,7 +170,7 @@ std::vector<unsigned char> CKey::encryptECIES(CKey& otherKey, const std::vector<
|
|||||||
if (EVP_EncryptFinal_ex(&ctx, &(out.front()) + len, &bytesWritten) < 0)
|
if (EVP_EncryptFinal_ex(&ctx, &(out.front()) + len, &bytesWritten) < 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
throw std::runtime_error("");
|
throw std::runtime_error("encryption error");
|
||||||
}
|
}
|
||||||
len += bytesWritten;
|
len += bytesWritten;
|
||||||
|
|
||||||
@@ -183,7 +184,6 @@ std::vector<unsigned char> CKey::encryptECIES(CKey& otherKey, const std::vector<
|
|||||||
|
|
||||||
std::vector<unsigned char> CKey::decryptECIES(CKey& otherKey, const std::vector<unsigned char>& ciphertext)
|
std::vector<unsigned char> CKey::decryptECIES(CKey& otherKey, const std::vector<unsigned char>& ciphertext)
|
||||||
{
|
{
|
||||||
|
|
||||||
// minimum ciphertext = IV + HMAC + 1 block
|
// minimum ciphertext = IV + HMAC + 1 block
|
||||||
if (ciphertext.size() < ((2 * ECIES_ENC_BLK_SIZE) + ECIES_HMAC_SIZE) )
|
if (ciphertext.size() < ((2 * ECIES_ENC_BLK_SIZE) + ECIES_HMAC_SIZE) )
|
||||||
throw std::runtime_error("ciphertext too short");
|
throw std::runtime_error("ciphertext too short");
|
||||||
@@ -195,6 +195,7 @@ std::vector<unsigned char> CKey::decryptECIES(CKey& otherKey, const std::vector<
|
|||||||
// begin decrypting
|
// begin decrypting
|
||||||
EVP_CIPHER_CTX ctx;
|
EVP_CIPHER_CTX ctx;
|
||||||
EVP_CIPHER_CTX_init(&ctx);
|
EVP_CIPHER_CTX_init(&ctx);
|
||||||
|
|
||||||
ECIES_ENC_KEY_TYPE secret;
|
ECIES_ENC_KEY_TYPE secret;
|
||||||
ECIES_HMAC_KEY_TYPE hmacKey;
|
ECIES_HMAC_KEY_TYPE hmacKey;
|
||||||
getECIESSecret(otherKey, secret, hmacKey);
|
getECIESSecret(otherKey, secret, hmacKey);
|
||||||
@@ -262,7 +263,7 @@ bool checkECIES(void)
|
|||||||
{
|
{
|
||||||
CKey senderPriv, recipientPriv, senderPub, recipientPub;
|
CKey senderPriv, recipientPriv, senderPub, recipientPub;
|
||||||
|
|
||||||
for(int i=0; i<30000; i++)
|
for(int i = 0; i < 30000; ++i)
|
||||||
{
|
{
|
||||||
if ((i % 100) == 0)
|
if ((i % 100) == 0)
|
||||||
{ // generate new keys every 100 times
|
{ // generate new keys every 100 times
|
||||||
|
|||||||
Reference in New Issue
Block a user