spank-olm

WIP Do not look
git clone git://archive.git.mtrnord.blog/MTRNord/spank-olm.git
Log | Files | Refs | README | LICENSE

olm_sign_fuzzer.cpp (780B)


      1 #include <botan/auto_rng.h>
      2 #include <cassert>
      3 #include <cstddef>
      4 #include <cstdint>
      5 #include "account.hpp"
      6 #include "botan/pubkey.h"
      7 
      8 // Just needed for compiling reasons
      9 extern "C" int LLVMFuzzerInitialize() { return 0; }
     10 
     11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
     12 {
     13     if (Size == 0)
     14     {
     15         return -1;
     16     }
     17 
     18     spank_olm::Account account;
     19     Botan::AutoSeeded_RNG rng;
     20     account.new_account(rng);
     21 
     22     const std::string_view message(reinterpret_cast<const char *>(Data), Size);
     23     auto signature = account.sign(rng, message);
     24 
     25     // Verify the signature
     26     Botan::PK_Verifier verifier(account.identity_keys->ed25519_key, "Ed25519ph");
     27     verifier.update(message);
     28     assert(verifier.check_signature(signature));
     29 
     30     return 0;
     31 }