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(); }
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(); }
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(); }
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)); }