LCOV - code coverage report
Current view: top level - src/test/fuzz - crypto_aes256.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 14 14
Test Date: 2024-12-04 04:00:22 Functions: 100.0 % 2 2
Branches: 60.0 % 20 12

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-2021 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <crypto/aes.h>
       6                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       7                 :             : #include <test/fuzz/fuzz.h>
       8                 :             : #include <test/fuzz/util.h>
       9                 :             : 
      10                 :             : #include <cassert>
      11                 :             : #include <cstdint>
      12                 :             : #include <vector>
      13                 :             : 
      14         [ +  - ]:         475 : FUZZ_TARGET(crypto_aes256)
      15                 :             : {
      16                 :          63 :     FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
      17                 :          63 :     const std::vector<uint8_t> key = ConsumeFixedLengthByteVector(fuzzed_data_provider, AES256_KEYSIZE);
      18                 :             : 
      19         [ +  - ]:          63 :     AES256Encrypt encrypt{key.data()};
      20         [ +  - ]:          63 :     AES256Decrypt decrypt{key.data()};
      21                 :             : 
      22   [ +  +  +  + ]:       71693 :     LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
      23                 :       71630 :         const std::vector<uint8_t> plaintext = ConsumeFixedLengthByteVector(fuzzed_data_provider, AES_BLOCKSIZE);
      24         [ +  - ]:       71630 :         std::vector<uint8_t> ciphertext(AES_BLOCKSIZE);
      25         [ +  - ]:       71630 :         encrypt.Encrypt(ciphertext.data(), plaintext.data());
      26         [ +  - ]:       71630 :         std::vector<uint8_t> decrypted_plaintext(AES_BLOCKSIZE);
      27         [ +  - ]:       71630 :         decrypt.Decrypt(decrypted_plaintext.data(), ciphertext.data());
      28         [ -  + ]:       71630 :         assert(decrypted_plaintext == plaintext);
      29                 :       71630 :     }
      30                 :          63 : }
        

Generated by: LCOV version 2.0-1