proxygen
fizz::extensions::test Namespace Reference

Classes

class  TokenBindingClientExtensionTest
 
class  TokenBindingConstructorTest
 
class  TokenBindingServerExtensionTest
 
class  ValidatorTest
 

Functions

 TEST_F (TokenBindingClientExtensionTest, TestValidCheckExtensions)
 
 TEST_F (TokenBindingClientExtensionTest, TestNoExtensions)
 
 TEST_F (TokenBindingClientExtensionTest, TestServerBadKeyParam)
 
 TEST_F (TokenBindingClientExtensionTest, TestServerHigherVersion)
 
 TEST_F (TokenBindingClientExtensionTest, TestServerLowerVersion)
 
 TEST_F (TokenBindingConstructorTest, TestSignAndValidate)
 
 TEST_F (TokenBindingConstructorTest, TestBadEcKey)
 
 TEST_F (TokenBindingServerExtensionTest, TestFullNegotiationFlow)
 
 TEST_F (TokenBindingServerExtensionTest, TestNoExtensions)
 
 TEST_F (TokenBindingServerExtensionTest, TestIncompatibleKeyParam)
 
 TEST_F (TokenBindingServerExtensionTest, TestIncompatibleVersion)
 
 TEST_F (TokenBindingServerExtensionTest, TestServerLowerVersion)
 
 TEST_F (ValidatorTest, TestBadKeySent)
 
 TEST_F (ValidatorTest, TestMismatchKeyParams)
 
 TEST_F (ValidatorTest, TestChromeSignature)
 
 TEST_F (ValidatorTest, TestInvalidSignature)
 
 TEST_F (ValidatorTest, TestTruncatedSignature)
 

Variables

StringPiece ekm
 
StringPiece chrome_session_ekm
 
StringPiece chrome_session_key
 
StringPiece chrome_session_signature
 

Function Documentation

fizz::extensions::test::TEST_F ( TokenBindingClientExtensionTest  ,
TestValidCheckExtensions   
)

Definition at line 41 of file TokenBindingClientExtensionTest.cpp.

References EXPECT_EQ, and EXPECT_TRUE.

41  {
42  setUpServerHelloExtensions(
43  TokenBindingProtocolVersion::token_binding_0_14,
44  TokenBindingKeyParameters::ecdsap256);
45  extensions_->onEncryptedExtensions(serverExtensions_);
46  EXPECT_TRUE(extensions_->getVersion().hasValue());
47  EXPECT_EQ(
48  extensions_->getVersion(),
49  TokenBindingProtocolVersion::token_binding_0_14);
50  EXPECT_TRUE(extensions_->getNegotiatedKeyParam().hasValue());
51  EXPECT_EQ(
52  extensions_->getNegotiatedKeyParam(),
53  TokenBindingKeyParameters::ecdsap256);
54 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::extensions::test::TEST_F ( TokenBindingConstructorTest  ,
TestSignAndValidate   
)

Definition at line 52 of file TokenBindingConstructorTest.cpp.

References ekm, EXPECT_TRUE, and folly::gen::move.

52  {
53  auto ekmBuf = getBuf(ekm);
54  auto binding = TokenBindingConstructor::createTokenBinding(
55  *key_.get(),
56  ekmBuf,
57  TokenBindingKeyParameters::ecdsap256,
58  TokenBindingType::provided_token_binding);
60  Validator::validateTokenBinding(
61  std::move(binding), ekmBuf, TokenBindingKeyParameters::ecdsap256)
62  .hasValue());
63 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::extensions::test::TEST_F ( TokenBindingClientExtensionTest  ,
TestNoExtensions   
)

Definition at line 56 of file TokenBindingClientExtensionTest.cpp.

References EXPECT_FALSE.

56  {
57  extensions_->onEncryptedExtensions(serverExtensions_);
58  EXPECT_FALSE(extensions_->getVersion().hasValue());
59  EXPECT_FALSE(extensions_->getNegotiatedKeyParam().hasValue());
60 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingServerExtensionTest  ,
TestFullNegotiationFlow   
)

Definition at line 60 of file TokenBindingServerExtensionTest.cpp.

References EXPECT_EQ.

60  {
61  setUpTokenBindingWithParameters(
62  TokenBindingProtocolVersion::token_binding_0_14,
63  TokenBindingKeyParameters::ecdsap256);
64  auto exts = extensions_->getExtensions(chlo_);
65  EXPECT_EQ(exts.size(), 1);
66 
67  auto tokenBindingExtension = getExtension<TokenBindingParameters>(exts);
68  verifyExtensionFields(
69  tokenBindingExtension,
70  TokenBindingProtocolVersion::token_binding_0_14,
71  TokenBindingKeyParameters::ecdsap256);
72 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::extensions::test::TEST_F ( TokenBindingClientExtensionTest  ,
TestServerBadKeyParam   
)

Definition at line 62 of file TokenBindingClientExtensionTest.cpp.

References EXPECT_FALSE, and EXPECT_THROW.

62  {
63  setUpServerHelloExtensions(
64  TokenBindingProtocolVersion::token_binding_0_14,
65  TokenBindingKeyParameters::rsa2048_pss);
66  context_->setSupportedVersions(std::vector<TokenBindingProtocolVersion>{
67  TokenBindingProtocolVersion::token_binding_0_12});
68  context_->setSupportedKeyParameters(std::vector<TokenBindingKeyParameters>{
69  TokenBindingKeyParameters::rsa2048_pkcs1_5});
70 
72  extensions_->onEncryptedExtensions(serverExtensions_), FizzException);
73  EXPECT_FALSE(extensions_->getVersion().hasValue());
74  EXPECT_FALSE(extensions_->getNegotiatedKeyParam().hasValue());
75 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingConstructorTest  ,
TestBadEcKey   
)

Definition at line 65 of file TokenBindingConstructorTest.cpp.

References ekm, and EXPECT_THROW.

65  {
66  auto badKey = EvpPkeyUniquePtr(EVP_PKEY_new());
67  auto ekmBuf = getBuf(ekm);
69  TokenBindingConstructor::createTokenBinding(
70  *badKey.get(),
71  ekmBuf,
72  TokenBindingKeyParameters::ecdsap256,
73  TokenBindingType::provided_token_binding),
74  std::runtime_error);
75 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
fizz::extensions::test::TEST_F ( ValidatorTest  ,
TestBadKeySent   
)

Definition at line 67 of file ValidatorTest.cpp.

References EXPECT_FALSE, and folly::gen::move.

67  {
68  StringPiece bad_ecdsa_key{
69  "3060FED4BA255A9D31C961EB74C6356D68C049B8923B41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4461FA6CE669622E60F29FB67903FE1008B8BC99A62299"};
70  auto binding = setUpWithKeyParameters(TokenBindingKeyParameters::ecdsap256);
71 
72  binding.tokenbindingid.key = getBuf(bad_ecdsa_key);
74  Validator::validateTokenBinding(
75  std::move(binding), ekm_, TokenBindingKeyParameters::ecdsap256)
76  .hasValue());
77 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingServerExtensionTest  ,
TestNoExtensions   
)

