Ejemplo n.º 1
0
static void
generateRsaKeys(Blob& encryptionKeyBlob, Blob& decryptionKeyBlob)
{
  RsaKeyParams params;
  DecryptKey decryptKey = RsaAlgorithm::generateKey(params);
  decryptionKeyBlob = decryptKey.getKeyBits();
  EncryptKey encryptKey = RsaAlgorithm::deriveEncryptKey(decryptionKeyBlob);
  encryptionKeyBlob = encryptKey.getKeyBits();
}
Ejemplo n.º 2
0
static void
generateAesKeys(Blob& encryptionKeyBlob, Blob& decryptionKeyBlob)
{
  AesKeyParams params;
  DecryptKey memberDecryptKey = AesAlgorithm::generateKey(params);
  decryptionKeyBlob = memberDecryptKey.getKeyBits();
  EncryptKey memberEncryptKey = AesAlgorithm::deriveEncryptKey(decryptionKeyBlob);
  encryptionKeyBlob = memberEncryptKey.getKeyBits();
}
Ejemplo n.º 3
0
void
GroupManager::generateKeyPair(Blob& privateKeyBlob, Blob& publicKeyBlob)
{
  RsaKeyParams params(keySize_);

  DecryptKey privateKey = RsaAlgorithm::generateKey(params);
  privateKeyBlob = privateKey.getKeyBits();

  EncryptKey publicKey = RsaAlgorithm::deriveEncryptKey(privateKeyBlob);
  publicKeyBlob = publicKey.getKeyBits();
}
Ejemplo n.º 4
0
TEST_F(TestAesAlgorithm, KeyGeneration)
{
  AesKeyParams keyParams(128);
  DecryptKey decryptKey = AesAlgorithm::generateKey(keyParams);
  EncryptKey encryptKey = AesAlgorithm::deriveEncryptKey(decryptKey.getKeyBits());

  Blob plainBlob(PLAINTEXT, sizeof(PLAINTEXT));

  // Encrypt/decrypt data in AES_CBC with auto-generated IV.
  EncryptParams encryptParams(ndn_EncryptAlgorithmType_AesCbc, 16);
  Blob cipherBlob = AesAlgorithm::encrypt
    (encryptKey.getKeyBits(), plainBlob, encryptParams);
  Blob receivedBlob = AesAlgorithm::decrypt
    (decryptKey.getKeyBits(), cipherBlob, encryptParams);
  ASSERT_TRUE(receivedBlob.equals(plainBlob));
}