decryptor for ECIES-X25519-AEAD-Ratchet

This commit is contained in:
orignal 2019-12-11 13:38:36 -05:00
parent 9ed58e5186
commit 553d59c32b
4 changed files with 43 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#include <string.h>
#include "Log.h"
#include "Gost.h"
#include "Elligator.h"
#include "CryptoKey.h"
namespace i2p
@ -146,6 +147,22 @@ namespace crypto
BN_free (x); BN_free (y);
}
bool ECIESX25519AEADRatchetDecryptor::Decrypt (const uint8_t * epub, uint8_t * keyMaterial, BN_CTX * ctx, bool zeroPadding)
{
uint8_t key[32];
if (!GetElligator ()->Decode (epub, key)) return false;
m_StaticKeys.Agree (key, keyMaterial);
return true;
}
void CreateECIESX25519AEADRatchetRandomKeys (uint8_t * priv, uint8_t * pub)
{
X25519Keys k;
k.GenerateKeys ();
k.GetPrivateKey (priv);
memcpy (pub, k.GetPublicKey (), 32);
}
}
}