コード例 #1
0
ファイル: bn_sqr.cpp プロジェクト: lanurmi/botan
void fuzz(const uint8_t in[], size_t len)
   {
   if(len > 8192/8)
      return;

   Botan::BigInt x = Botan::BigInt::decode(in, len);

   Botan::BigInt x_sqr = square(x);
   Botan::BigInt x_mul = x * x;

   FUZZER_ASSERT_EQUAL(x_sqr, x_mul);
   }
コード例 #2
0
ファイル: divide.cpp プロジェクト: Hackmanit/botan
void fuzz(const uint8_t in[], size_t len)
   {
   if(len % 2 == 1 || len > 2*4096/8)
      return;

   const Botan::BigInt x = Botan::BigInt::decode(in, len / 2);
   const Botan::BigInt y = Botan::BigInt::decode(in + len / 2, len / 2);

   if(y == 0)
      return;

   Botan::BigInt q, r;
   Botan::divide(x, y, q, r);

   FUZZER_ASSERT_TRUE(r < y);

   Botan::BigInt z = q*y + r;

   FUZZER_ASSERT_EQUAL(z, x);
   }