Browse Source

ECICS gerenarate keys

pull/986/head
orignal 7 years ago
parent
commit
00bbb81375
  1. 13
      libi2pd/Crypto.cpp
  2. 1
      libi2pd/Crypto.h

13
libi2pd/Crypto.cpp

@ -460,6 +460,19 @@ namespace crypto @@ -460,6 +460,19 @@ namespace crypto
return ret;
}
void GenerateECICSKeyPair (const EC_GROUP * curve, BIGNUM *& priv, EC_POINT *& pub)
{
BN_CTX * ctx = BN_CTX_new ();
BIGNUM * q = BN_new ();
EC_GROUP_get_order(curve, q, ctx);
priv = BN_new ();
BN_rand_range (priv, q);
pub = EC_POINT_new (curve);
EC_POINT_mul (curve, pub, priv, nullptr, nullptr, ctx);
BN_free (q);
BN_CTX_free (ctx);
}
// HMAC
const uint64_t IPAD = 0x3636363636363636;
const uint64_t OPAD = 0x5C5C5C5C5C5C5C5C;

1
libi2pd/Crypto.h

@ -55,6 +55,7 @@ namespace crypto @@ -55,6 +55,7 @@ namespace crypto
// ECICS
void ECICSEncrypt (const EC_GROUP * curve, const EC_POINT * key, const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx); // 222 bytes data, 512 bytes encrypted
bool ECICSDecrypt (const EC_GROUP * curve, const BIGNUM * key, const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx);
void GenerateECICSKeyPair (const EC_GROUP * curve, BIGNUM *& priv, EC_POINT *& pub);
// HMAC
typedef i2p::data::Tag<32> MACKey;

Loading…
Cancel
Save