crypto/p256_key_exchange_unittest.cc
// The Verify test takes a public key sample value from the Freenet reference
// implementation with a valid signature and checks that our implementation
// can verify the signature appropriatelly.
The Verify test takes a public key sample value from the Freenet reference
implementation with a valid signature and checks that our implementation
can verify the signature appropriatelly.
The Verify test takes a public key sample value from the Freenet reference implementation with a valid signature and checks that our implementation can verify the signature appropriatelly .
TEST(P256KeyExchange, Verify) {
  const uint8_t sig[] = {
    0x30, 0x45, 0x02, 0x20, 0x6c, 0x0c, 0x5b, 0x93, 0x30, 0xb9, 0x59, 0xf8,
    0xcb, 0x23, 0x38, 0xec, 0x13, 0xc3, 0x51, 0xb9, 0x72, 0x61, 0x14, 0xa9,
    0xc2, 0xf5, 0x59, 0x97, 0x23, 0x09, 0x00, 0x52, 0x57, 0xab, 0x49, 0x22,
    0x02, 0x21, 0x00, 0x95, 0xe3, 0xd4, 0xa1, 0xcd, 0x7e, 0xe3, 0x84, 0x48,
    0x5f, 0x56, 0x23, 0xd3, 0x2b, 0x0b, 0x15, 0x43, 0xce, 0x3a, 0x35, 0x68,
    0xc6, 0xaa, 0x2a, 0xf2, 0x80, 0x0a, 0x0d, 0x22, 0x38, 0xb2, 0x38
  };
  const base::StringPiece public_str(reinterpret_cast<const char *>(public_key),
                                     sizeof(public_key));
  const base::StringPiece signature_str(reinterpret_cast<const char *>(sig),
                                        sizeof(sig));
  ASSERT_TRUE(P256KeyExchange::VerifySignature(public_str, signature_str));
}
TEST ( P256KeyExchange , Verify ) { const uint8_t sig [ ] = { 0x30 , 0x45 , 0x02 , 0x20 , 0x6c , 0x0c , 0x5b , 0x93 , 0x30 , 0xb9 , 0x59 , 0xf8 , 0xcb , 0x23 , 0x38 , 0xec , 0x13 , 0xc3 , 0x51 , 0xb9 , 0x72 , 0x61 , 0x14 , 0xa9 , 0xc2 , 0xf5 , 0x59 , 0x97 , 0x23 , 0x09 , 0x00 , 0x52 , 0x57 , 0xab , 0x49 , 0x22 , 0x02 , 0x21 , 0x00 , 0x95 , 0xe3 , 0xd4 , 0xa1 , 0xcd , 0x7e , 0xe3 , 0x84 , 0x48 , 0x5f , 0x56 , 0x23 , 0xd3 , 0x2b , 0x0b , 0x15 , 0x43 , 0xce , 0x3a , 0x35 , 0x68 , 0xc6 , 0xaa , 0x2a , 0xf2 , 0x80 , 0x0a , 0x0d , 0x22 , 0x38 , 0xb2 , 0x38 } ; const base :: StringPiece public_str ( reinterpret_cast < const char * > ( public_key ) , sizeof ( public_key ) ) ; const base :: StringPiece signature_str ( reinterpret_cast < const char * > ( sig ) , sizeof ( sig ) ) ; ASSERT_TRUE ( P256KeyExchange :: VerifySignature ( public_str , signature_str ) ) ; }
The Verify test takes a public key sample value from the Freenet reference
implementation with a valid signature and checks that our implementation
can verify the signature appropriatelly.
The Verify test takes a public key sample value from the Freenet reference implementation with a valid signature and checks that our implementation can verify the signature appropriatelly .
// Signature in DER export format. // Convert the byte arrays to strings to be able to call VerifySignature() // It must return true, as this is a valid signature from the public key above