Definition at line 74 of file TokenBindingServerExtensionTest.cpp.

References EXPECT_EQ.

74  {
75  auto exts = extensions_->getExtensions(chlo_);
76  EXPECT_EQ(exts.size(), 0);
77 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::extensions::test::TEST_F ( TokenBindingClientExtensionTest  ,
TestServerHigherVersion   
)

Definition at line 77 of file TokenBindingClientExtensionTest.cpp.

References EXPECT_FALSE, and EXPECT_THROW.

77  {
78  setUpServerHelloExtensions(
79  TokenBindingProtocolVersion::token_binding_0_14,
80  TokenBindingKeyParameters::ecdsap256);
81  context_->setSupportedVersions(std::vector<TokenBindingProtocolVersion>{
82  TokenBindingProtocolVersion::token_binding_0_12});
83 
85  extensions_->onEncryptedExtensions(serverExtensions_), FizzException);
86  EXPECT_FALSE(extensions_->getVersion().hasValue());
87  EXPECT_FALSE(extensions_->getNegotiatedKeyParam().hasValue());
88 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingServerExtensionTest  ,
TestIncompatibleKeyParam   
)

Definition at line 79 of file TokenBindingServerExtensionTest.cpp.

References EXPECT_EQ, and folly::gen::move.

79  {
80  setUpTokenBindingWithParameters(
81  TokenBindingProtocolVersion::token_binding_0_14,
82  TokenBindingKeyParameters::ecdsap256);
83  std::vector<TokenBindingKeyParameters> keyParams = {
84  TokenBindingKeyParameters::rsa2048_pss};
85 
86  tokenBindingContext_->setSupportedKeyParameters(std::move(keyParams));
87  auto exts = extensions_->getExtensions(chlo_);
88  EXPECT_EQ(exts.size(), 0);
89 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::extensions::test::TEST_F ( ValidatorTest  ,
TestMismatchKeyParams   
)

Definition at line 79 of file ValidatorTest.cpp.

References EXPECT_FALSE, and folly::gen::move.

79  {
80  auto binding = setUpWithKeyParameters(TokenBindingKeyParameters::ecdsap256);
82  Validator::validateTokenBinding(
83  std::move(binding), ekm_, TokenBindingKeyParameters::rsa2048_pss)
84  .hasValue());
85 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( ValidatorTest  ,
TestChromeSignature   
)

Definition at line 87 of file ValidatorTest.cpp.

References EXPECT_TRUE, and folly::gen::move.

87  {
88  auto binding = setUpWithKeyParameters(TokenBindingKeyParameters::ecdsap256);
90  Validator::validateTokenBinding(
91  std::move(binding), ekm_, TokenBindingKeyParameters::ecdsap256)
92  .hasValue());
93 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::extensions::test::TEST_F ( TokenBindingClientExtensionTest  ,
TestServerLowerVersion   
)

Definition at line 90 of file TokenBindingClientExtensionTest.cpp.

References EXPECT_FALSE.

90  {
91  setUpServerHelloExtensions(
92  TokenBindingProtocolVersion::token_binding_0_12,
93  TokenBindingKeyParameters::ecdsap256);
94  context_->setSupportedVersions(std::vector<TokenBindingProtocolVersion>{
95  TokenBindingProtocolVersion::token_binding_0_14});
96 
97  extensions_->onEncryptedExtensions(serverExtensions_);
98  EXPECT_FALSE(extensions_->getVersion().hasValue());
99  EXPECT_FALSE(extensions_->getNegotiatedKeyParam().hasValue());
100 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingServerExtensionTest  ,
TestIncompatibleVersion   
)

Definition at line 91 of file TokenBindingServerExtensionTest.cpp.

References EXPECT_EQ.

91  {
92  setUpTokenBindingWithParameters(
93  TokenBindingProtocolVersion::token_binding_0_13,
94  TokenBindingKeyParameters::ecdsap256);
95 
96  auto exts = extensions_->getExtensions(chlo_);
97  EXPECT_EQ(exts.size(), 0);
98 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::extensions::test::TEST_F ( ValidatorTest  ,
TestInvalidSignature   
)

Definition at line 95 of file ValidatorTest.cpp.

References EXPECT_FALSE, and folly::gen::move.

95  {
96  auto binding = setUpWithKeyParameters(TokenBindingKeyParameters::ecdsap256);
97  *binding.signature->writableData() ^= 0x04;
99  Validator::validateTokenBinding(
100  std::move(binding), ekm_, TokenBindingKeyParameters::ecdsap256)
101  .hasValue());
102 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::extensions::test::TEST_F ( TokenBindingServerExtensionTest  ,
TestServerLowerVersion   
)

Definition at line 100 of file TokenBindingServerExtensionTest.cpp.

References EXPECT_EQ, and folly::gen::move.

100  {
101  setUpTokenBindingWithParameters(
102  TokenBindingProtocolVersion::token_binding_0_14,
103  TokenBindingKeyParameters::ecdsap256);
104  std::vector<TokenBindingProtocolVersion> versions = {
105  TokenBindingProtocolVersion::token_binding_0_13};
106 
107  tokenBindingContext_->setSupportedVersions(std::move(versions));
108  auto exts = extensions_->getExtensions(chlo_);
109  EXPECT_EQ(exts.size(), 1);
110 
111  auto tokenBindingExtension = getExtension<TokenBindingParameters>(exts);
112  verifyExtensionFields(
113  tokenBindingExtension,
114  TokenBindingProtocolVersion::token_binding_0_13,
115  TokenBindingKeyParameters::ecdsap256);
116 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::extensions::test::TEST_F ( ValidatorTest  ,
TestTruncatedSignature   
)

Definition at line 104 of file ValidatorTest.cpp.

References EXPECT_FALSE, and folly::gen::move.

104  {
105  auto binding = setUpWithKeyParameters(TokenBindingKeyParameters::ecdsap256);
106  binding.signature->trimEnd(4);
107  EXPECT_FALSE(
108  Validator::validateTokenBinding(
109  std::move(binding), ekm_, TokenBindingKeyParameters::ecdsap256)
110  .hasValue());
111 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862

Variable Documentation

StringPiece fizz::extensions::test::chrome_session_ekm
Initial value:
{
"9d20b2acf86f893a240642593cfc53102b9fb76b37f059d4bff47a0e6fee25e7"}

Definition at line 27 of file ValidatorTest.cpp.

Referenced by fizz::extensions::test::ValidatorTest::SetUp().

StringPiece fizz::extensions::test::chrome_session_key
Initial value:
{
"40dd2fa2430a0f54ca96454bdf23c264353a252812bc5fa7b851a6fa9d620424bf43e20e50a4ca0a1769f4024db346ca5075eecdb7f62d0018cf1642b75f679d98"}

Definition at line 29 of file ValidatorTest.cpp.

Referenced by fizz::extensions::test::ValidatorTest::setUpWithKeyParameters().

StringPiece fizz::extensions::test::chrome_session_signature
Initial value:
{
"d2c9c04957013f38369a18a5d5b47d6492f0f0f5c8772a27cc3770f23dda94d30fc3a6d0dc110c78e668a44c3b8b61842a6e72795f61f51f398f8dedd2ceb9a3"}

Definition at line 31 of file ValidatorTest.cpp.

Referenced by fizz::extensions::test::ValidatorTest::setUpWithKeyParameters().

StringPiece fizz::extensions::test::ekm
Initial value:
{
"1234567890012345689012345678901234567890123456789012345678901234"}

Definition at line 24 of file TokenBindingConstructorTest.cpp.

Referenced by proxygen::HTTPSession::getCertAuthSettingVal(), fizz::test::TEST(), TEST_F(), and proxygen::HTTPSession::verifyCertAuthSetting().