// Copyright (c) 2020 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include FUZZ_TARGET(crypto_aes256) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; const std::vector key = ConsumeFixedLengthByteVector(fuzzed_data_provider, AES256_KEYSIZE); AES256Encrypt encrypt{key.data()}; AES256Decrypt decrypt{key.data()}; LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { const std::vector plaintext = ConsumeFixedLengthByteVector(fuzzed_data_provider, AES_BLOCKSIZE); std::vector ciphertext(AES_BLOCKSIZE); encrypt.Encrypt(ciphertext.data(), plaintext.data()); std::vector decrypted_plaintext(AES_BLOCKSIZE); decrypt.Decrypt(decrypted_plaintext.data(), ciphertext.data()); assert(decrypted_plaintext == plaintext); } }