/* * NIST keywrap example * (C) 2011 Jack Lloyd * * Distributed under the terms of the Botan license */ #include #include #include #include int main() { using namespace Botan; LibraryInitializer init; AutoSeeded_RNG rng; // The key to encrypt SymmetricKey key(rng, 24); // The key encryption key SymmetricKey kek(rng, 32); std::cout << "Original: " << key.as_string() << "\n"; Algorithm_Factory& af = global_state().algorithm_factory(); SecureVector enc = rfc3394_keywrap(key.bits_of(), kek, af); std::cout << "Encrypted: " << hex_encode(enc) << "\n"; SecureVector dec = rfc3394_keyunwrap(enc, kek, af); std::cout << "Decrypted: " << hex_encode(dec) << "\n"; }