proxygen
fizz::test Namespace Reference

Classes

struct  A1
 
struct  A2
 
class  ActionMoveVisitor
 
class  AsyncFizzBaseTest
 
class  AuthenticatorTest
 
struct  BlockWriter
 
struct  CertAndKey
 
class  CertDecompressionManagerTest
 
class  CertTestTyped
 
struct  CipherParams
 
class  ConcreteReadRecordLayer
 
class  ConcreteWriteRecordLayer
 
class  DefaultCertificateVerifierTest
 
class  ECDHTest
 
class  EncryptedRecordTest
 
struct  ExpectedParameters
 
class  ExtensionsTest
 
class  FizzBaseTest
 
class  HandshakeContextTest
 
class  HandshakeTest
 
class  HandshakeTypesTest
 
struct  HashParams
 
class  HkdfTest
 
class  Key
 
struct  KeyParams
 
class  KeySchedulerTest
 
class  LocalTransport
 
class  MockAead
 
class  MockAsyncFizzBase
 
class  MockCert
 
class  MockCertificateCompressor
 
class  MockCertificateDecompressor
 
class  MockCertificateVerifier
 
class  MockFactory
 
class  MockHandshakeContext
 
class  MockKeyScheduler
 
class  MockPeerCert
 
class  MockSelfCert
 
class  OpenSSLEVPCipherTest
 
struct  P256Test
 
struct  P384Test
 
struct  P521Test
 
struct  Params
 
class  PlaintextRecordTest
 
class  ProtocolTest
 
class  RecordTest
 
class  RSAPSSTest
 
struct  RSATest
 
class  SigSchemeTest
 
struct  State
 
class  TestFizzBase
 
struct  TestMessages
 
class  TestStateMachine
 
class  ValidateAuthenticatorTest
 
class  ZlibCertificateCompressorTest
 

Typedefs

using BufCreator = std::function< std::unique_ptr< folly::IOBuf >(size_t len, size_t bufNum)>
 
using KeyTypes = ::testing::Types< P256, P384, P521 >
 
using Action = boost::variant< A1, A2 >
 
using Actions = std::vector< Action >
 

Enumerations

enum  StateEnum { StateEnum::NotError, StateEnum::Error }
 

Functions

 TEST (IOBufUtilTest, TrimBytes)
 
 TEST (IOBufUtilTest, TransformBufferInplace)
 
std::unique_ptr< IOBufcreateBuf (size_t len)
 
 TEST (IOBufUtilTest, TransformBufferWithFragmentedBuffer)
 
 TEST (IOBufUtilTest, TransformBufferBlocks)
 
 TEST (IOBufUtilTest, TransformBufferBlocksSplit)
 
 TEST (IOBufUtilTest, TransformBufferBlocksInputFragmented)
 
 TEST (IOBufUtilTest, TransformBufferBlocksOutputFragmented)
 
 TEST (IOBufUtilTest, TransformBufferBlocksInputFragmented2)
 
 TEST (IOBufUtilTest, TransformBufferBlocksFragmented)
 
std::unique_ptr< AeadgetCipher (const CipherParams &params)
 
std::unique_ptr< IOBufcopyBuffer (const folly::IOBuf &buf)
 
std::unique_ptr< folly::IOBufcallEncrypt (std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
 
void callDecrypt (std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncrypt)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptWithTagRoom)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptReusedCipher)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptChunkedInput)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptChunkedInputWithTagRoomHead)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptChunkedInputWithTagRoomLast)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptChunkedSharedInput)
 
 TEST_P (OpenSSLEVPCipherTest, TestEncryptChunkedAad)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecrypt)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptReusedCipher)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptInputTooSmall)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptWithChunkedInput)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptWithChunkedSharedInput)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptWithVeryChunkedInput)
 
 TEST_P (OpenSSLEVPCipherTest, TestDecryptWithChunkedAad)
 
 TEST_P (OpenSSLEVPCipherTest, TestTryDecrypt)
 
 INSTANTIATE_TEST_CASE_P (AESGCM128TestVectors, OpenSSLEVPCipherTest,::testing::Values(CipherParams{"87f6c12b1ae8a9b7efafc65af0f5c994","479e25839c19e0476f95a6f5", 1,"","010015","9d4db5ecd768198892531eebac72cf1d477dd0", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"911dc107aa6eccb6706bdcc37e76a07a","11c7fa13e9499ed042b09e57", 0,"","14000020de15cbc8c62d0e6fef73a6d4e70e5c372c2b94fe08ea40d11166a7e6c967ba9c16","56a21739148c898fe807026a179d59202647a3b1e01267a3883cf5f69fd233f63ff12c1c71b4c8f3d6086affb49621f96b842e1d35", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cae6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec5c241e994fb7d889e1b61d1db2b9be6777f5a393", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"fda2a4404670808f4937478b8b6e3fe1","b5f3a3fae1cb25c9dcd73993", 0,"","0800001e001c000a00140012001d00170018001901000101010201030104000000000b0001b9000001b50001b0308201ac30820115a003020102020102300d06092a864886f70d01010b0500300e310c300a06035504031303727361301e170d3136303733303031323335395a170d3236303733303031323335395a300e310c300a0603550403130372736130819f300d06092a864886f70d010101050003818d0030818902818100b4bb498f8279303d980836399b36c6988c0c68de55e1bdb826d3901a2461eafd2de49a91d015abbc9a95137ace6c1af19eaa6af98c7ced43120998e187a80ee0ccb0524b1b018c3e0b63264d449a6d38e22a5fda430846748030530ef0461c8ca9d9efbfae8ea6d1d03e2bd193eff0ab9a8002c47428a6d35a8d88d79f7f1e3f0203010001a31a301830090603551d1304023000300b0603551d0f0404030205a0300d06092a864886f70d01010b05000381810085aad2a0e5b9276b908c65f73a7267170618a54c5f8a7b337d2df7a594365417f2eae8f8a58c8f8172f9319cf36b7fd6c55b80f21a03015156726096fd335e5e67f2dbf102702e608ccae6bec1fc63a42a99be5c3eb7107c3c54e9b9eb2bd5203b1c3b84e0a8b2f759409ba3eac9d91d402dcc0cc8f8961229ac9187b42b4de100000f000084080400804547d6168f2510c550bd949cd2bc631ff134fa10a827ff69b166a6bd95e249ed0daf571592ebbe9ff13de6b03acc218146781f693b5a692b7319d74fd2e53b6a2df0f6785d624f024a44030ca00b869ae81a532b19e47e525ff4a62c51a5889eb565fee268590d8a3ca3c1bc3bd5404e39720ca2eaee308f4e0700761e986389140000209efee03ebffbc0dc23d26d958744c09e3000477eff7ae3148a50e5670013aaaa16","c1e631f81d2af221ebb6a957f58f3ee266272635e67f99a752f0df08adeb33bab8611e55f33d72cf84382461a8bfe0a659ba2dd1873f6fcc707a9841cefc1fb03526b9ca4fe343e5805e95a5c01e56570638a76a4bc8feb07be879f90568617d905fecd5b1619fb8ec4a6628d1bb2bb224c490ff97a6c0e9acd03604bc3a59d86bdab4e084c1c1450f9c9d2afeb172c07234d739868ebd62de2060a8de989414a82920dacd1cac0c6e72ecd7f4018574ceaca6d29f361bc37ee2888b8e302ca9561a9de9163edfa66badd4894884c7b359bcacae5908051b37952e10a45fe73fda126ebd67575f1bed8a992a89474d7dec1eed327824123a414adb66d5ef7d0836ff98c2cdd7fb0781e192bf0c7568bf7d890a51c332879b5037b212d622412ca48e8323817bd6d746eef683845cec4e3ef64b3a18fcce513ea951f3366693a7ff490d09d08ab1f63e13625a545961599c0d9c7a099d1163cad1b9bcf8e917d766b98853ef6877834f891df16be1fcc9c18ea1882ea3f1f4b64358e1b146cebfb3e02e153fdb73af2693f22c6f593fa475380ba6611740ad20e319a654ac5684775236162e8447ed808861bfbda6e18ec97ae090bf703475cfb90fe20a3c55bef6f5eba6e6a1da6a1996b8bde42180608ca2279def8e8153895cc850db6420561c04b5729cc6883436ea02ee07eb9baee2fb3a9e1bbda8730d6b220576e24df70af6928eb865fee8a1d1c0f1818aca68d5002ae4c65b2f49c9e6e21dcf76784adbd0e887a36832ef85beb10587f16c6ffe60d7451059ec7f1014c3efe19e56aedb5ad31a9f29dc4458cfbf0c7070c175dcad46e1675226b47c071aad3172ebd33e45d741cb91253a01a69ae3cc292bce9c03246ac951e45e97ebf04a9d51fab5cf06d9485cce746b1c077be69ad153f1656ef89fc7d1ed8c3e2da7a2", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cbe6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec5c241e994fb7d889e1b61d1db2b9be6777f5a393", false, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cae6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec", false, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"AD7A2BD03EAC835A6F620FDCB506B345","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","701AFA1CC039C0D765128A665DAB69243899BF7318CCDC81C9931DA17FBE8EDD7D17CB8B4C26FC81E3284F2B7FBA713D4F8D55E7D3F06FD5A13C0C29B9D5B880", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"AD7A2BD03EAC835A6F620FDCB506B345","12153524C0895E81B2C28465", 0,"D609B1F056637A1D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","701AFA1CC039C0D765128A665DAB69243899BF7318CCDC81C9931DA17FBE8EDD7D17CB8B4C26FC81E3284F2B7FBA713D4F8D55E7D3F06FD5A13C0C29B9D5B880", false, CipherSuite::TLS_AES_128_GCM_SHA256}))
 
 INSTANTIATE_TEST_CASE_P (AESGCM256TestVectors, OpenSSLEVPCipherTest,::testing::Values(CipherParams{"E3C08A8F06C6E3AD95A70557B23F75483CE33021A9C72B7025666204C69C0B72","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","E2006EB42F5277022D9B19925BC419D7A592666C925FE2EF718EB4E308EFEAA7C5273B394118860A5BE2A97F56AB78365CA597CDBB3EDB8D1A1151EA0AF7B436", true, CipherSuite::TLS_AES_256_GCM_SHA384}, CipherParams{"E3C08A8F06C6E3AD95A70557B23F75483CE33021A9C72B7025666204C69C0B72","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","E2006EB42F5277022D9B19925BC419D7A592666C925FE2EF718EB4E308EFEAA7C5273B394118860A5BE2A97F56AB78365CA597CDBB3EDB8D1A1151EA1AF7B436", false, CipherSuite::TLS_AES_256_GCM_SHA384}))
 
std::unique_ptr< folly::IOBufdefaultCreator (size_t len, size_t)
 
std::unique_ptr< folly::IOBuftoIOBuf (std::string hexData, size_t headroom, size_t tailroom)
 
std::unique_ptr< IOBufchunkIOBuf (std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
 
 TYPED_TEST_CASE (Key, KeyTypes)
 
 TYPED_TEST (Key, GenerateKey)
 
 TYPED_TEST (Key, SharedSecret)
 
 TYPED_TEST (Key, ReadFromKey)
 
 TYPED_TEST (Key, ReadWrongGroup)
 
 TYPED_TEST (Key, Decode)
 
 TYPED_TEST (Key, Encode)
 
 TYPED_TEST (Key, DecodeInvalid)
 
 TYPED_TEST (Key, DecodeInvalidSmallLength)
 
int getNid (const Params &param)
 
void setPoint (EcKeyUniquePtr &key, std::string x, std::string y)
 
EvpPkeyUniquePtr getKey (const Params &param)
 
 TEST_P (ECDHTest, TestKeyAgreement)
 
 INSTANTIATE_TEST_CASE_P (TestVectors, ECDHTest,::testing::Values(Params{"e19007eb245d6995ffa8b3ede1e59193aa6cfaaf4cc1e1d126948610c9b3f44c","758b2f0e79a3d0a94f521ae31dcff50fabd394bb4bbec8fa37d1566f463444e7","b981e686e53e9e9dc2e3f263e810c89b4c271e62392f59ed45ed30ac3a5bfd33","8171000763de347d0eb650dd6fddac2ad48ec122c162d66c3df257aea13192fb","c22ac2ee50e771a93b2b6a42c5e9b76b45a56e0d0011e34aa790283ede61f3d9","0ef754edae5e79c518f1056aa5179cbb6a3a4b7c9654b5048f4259bd2597e57d","5cbea453310285b22f128178bd09b906fde9e660b5a17a7cec809a5a9a1e9287", true, KeyType::P256}, Params{"0ced658b6113979f8d05fd7b305ce0b8d70f45034d021b052cbcb318e0cfd602","acbcb31f5f6798a00f28aa4a634873744768db612925336efca98122a76d1b5e","7dcefeb3ccb530029a8b62e5a7f00c42fc7ebeac8f469c289ea77b6186d661f0","64e23f7a2d279930f1de66b4bc147786b168d059f581268c24f6650362246e63","ba393b401354aa9552c4289b7a55288d97590429a4003913a243081bacf88acf","d089687aa5442684d71b805ea2b36f6c1c783833346dfdd8208768ed2a7e767d","f70e4fc9ba68aafe07be1767620e64dd5e5bb7ab279f0657465cddeb69e36fa9", true, KeyType::P256}, Params{"0ced658b6113979f8d05fd7b305ce0b8d70f45034d021b052cbcb318e0cfd602","758b2f0e79a3d0a94f521ae31dcff50fabd394bb4bbec8fa37d1566f463444e7","b981e686e53e9e9dc2e3f263e810c89b4c271e62392f59ed45ed30ac3a5bfd33","8171000763de347d0eb650dd6fddac2ad48ec122c162d66c3df257aea13192fb","c22ac2ee50e771a93b2b6a42c5e9b76b45a56e0d0011e34aa790283ede61f3d9","0ef754edae5e79c518f1056aa5179cbb6a3a4b7c9654b5048f4259bd2597e57d","5cbea453310285b22f128178bd09b906fde9e660b5a17a7cec809a5a9a1e9287", true, KeyType::P256}, Params{"639ef9ee75a3888617fdd7ed89d62f7398b0eb4f20ccbd35026e150fc937c927","1d2dda4a3735be1f3aedfa8a7bb1410c3867c5d67f55a3dd5376b137352f113d","eca92fb210b1813f51ea2483ff461eb24786afb41f1a00870cf65aab5bbd725e","e062138981049c3b4b964fa5a28569e0142c2c51d6ca0bebdb3270e2ab77fb30","9aa8dd75f7d929b1f5f123aa9f3265be34f771c20bb50deea684a139a10938f8","2b74f503fa7b08db1c76d97c2e571cb91f68a93413daf102c47fee1b8a264d93","9f5f64d76f9bb2f2af24debdd47323d5df9d2b84fc7c7aac1f6d41678adec7de", false, KeyType::P256}, Params{"305dfb4a8850cc59280891147baf457bfe5e2bae984571634a77dc8d3472fa9b","202cb5a224e6c2a84e624094486edf04116c8d68ec1f4a0e0ed9ee090e1a900b","cacf3a5789bb33954be600425d62d9eae5371f90f88167258814213e4a4f4b1a","72cc52808f294b64b6f7233c3d2f5d96cc1d29287320e39e1c151deef0bc14eb","49a768c9a4ca56e374f685dd76a461b1016c59dcded2c8d8cbd9f23ca453831f","b1e3bb9b5f12a3b5ae788535d4554bd8c46e0e6130075e4e437d3854cf8f1c34","c0147c3c2691b450b5edc08b51aea224d9f4359ff67aab6da3146f396dbceaea", false, KeyType::P256}, Params{"0e5c98ff2d2a3aab14ad0067b60dbe64e4f541ab5bed11c5a0c55ae1e60b51ff5faaf377837977d80cbfdc33c2ff542b","d1bf2ac21637d66d6398aac01dcd56ac6f065fb45d1f6f16747bab9e9b01b4630b59b20927aea147355bf41838acb482","4c9e23f1c5a41647d094086bf4ed31708651f21d996c47780688ac10f77deee2e43b5241b6caecd2fd5444bc50472e0e","f865418473e5bf7d2e1bbcd9bd5a9270c003a9dd35e778133ca59fcab4bb64fe24d6800e7047bdd033abc8bfa8db35b5","32b72ab9b558249dcbc6cbade234f58e4f7aa5d3f6420ea99a5f997e8c2a91fb7fd83779d0d2169428683771c745fd1a","c749e02a3719bb56bf1dfc4ba3820309c01ab6e84cb29db7cdd80f127233f5295687f8178f3a8704c1063b84c2ee472f","a781430e6078a179df3f9ee27cd8fdc6188f161b6c4ccc4053ef6c6ca6fc222946883a53c06db08f0a020023ced055aa", true, KeyType::P384}, Params{"925065e50f7eae1319865720ae483de4dba7449dc144c4b50b8e96c4f4fcd9f8b3fbf693262429c91c69d8dd8355fdd8","4c619593e459e4aca7c572834064134d93e8b1b676388b0ff67b893722cf7e8396cd953df38a42e4131dbad29518b2af","dbe261af918baade39070e88f62eabe4ee9d5f2563707271cc566dd7a2380aa4707d15d6eef142a52d75a67429afd0c6","c40c805488115e43279c99797bcbfff8d9922ea9aec471d9ba659590034c3fb739d23661c0aae6e7ada2a1de36eb63a1","a95b7ad4de234e9be8b260313ddb96a404b75b3a7e0f234981f3b189d86ac31bbe3937776c0608024871ef64815784b3","4890ee227219ca5ce34632cbca5732accc2d276fa1b1cc9d14f6b7e4b0f5e116a92cbef743de3e69537e250f27125e82","128934db846099c8d8caa788b0b84bb65bd57b20774ff7f8e7f29939297d72bbc232c5d2b2c8ef1d63e3d75d3908e778", true, KeyType::P384}, Params{"259c53eec19d01d19428f6cc5cd445ab685578c53325f6d2f157bd0328deca4ffb8c21dca891d59e34a807203f7e9a5d","d18832f4cf3013e514b4fb4c42bbeb15708e20ed91b982598deb2d67b37275587fcb35cf214039ec4fd1834d704c1faf","917c49465bef063949957256eddbece762090ef10f8c48566bd71dc0ad9eb3bc00f0b3f6a88d614210804dd633ca6e68","3120ee90dcce02bac90a66d30ad602e94edcce482dbc5245a136df1d0509b04f6ee305fedd290775c71f1631684f5c0a","7a3e0fd767acf409cebe6fe0222974438bccdefb13f0d668b8daad43a6fdbdf46845c45b9594ffd6742a615dd834f1a5","e3cc9f7153b6ffd3b285349996b952905466942d17f6a9685a11318b0c2c72904961d246cbe3ef98903dbbfb0fbe55b0","5c8d476518873208e1c97685c033a1ba6ec279b8674060cc1a99469908604353043bf488109150b9b2f9b3b1440a426c", true, KeyType::P384}, Params{"4e422a76b085ae939a8166afb98e344b9ac30bab610e90b3d7449de0a0de6b88fadb095e4818521bb1473540a7ec73ee","de464ed2129eef42ef23cb1bfad27382293edad91d867b1b8b82a19bd17516daf0a73548787a733d66ca4f4d40b52da1","f07bd6003229de37d6293513cbace59ebc24efb571c065df2bc1465c4570928fd612a59a46805b6adce7fb94e36ad043","f8f6697507aeec09fe024f974e00e67f12a14c130df875732b450b3ae8d2cbbb1fcf46bac9207e89a297352eeade7df5","c1db2e81eca0e5b02e8736ff351aa8e59bdadd1c9c7428faf93493c7b93153ec2c55964a157025ff6ddb4523d8e0a453","98daa370a6610ecf604e38e1e70b7f57657c49908eb15634a3a65a175ca7b8cfe1ad535037928ae95c80107a1e018b3c","d80415977c3ce1737fd574596e981c767ecaf5c70084fae6c2072f0ccecc8bdda54a0bf44357981303a2ecc78b26e97c", false, KeyType::P384}, Params{"4ee6a24b5dca82b215c92cb298d5ac24b77820c7b7e9c8fe4d05d7a297b8f6be40f8d8cf09a4bb238cfdbe05f851c493","1f9af3b14439d4c56b353b5892dd85b6a27053e1d23f5f05ff95ea3fa942eb463e1074b01828a79c865b16fde0fc0f24","01a81aaef502fe84508b054924d90078f68d8d4e9ae5299bd0ea60a97167c549011f4a024e964292d378e82b6874caad","3d715cd0d6490ba5607e7eae2c74361be65de413f10576c1d996658e20c78f8110c70104067922d48303f6ccb1b23f46","2fa7d2ea93945b41c929279a750ded758d9db93d120b5eeda3d9994e36e3381f653d19dcae0eccb1a12153ce4025a62e","04c6e45983485529e9dacba8d609cffaec849f7c5e5cf4a025ce2c0ff9ae6679b4564b9af58fab58c7f92837597b830b","5e77e466aeae9c10ff8d255e07cf0ad9eae50c8a6fd2c7cd889d73d968c423a15c0462b05bf985cbf679a629e380ce80", false, KeyType::P384}, Params{"0000002fef62381162942889a6094a6bb9ac1f4ddf66d9cda9f618232d31b90c50d7da78a47ed91d40cae946898571db972dc294b109815f38feee9eaac0d5f7c3250728","0000004b05ffa025113390797f2736174aa1c784f4dd34e764ee40d40e4d2442677ebea3498086c9473e5c92789cbdb02bb327bbd61d58690f6a83d9ca73bccbde37dec4","0000004da67cffc98070b82af61feba78787efefb13bd810d80ff92304788e49a4e5b634b3565474a8ecb1615d7b1b77a7a27875adb73a8a5d8f3f84e5e8b744cda250b0","00000311a5e520e238141527671a38cb6f776d96a9f82ef70dffa11dc0895f4060f1abbb9ad6fd259e4a7beaf5f7266ea1bb45bcbfebfda2705e5c551e710fb1d745f57e","0000010ba3778cb2cc965834c0a9593adc6a222692656d657fb0d15293edf0ab33762384a96a16fddea7540b7ccbcca46ec4ac9bcf95fdb5aa18e158aab4d91981bd733e","0000018522df93ddd636e5bc94daecdc600fa241686ec18634fd30b7cbdfdc9ffba1166ac08df34a31896f6fad191414929261ebd7187afb72919f8a0c926be37f99c1e5","01a5e4b31be4b1346e53906b6767b1fe94ec1a8a5abc28fb6f01518c056959af3bc9335dddab178b52318cc5512559931b8dc18de0ce810c2c7f15769d7ce70e719c", false, KeyType::P521}, Params{"0000013262b7f4f36de274b2c60e4a812866740e545186953f798ac07b5d74e4f0cc1123a9bfcbf77850e2d856246065c54a2437a2816a7d79d6180a9a6ba17f18df8b65","000001474af758238005238b2fa253c4f9c557de664d64c66d7d88f334555997591ccc242ff3c6d0e34d07fc835aaae024c2bd21f2ba5c0b0a8ac3fdd90e1c479cb8e538","000000a721b04654204ca19064b37a4abf4247413a6d29e9211a0df9d50975c7d8d4654dc04a478455ea24993f0fef5460f189c4729c15fba385fd85ef42ae7610e39450","000001a23de55fb7ad153e7e65d21ad10c77fdf2072b2a5aa116aaf1bc31a345420c1fe8eaccbbcdeb07b73ba2fa706c7498e3a4828f348b00af9df1551780e709a7754c","000000ed7bc3a95ef74dc3a9893a5ec7c9fab723c16dc21b30341c374c25e1334dada7f92d62967f3bca4da70b0a77fa0732dac05a3d19cb04e50b3cd1894549ac1d3c6e","000001c30d23ea4c140aabfba3753ce40c788010342c15c51d2dd6e9b079194e593ba965ea419ef37746f954027fa1b8159ccd3b54aece67451c7e892d6f6e1fb44c548c","01e8ff7a8c57b017f8b8266adab65fe2c417173566087e15c5fc972071cc560ac93908a806468bc44b8312a8a48464886ca0d767db938447387a348f3f56c6463796", true, KeyType::P521}, Params{"000000364b6cc953c841d2e1c8c292fadaa673ea073d150da4cec9c0c6544c92373c6a42a781283bedb080a4de720b99769869019a38023019b9d15c99b2a08a02104cc7","000001abbbcd3912723cbb3147145a12b8f2f40d1fe6484fa831250435ffb8eb751bccdf425e81d8e79518ec84c56bd28763c417f30a16c213abbfd8e5871d93dcb3f0d0","00000237c413a4527ca89dee7c8a5c45fc0207627e3db79353ee506857d68f746ea2c7b4d04ab1c10df56b1a706012f616ec9a5510467c49a56941841a1636f620dc3ac4","000000e04b0e32496f1d43ff48d759dc57d586c6c55efb6460fc1148021afa1943180aea2a1be7721a69ebf9d55585a4d4bdb6ff3e177448568c0b45542eddb936fbd870","00000195a305d23a94794e680b211b8ec4a5c2150a2002afdc4ff5da254c438b5686b12dda72bd8dbb009d07d469c3d664e67da274de7f2e2dc84661d2a054638cf6fc98","000000e56b77c46a997c06da59033e1c57939f6f8513329ebe93dcb00857a8ff850428473d937528e85c15a5fe46df1ffb7aeed4b17f7fc9ad08fb121045e2eea5a316b2","013eeaad91133eb338a4c1f27af66aa7f7614619b6c21c20f0e2d68fca2e9cbaa224104a45aa4dbefcb1e49b7f1a36171a35102d2b7d2ffbade07e600b4a7e28c05c", false, KeyType::P521}, Params{"000001ef093db892daaa05d43e70654bd702d7e177465b00a5ff70a9a072774d7cda3893c181ad1dbb23f8352d3098025406a442c60afaf949dd37ee9c36ee2f785dc693","0000017e817b93e7e3eb95291545afffa2dcd1ff90b97c2b7d9cc7a46511cbdf7a7afe7a2ce126822d08bc71519542743dfece750e18f1e01bb5201e622e2697e5b1faa6","00000025e5e302514ccb15ed84291ba30746b1176f2b080bfa78ef7ce5721fd00d3d717421932d61ad74068c36885a9a0e6537183209a79054fcb8df43b83066f60c47d5","0000004e9f4ebd9f4772df7c003828210d087aa41c0154394428f5f8624536a15c157634c5200de037e46698d4f8484feb164374899b2d9d5e258080dae6b3429c965154","0000021fb91b2abbdd7dee5e2750a1fce602e235a6512b429ab0a3845bd8c8a630d9d35850e0ba78f01c01ffae6ca1a88c93c153a6fdc09f76fae768bdd449e7f6730b68","0000005cb38e5272648f2adcb5ec7a37f3b2135c93a0202f2c822383eae29468392f4baeddabf0acd3bee0cbc1dd540b435d34ecb008408ac093978976741d1afa374c72","01bca2f6325ccf7a6a213b2678ded8ce3e687497c7f7f46a4a06bf3e69dabb745a883d130936c786debf2fe5ef8880f1bb976a79e33b68d30d7356b5a4672e65fcea", false, KeyType::P521}, Params{"0000014199e2e81aa1f98bf0f39d069e720820d0433222f5b8ca26606fe7c4d0cd619b415d2a629674479a6ec6171f05f657a168aad9342e8489a39cf485a396a8400c59","00000070ce983ca6d0a7aa7849bef13e11e3dc1d62e1ddb85b54d4a3c9de5b47a078846f92105304efe4a4e71d7ff91c19a7b4e03fd87c2d8fb70732e274b114a0bf3bd2","0000009f564f73a5c7282556437dc4c2fbdf87d5fcfbaab0feecf1f7a88104f15a7314b083f711bd7b3a2c74b1096fdccdac01e0a35b8fd86d99ba9d64d10e190033c3df","000000c0b19361224245482bbe42110f9aa44f2818b5146710c24b4825a9a3e0a4743fc7983df560bd85d30639bbdb4d7fc0c56a862e0ef349801bef06ed0a9774463e9f","000000231f2c5c2ad3894b81ad2c8942221d06041f37b8d520e926701b9fb38e32833f9b2b99142d0e54baef33c17b2bd0f23ec3e1b08b9a87f65942384e5863607ba65c","0000005e3b734d4207b51259a1fca526161250176eab1364930d7d06259f43e68202962d9bb818a44bf3bf4a385e634a8d52489c58e2c9234670ae9f30668a2f5553c261","01186d749c6b2a215c59df35ef6f2f6ed1745a9b2e15fca225e79faa7c5b9af44821d50765b45c3c66e210ec78d4bccb7f8c44c19cf80f5357938df48e320fa1ed88", true, KeyType::P521}))
 
 TEST (X25519KeyExchange, KeyExchange)
 
 TEST (X25519KeyExchange, SmallKeyExchange)
 
 TEST (ValidateECKey, GoodPrivateKey)
 
 TEST (ValidateECKey, GoodPubicKey)
 
 TEST (ValidateECKey, WrongKeyType)
 
 TEST (ValidateECKey, WrongCurve)
 
static EvpPkeyUniquePtr generateKey ()
 
 TEST_F (RSAPSSTest, TestSignVerify)
 
 TEST_F (RSAPSSTest, TestVerifyDifferent)
 
 TEST_F (RSAPSSTest, TestVerifyFailure)
 
 TEST_P (HkdfTest, TestHkdfSha256Expand)
 
 INSTANTIATE_TEST_CASE_P (TestVectors, HkdfTest,::testing::Values(HashParams{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b","000102030405060708090a0b0c","f0f1f2f3f4f5f6f7f8f9", 42,"3cb25f25faacd57a90434f64d0362f2a""2d2d0a90cf1a5a4c5db02d56ecc4c5bf""34007208d5b887185865"}, HashParams{"000102030405060708090a0b0c0d0e0f""101112131415161718191a1b1c1d1e1f""202122232425262728292a2b2c2d2e2f""303132333435363738393a3b3c3d3e3f""404142434445464748494a4b4c4d4e4f","606162636465666768696a6b6c6d6e6f""707172737475767778797a7b7c7d7e7f""808182838485868788898a8b8c8d8e8f""909192939495969798999a9b9c9d9e9f""a0a1a2a3a4a5a6a7a8a9aaabacadaeaf","b0b1b2b3b4b5b6b7b8b9babbbcbdbebf""c0c1c2c3c4c5c6c7c8c9cacbcccdcecf""d0d1d2d3d4d5d6d7d8d9dadbdcdddedf""e0e1e2e3e4e5e6e7e8e9eaebecedeeef""f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", 82,"b11e398dc80327a1c8e7f78c596a4934""4f012eda2d4efad8a050cc4c19afa97c""59045a99cac7827271cb41c65e590e09""da3275600c2f09b8367793a9aca3db71""cc30c58179ec3e87c14c01d5c1f3434f""1d87"}, HashParams{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b","","", 42,"8da4e775a563c18f715f802a063c5a31""b8a11f5c5ee1879ec3454e5f3c738d2d""9d201395faa4b61a96c8"}))
 
 TEST (RandomGeneratorTest, TestRandom)
 
 TEST (RandomGeneratorTest, TestRandomUInt32)
 
EvpPkeyUniquePtr getPrivateKey (StringPiece key)
 
EvpPkeyUniquePtr getPublicKey (StringPiece key)
 
std::unique_ptr< folly::IOBuftoIOBuf (folly::StringPiece hexData)
 
folly::ssl::X509UniquePtr getCert (folly::StringPiece cert)
 
std::unique_ptr< folly::IOBufgetCertData (folly::StringPiece cert)
 
void useMockRandom ()
 
 TEST (UtilsTest, TestEqualWrongSize)
 
 TEST (UtilsTest, TestEqual)
 
 TEST (UtilsTest, TestClean)
 
 TEST (ExportedAuthenticatorTest, TestAuthenticatorRequest)
 
 TEST (ExportedAuthenticatorTest, TestEmptyAuthenticatorRequest)
 
 TEST_F (AuthenticatorTest, TestValidAuthenticator)
 
 TEST_F (AuthenticatorTest, TestEmptyAuthenticator)
 
 TEST (ExportedAuthenticatorTest, TestGetContext)
 
 TEST_F (ValidateAuthenticatorTest, TestValidateValidAuthenticator)
 
 TEST_F (ValidateAuthenticatorTest, TestValidateEmptyAuthenticator)
 
 TEST_F (ExtensionsTest, TokenBindingParameters)
 
 TEST_F (ExtensionsTest, TokenBindingMessageFromChrome)
 
 TEST_F (ExtensionsTest, TokenBindingMessageSelfCreated)
 
 TEST (ContextTest, TestAscendingVersionsNotSet)
 
 TEST (ContextTest, TestShuffledNotSet)
 
 TEST (ContextTest, TestDoubleNotSet)
 
 TEST (ContextTest, TestEmptySet)
 
 TEST (ContextTest, TestSingleSet)
 
 TEST (ContextTest, TestDescendingVersionsSet)
 
 TEST (ContextTest, TestDoubleSet)
 
 TEST (ContextTest, TestDescendingDuplicatesNotSet)
 
 TEST_F (CertDecompressionManagerTest, TestBasic)
 
 TEST_F (CertDecompressionManagerTest, TestSameOverwrites)
 
template<typename T >
static ssl::X509UniquePtr getCert ()
 
template<>
ssl::X509UniquePtr getCert< P256Test > ()
 
template<>
ssl::X509UniquePtr getCert< P384Test > ()
 
template<>
ssl::X509UniquePtr getCert< P521Test > ()
 
template<>
ssl::X509UniquePtr getCert< RSATest > ()
 
template<typename T >
static ssl::EvpPkeyUniquePtr getKey ()
 
template<>
ssl::EvpPkeyUniquePtr getKey< P256Test > ()
 
template<>
ssl::EvpPkeyUniquePtr getKey< P384Test > ()
 
template<>
ssl::EvpPkeyUniquePtr getKey< P521Test > ()
 
template<>
ssl::EvpPkeyUniquePtr getKey< RSATest > ()
 
 TYPED_TEST_CASE (CertTestTyped, KeyTypes)
 
 TEST (CertTest, GetIdentity)
 
 TEST (CertTest, GetAltIdentity)
 
 TEST (CertTest, GetCertMessage)
 
 TEST (CertTest, PrepareSignData)
 
 TEST (CertTest, MakePeerCertEmpty)
 
 TEST (CertTest, MakePeerCertJunk)
 
 TEST (CertTest, PeerCertGetX509)
 
 TYPED_TEST (CertTestTyped, MatchingCert)
 
 TYPED_TEST (CertTestTyped, MismatchedCert)
 
 TYPED_TEST (CertTestTyped, SigSchemes)
 
 TYPED_TEST (CertTestTyped, TestSignVerify)
 
 TYPED_TEST (CertTestTyped, TestSignVerifyBitFlip)
 
 TYPED_TEST (CertTestTyped, TestSignVerifyWrongSize)
 
 TYPED_TEST (CertTestTyped, TestVerifyWrongScheme)
 
 TYPED_TEST (CertTestTyped, TestVerifyDecodedCert)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifySuccess)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifyWithIntermediates)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifySelfSignedCert)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifySelfSignedCertWithOverride)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifyWithIntermediateMissing)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifyWithIntermediateMissingWithOverride)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifyWithBadIntermediate)
 
 TEST_F (DefaultCertificateVerifierTest, TestVerifyWithBadRoot)
 
 TEST (ExporterTest, TestExporterBasic)
 
static WriteNewSessionTicket writeNewSessionTicket (const std::string &str)
 
static AppWrite appWrite (const std::string &str)
 
 MATCHER_P (WriteNewSessionTicketMatches, expected,"")
 
 MATCHER_P (WriteMatches, expected,"")
 
 TEST_F (FizzBaseTest, TestReadSingle)
 
 TEST_F (FizzBaseTest, TestReadMulti)
 
 TEST_F (FizzBaseTest, TestReadNoActions)
 
 TEST_F (FizzBaseTest, TestWriteNewSessionTicket)
 
 TEST_F (FizzBaseTest, TestWrite)
 
 TEST_F (FizzBaseTest, TestEarlyWrite)
 
 TEST_F (FizzBaseTest, TestWriteMulti)
 
 TEST_F (FizzBaseTest, TestAppClose)
 
 TEST_F (FizzBaseTest, TestWriteNewSessionTicketInCallback)
 
 TEST_F (FizzBaseTest, TestWriteInCallback)
 
 TEST_F (FizzBaseTest, TestAppCloseInCallback)
 
 TEST_F (FizzBaseTest, TestWriteThenCloseInCallback)
 
 TEST_F (FizzBaseTest, TestDeleteInCallback)
 
 TEST_F (FizzBaseTest, TestStopOnError)
 
 TEST_F (FizzBaseTest, TestAsyncAction)
 
 TEST_F (FizzBaseTest, TestAsyncActionDelete)
 
 TEST_F (FizzBaseTest, TestActionProcessing)
 
 TEST_F (FizzBaseTest, TestActionProcessingAsync)
 
 TEST_F (FizzBaseTest, TestErrorPendingEvents)
 
 TEST_F (FizzBaseTest, EventAfterErrorState)
 
 TEST_F (FizzBaseTest, TestManyActions)
 
 TEST_F (HandshakeContextTest, TestHandshakeContextSingle)
 
 TEST_F (HandshakeContextTest, TestHandshakeContextMultiple)
 
 TEST_F (HandshakeContextTest, TestFinished)
 
 TEST_F (HandshakeContextTest, TestEmpty)
 
 TEST_F (KeySchedulerTest, TestEarly)
 
 TEST_F (KeySchedulerTest, TestEarlyEcdhe)
 
 TEST_F (KeySchedulerTest, TestNoEarly)
 
 TEST_F (KeySchedulerTest, TestKeyUpdate)
 
 TEST_F (KeySchedulerTest, TestTrafficKey)
 
 MATCHER_P (BufMatches, expected,"")
 
 MATCHER_P (RangeMatches, expected,"")
 
template<typename A , typename B >
void throwIfNeq (const A &a, const B &b, const std::string &msg)
 
template<typename A >
void throwIfNull (const A &a, const std::string &msg)
 
CertAndKey createCert (std::string cn, bool ca, CertAndKey *issuer)
 
std::shared_ptr< PeerCertgetPeerCert (const CertAndKey &cert)
 
 TEST_F (ZlibCertificateCompressorTest, TestCompressDecompress)
 
 TEST_F (ZlibCertificateCompressorTest, TestHugeCompressedCert)
 
 TEST_F (ZlibCertificateCompressorTest, TestBadMessages)
 
 TEST_F (EncryptedRecordTest, TestReadEmpty)
 
 TEST_F (EncryptedRecordTest, TestReadHandshake)
 
 TEST_F (EncryptedRecordTest, TestReadAlert)
 
 TEST_F (EncryptedRecordTest, TestReadAppData)
 
 TEST_F (EncryptedRecordTest, TestReadUnknown)
 
 TEST_F (EncryptedRecordTest, TestWaitForData)
 
 TEST_F (EncryptedRecordTest, TestWaitForHeader)
 
 TEST_F (EncryptedRecordTest, TestMaxSize)
 
 TEST_F (EncryptedRecordTest, TestOverSize)
 
 TEST_F (EncryptedRecordTest, TestDataRemaining)
 
 TEST_F (EncryptedRecordTest, TestPadding)
 
 TEST_F (EncryptedRecordTest, TestAllPaddingAppData)
 
 TEST_F (EncryptedRecordTest, TestAllPaddingHandshake)
 
 TEST_F (EncryptedRecordTest, TestNoContentType)
 
 TEST_F (EncryptedRecordTest, TestReadSeqNum)
 
 TEST_F (EncryptedRecordTest, TestSkipAndWait)
 
 TEST_F (EncryptedRecordTest, TestSkipAndRead)
 
 TEST_F (EncryptedRecordTest, TestWriteHandshake)
 
 TEST_F (EncryptedRecordTest, TestWriteAppData)
 
 TEST_F (EncryptedRecordTest, TestWriteAppDataInPlace)
 
 TEST_F (EncryptedRecordTest, TestFragmentedWrite)
 
 TEST_F (EncryptedRecordTest, TestWriteSplittingWholeBuf)
 
 TEST_F (EncryptedRecordTest, TestWriteSplittingCombineSmall)
 
 TEST_F (EncryptedRecordTest, TestWriteSeqNum)
 
 TEST_F (EncryptedRecordTest, TestWriteEmpty)
 
 TEST_F (EncryptedRecordTest, TestWriteMaxSize)
 
 TEST_F (EncryptedRecordTest, TestWriteMinSize)
 
 TEST_F (ExtensionsTest, TestProtocolNameList)
 
 TEST_F (ExtensionsTest, TestServerNameList)
 
 TEST_F (ExtensionsTest, TestHelloRetryRequestKeyShare)
 
 TEST_F (ExtensionsTest, TestClientEarlyData)
 
 TEST_F (ExtensionsTest, TestServerEarlyData)
 
 TEST_F (ExtensionsTest, TestTicketEarlyData)
 
 TEST_F (ExtensionsTest, TestCookie)
 
 TEST_F (ExtensionsTest, TestCertificateAuthorities)
 
 TEST_F (ExtensionsTest, TestCertificateCompressionAlgorithms)
 
 TEST_F (ExtensionsTest, TestBadlyFormedExtension)
 
 TEST_F (HandshakeTypesTest, ChloEncodeDecode)
 
 TEST_F (HandshakeTypesTest, SSL3ChloDecode)
 
 TEST_F (HandshakeTypesTest, ChloDecidePsk)
 
 TEST_F (HandshakeTypesTest, ChloEncodeCopy)
 
 TEST_F (HandshakeTypesTest, NstEncodeDecode)
 
bool extensionsMatch (const Extension &expected, const Extension &actual)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeSigAlgs)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeClientKeyShare)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeServerHello)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeEndOfEarlyData)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeEncryptedExtensions)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodedCertificate)
 
 TEST_F (HandshakeTypesTest, EncodedAndDecodeCertificateVerify)
 
 TEST_F (HandshakeTypesTest, EncodedAndDecodeKeyUpdated)
 
 TEST_F (HandshakeTypesTest, EncodedAndDecodeCertificateRequest)
 
 TEST_F (HandshakeTypesTest, EncodeAndDecodeCompressedCertificate)
 
 TEST_F (PlaintextRecordTest, TestReadEmpty)
 
 TEST_F (PlaintextRecordTest, TestReadHandshake)
 
 TEST_F (PlaintextRecordTest, TestReadAlert)
 
 TEST_F (PlaintextRecordTest, TestReadAppData)
 
 TEST_F (PlaintextRecordTest, TestWaitForData)
 
 TEST_F (PlaintextRecordTest, TestWaitForHeader)
 
 TEST_F (PlaintextRecordTest, TestMaxSize)
 
 TEST_F (PlaintextRecordTest, TestOverSize)
 
 TEST_F (PlaintextRecordTest, TestEmpty)
 
 TEST_F (PlaintextRecordTest, TestDataRemaining)
 
 TEST_F (PlaintextRecordTest, TestSkipAndWait)
 
 TEST_F (PlaintextRecordTest, TestWaitBeforeSkip)
 
 TEST_F (PlaintextRecordTest, TestSkipAndRead)
 
 TEST_F (PlaintextRecordTest, TestWriteHandshake)
 
 TEST_F (PlaintextRecordTest, TestWriteClientHello)
 
 TEST_F (PlaintextRecordTest, TestWriteAppData)
 
 TEST_F (PlaintextRecordTest, TestFragmentedWrite)
 
 TEST_F (RecordTest, TestNoData)
 
 TEST_F (RecordTest, TestReadAppData)
 
 TEST_F (RecordTest, TestAlert)
 
 TEST_F (RecordTest, TestHandshake)
 
 TEST_F (RecordTest, TestHandshakeTooLong)
 
 TEST_F (RecordTest, TestHandshakeFragmentedImmediate)
 
 TEST_F (RecordTest, TestHandshakeFragmentedDelayed)
 
 TEST_F (RecordTest, TestHandshakeCoalesced)
 
 TEST_F (RecordTest, TestHandshakeSpliced)
 
 TEST_F (RecordTest, TestWriteAppData)
 
 TEST_F (RecordTest, TestWriteAlert)
 
 TEST_F (RecordTest, TestWriteHandshake)
 
 TEST (TestTypes, WriteAndRead24BitsNormal)
 
 TEST (TestTypes, Write24BitsOverflow)
 
 TEST (TestTypes, Write24BitsBuffer)
 
 TEST (TestTypes, Write24BitsBufferOverflow)
 
 TEST (TestTypes, WriteBuf)
 
 TEST_F (AsyncFizzBaseTest, TestIsFizz)
 
 TEST_F (AsyncFizzBaseTest, TestAppBytesWritten)
 
 TEST_F (AsyncFizzBaseTest, TestAppBytesReceived)
 
 TEST_F (AsyncFizzBaseTest, TestWrite)
 
 TEST_F (AsyncFizzBaseTest, TestReadErr)
 
 TEST_F (AsyncFizzBaseTest, TestReadErrNoCallback)
 
 TEST_F (AsyncFizzBaseTest, TestReadErrAsync)
 
 TEST_F (AsyncFizzBaseTest, TestReadEOF)
 
 TEST_F (AsyncFizzBaseTest, TestReadEOFNoCallback)
 
 TEST_F (AsyncFizzBaseTest, TestMovableBuffer)
 
 TEST_F (AsyncFizzBaseTest, TestMovableBufferAsyncCallback)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferLarger)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferExact)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferSmaller)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferAsync)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferZero)
 
 TEST_F (AsyncFizzBaseTest, TestReadBufferPause)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadBufMovable)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadBufMove)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadBufAvail)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadError)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadEOF)
 
 TEST_F (AsyncFizzBaseTest, TestTransportReadBufPause)
 
 TEST_F (AsyncFizzBaseTest, TestAppReadBufPause)
 
 TEST_F (AsyncFizzBaseTest, TestWriteSuccess)
 
 TEST_F (AsyncFizzBaseTest, TestWriteError)
 
 TEST_F (AsyncFizzBaseTest, TestHandshakeTimeout)
 
 TEST_F (AsyncFizzBaseTest, TestAttachEventBase)
 
 TEST_F (AsyncFizzBaseTest, TestAttachEventBaseWithReadCb)
 
 TEST_F (HandshakeTest, BasicHandshake)
 
 TEST_F (HandshakeTest, BasicHandshakeTrickle)
 
 TEST_F (HandshakeTest, P256)
 
 TEST_F (HandshakeTest, P384)
 
 TEST_F (HandshakeTest, P521)
 
 TEST_F (HandshakeTest, GroupServerPref)
 
 TEST_F (HandshakeTest, GroupMismatch)
 
 TEST_F (HandshakeTest, SchemeServerPref)
 
 TEST_F (HandshakeTest, SchemeMismatch)
 
 TEST_F (HandshakeTest, HRR)
 
 TEST_F (HandshakeTest, PskDheKe)
 
 TEST_F (HandshakeTest, HrrPskDheKe)
 
 TEST_F (HandshakeTest, HrrPskDheKeWithCache)
 
 TEST_F (HandshakeTest, HrrIncompatiblePsk)
 
 TEST_F (HandshakeTest, PskKe)
 
 TEST_F (HandshakeTest, TestEkmSame)
 
 TEST_F (HandshakeTest, TestEarlyEkmSame)
 
 TEST_F (HandshakeTest, TestExtensions)
 
 TEST_F (HandshakeTest, BasicCertRequest)
 
 TEST_P (SigSchemeTest, Schemes)
 
 TEST_F (HandshakeTest, CertRequestPskPreservesIdentity)
 
 TEST_F (HandshakeTest, CertRequestNoCert)
 
 TEST_F (HandshakeTest, CertRequestPermitNoCert)
 
 TEST_F (HandshakeTest, CertRequestBadCert)
 
 TEST_F (HandshakeTest, BasicCertCompression)
 
 TEST_F (HandshakeTest, EarlyDataAccepted)
 
 TEST_F (HandshakeTest, EarlyDataRejected)
 
 TEST_F (HandshakeTest, EarlyDataRejectedHrr)
 
 TEST_F (HandshakeTest, EarlyDataRejectedResend)
 
 TEST_F (HandshakeTest, EarlyDataRejectedDontResend)
 
 TEST_F (HandshakeTest, EarlyDataTrickleSendAccepted)
 
 TEST_F (HandshakeTest, EarlyDataTrickleSendRejected)
 
 TEST_F (HandshakeTest, Compat)
 
 TEST_F (HandshakeTest, TestCompatHRR)
 
 TEST_F (HandshakeTest, TestCompatEarly)
 
 TEST_F (HandshakeTest, TestCompatEarlyRejected)
 
 TEST_F (HandshakeTest, TestCompatEarlyRejectedHRR)
 
 TEST_F (HandshakeTest, TestCookie)
 
 TEST_F (HandshakeTest, TestCookieGroupNegotiate)
 
 TEST_F (HandshakeTest, TestCookieResume)
 
 TEST_F (HandshakeTest, TestCookieIncompatiblePsk)
 
 TEST_F (HandshakeTest, TestCookiePskKe)
 
 TEST_F (HandshakeTest, TestBadCookie)
 
 INSTANTIATE_TEST_CASE_P (SignatureSchemes, SigSchemeTest,::testing::Values(SignatureScheme::rsa_pss_sha256, SignatureScheme::ecdsa_secp256r1_sha256, SignatureScheme::ecdsa_secp384r1_sha384, SignatureScheme::ecdsa_secp521r1_sha512))
 
 TEST (UtilTest, GetAlpnFromNpn)
 
 TEST (UtilTest, CreateTickerCipher)
 
 TEST (UtilTest, ReadPKey)
 
 TEST (UtilTest, ReadChainFile)
 

Variables

constexpr size_t kHeadroom = 10
 
static struct randombytes_implementation mockRandom
 
constexpr folly::StringPiece kP256Key
 
constexpr folly::StringPiece kP256PublicKey
 
constexpr folly::StringPiece kP256K1Key
 
constexpr folly::StringPiece kP256Certificate
 
constexpr folly::StringPiece kP384Key
 
constexpr folly::StringPiece kP384PublicKey
 
constexpr folly::StringPiece kP384Certificate
 
constexpr folly::StringPiece kP521Key
 
constexpr folly::StringPiece kP521PublicKey
 
constexpr folly::StringPiece kP521Certificate
 
constexpr folly::StringPiece kRSAKey
 
constexpr folly::StringPiece kRSACertificate
 
constexpr folly::StringPiece kClientAuthCACert
 
constexpr folly::StringPiece kClientAuthClientCert
 
constexpr folly::StringPiece kClientAuthClientKey
 
StringPiece expected_auth_request
 
StringPiece expected_authenticator
 
StringPiece expected_cr_context = {"303132333435363738396162636465666768696a"}
 
StringPiece expected_cert
 
StringPiece expected_empty_authenticator
 
StringPiece exporter_master = {"12345678901234567890123456789012"}
 
StringPiece label = {"EXPORTER-Token-Binding"}
 
StringPiece basic_expected_ekm
 
constexpr ProtocolVersion TestProtocolVersion = ProtocolVersion::tls_1_3
 
static const std::string exampleCompressedCertificate
 
static const std::string tooLargeCompressedCertificate
 

Typedef Documentation

using fizz::test::Action = typedef boost::variant<A1, A2>

Definition at line 56 of file FizzBaseTest.cpp.

using fizz::test::Actions = typedef std::vector<Action>

Definition at line 57 of file FizzBaseTest.cpp.

using fizz::test::BufCreator = typedef std::function<std::unique_ptr<folly::IOBuf>(size_t len, size_t bufNum)>

Definition at line 20 of file TestUtil.h.

Definition at line 106 of file ECKeyExchangeTest.cpp.

Enumeration Type Documentation

enum fizz::test::StateEnum
strong
Enumerator
NotError 
Error 

Definition at line 44 of file FizzBaseTest.cpp.

Function Documentation

static AppWrite fizz::test::appWrite ( const std::string str)
static

Definition at line 30 of file FizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), fizz::AppWrite::data, and fizz::detail::write().

Referenced by fizz::sm::generateTicket(), fizz::sm::getCertificateRequest(), fizz::sm::getMaxEarlyDataSize(), fizz::sm::handleEarlyAppWrite(), and TEST_F().

30  {
32  write.data = IOBuf::copyBuffer(str);
33  return write;
34 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
void fizz::test::callDecrypt ( std::unique_ptr< Aead > &  cipher,
const CipherParams params,
std::unique_ptr< IOBuf ciphertext = nullptr,
std::unique_ptr< IOBuf aad = nullptr 
)

Definition at line 104 of file OpenSSLEVPCipherTest.cpp.

References fizz::test::CipherParams::aad, fizz::test::CipherParams::ciphertext, copyBuffer(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, folly::gen::move, fizz::test::CipherParams::plaintext, fizz::test::CipherParams::seqNum, toIOBuf(), and fizz::test::CipherParams::valid.

Referenced by TEST_P().

108  {
109  if (!ciphertext) {
110  ciphertext = toIOBuf(params.ciphertext);
111  }
112  if (!aad && !params.aad.empty()) {
113  aad = toIOBuf(params.aad);
114  }
115  auto ctCopy = copyBuffer(*ciphertext);
116  try {
117  auto out = cipher->decrypt(std::move(ciphertext), aad.get(), params.seqNum);
118  EXPECT_TRUE(params.valid);
119  EXPECT_TRUE(IOBufEqualTo()(toIOBuf(params.plaintext), out));
120 
121  EXPECT_EQ(
122  out->computeChainDataLength(),
123  ctCopy->computeChainDataLength() - cipher->getCipherOverhead());
124  } catch (const std::runtime_error&) {
125  EXPECT_FALSE(params.valid);
126  }
127 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr Params params[]
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
std::unique_ptr<folly::IOBuf> fizz::test::callEncrypt ( std::unique_ptr< Aead > &  cipher,
const CipherParams params,
std::unique_ptr< IOBuf plaintext = nullptr,
std::unique_ptr< IOBuf aad = nullptr 
)

Definition at line 81 of file OpenSSLEVPCipherTest.cpp.

References fizz::test::CipherParams::aad, fizz::test::CipherParams::ciphertext, copyBuffer(), EXPECT_EQ, folly::gen::move, fizz::test::CipherParams::plaintext, fizz::test::CipherParams::seqNum, toIOBuf(), and fizz::test::CipherParams::valid.

Referenced by TEST_P().

85  {
86  if (!plaintext) {
87  plaintext = toIOBuf(params.plaintext);
88  }
89 
90  if (!aad && !params.aad.empty()) {
91  aad = toIOBuf(params.aad);
92  }
93  auto ptCopy = copyBuffer(*plaintext);
94  auto out = cipher->encrypt(std::move(plaintext), aad.get(), params.seqNum);
95  bool valid = IOBufEqualTo()(toIOBuf(params.ciphertext), out);
96 
97  EXPECT_EQ(valid, params.valid);
98  EXPECT_EQ(
99  out->computeChainDataLength(),
100  ptCopy->computeChainDataLength() + cipher->getCipherOverhead());
101  return out;
102 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr Params params[]
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
std::unique_ptr< folly::IOBuf > fizz::test::chunkIOBuf ( std::unique_ptr< IOBuf input,
size_t  chunks,
BufCreator  creator 
)

Definition at line 31 of file TestUtil.cpp.

References folly::gen::chunked(), folly::IOBuf::computeChainDataLength(), folly::IOBuf::countChainElements(), defaultCreator(), folly::chrono::floor(), i, folly::gen::move, folly::IOBuf::prependChain(), fizz::transformBuffer(), and uint8_t.

Referenced by TEST_P().

31  {
32  if (!creator) {
33  creator = defaultCreator;
34  }
35  // create IOBuf chunks
36  size_t inputLen = input->computeChainDataLength();
37  size_t chunkLen = floor((double)inputLen / (double)chunks);
38  std::unique_ptr<IOBuf> chunked;
39 
40  for (size_t i = 0; i < chunks - 1; ++i) {
41  auto buf = creator(chunkLen, i);
42  buf->append(chunkLen);
43  if (!chunked) {
44  chunked = std::move(buf);
45  } else {
46  chunked->prependChain(std::move(buf));
47  }
48  }
49 
50  size_t remainLen = inputLen - (chunks - 1) * chunkLen;
51  auto remain = creator(remainLen, chunks - 1);
52  remain->append(remainLen);
53  chunked->prependChain(std::move(remain));
54 
56  *input, *chunked, [](uint8_t* out, const uint8_t* in, size_t len) {
57  memcpy(out, in, len);
58  });
59 
60  CHECK_EQ(chunks, chunked->countChainElements());
61  return chunked;
62 }
auto chunks
std::unique_ptr< folly::IOBuf > defaultCreator(size_t len, size_t)
Definition: TestUtil.cpp:18
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
size_t countChainElements() const
Definition: IOBuf.cpp:493
void transformBuffer(const folly::IOBuf &in, folly::IOBuf &out, Func func)
Definition: IOBufUtil.h:38
void prependChain(std::unique_ptr< IOBuf > &&iobuf)
Definition: IOBuf.cpp:509
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
constexpr To floor(std::chrono::duration< Rep, Period > const &d)
Definition: Chrono.h:114
Chunked chunked(const Container &container, int chunkSize=256)
Definition: Parallel.h:49
std::unique_ptr<IOBuf> fizz::test::copyBuffer ( const folly::IOBuf buf)

Definition at line 69 of file OpenSSLEVPCipherTest.cpp.

References folly::IOBuf::copyBuffer(), and folly::IOBuf::prependChain().

Referenced by callDecrypt(), callEncrypt(), folly::IOBuf::copyBuffer(), folly::IOBuf::maybeCopyBuffer(), TEST(), TEST_F(), and folly::IOBuf::wrapBufferAsValue().

69  {
70  std::unique_ptr<IOBuf> out;
71  for (auto r : buf) {
72  if (out) {
74  } else {
75  out = IOBuf::copyBuffer(r);
76  }
77  }
78  return out;
79 }
void prependChain(std::unique_ptr< IOBuf > &&iobuf)
Definition: IOBuf.cpp:509
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
std::unique_ptr<IOBuf> fizz::test::createBuf ( size_t  len)

Definition at line 59 of file IOBufUtilTest.cpp.

References folly::IOBuf::create().

Referenced by TEST().

59  {
60  auto res = IOBuf::create(len);
61  res->append(len);
62  return res;
63 }
CertAndKey fizz::test::createCert ( std::string  cn,
bool  ca,
CertAndKey issuer 
)

Definition at line 35 of file Utilities.h.

References fizz::test::CertAndKey::cert, fizz::test::CertAndKey::key, folly::gen::move, name, string, throwIfNeq(), and throwIfNull().

Referenced by fizz::tool::fizzServerCommand(), fizz::server::test::FizzTestServer::FizzTestServer(), fizz::test::DefaultCertificateVerifierTest::SetUp(), and TEST_F().

35  {
36  folly::ssl::EvpPkeyUniquePtr pk(EVP_PKEY_new());
37  throwIfNull(pk, "private key creation failed");
38 
39  folly::ssl::X509UniquePtr crt(X509_new());
40  throwIfNull(crt, "cert creation failed");
41 
43  EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1));
44  throwIfNull(grp, "group creation failed");
45 
46  EC_GROUP_set_asn1_flag(grp.get(), OPENSSL_EC_NAMED_CURVE);
47  EC_GROUP_set_point_conversion_form(grp.get(), POINT_CONVERSION_UNCOMPRESSED);
48 
49  throwIfNeq(EC_GROUP_check(grp.get(), nullptr), 1, "group check failed");
50 
51  folly::ssl::EcKeyUniquePtr ec(EC_KEY_new());
52  throwIfNull(ec, "ec key creation error");
53 
54  throwIfNeq(EC_KEY_set_group(ec.get(), grp.get()), 1, "failed to set group");
55 
56  throwIfNeq(EC_KEY_generate_key(ec.get()), 1, "ec generation failed");
57 
58  throwIfNeq(
59  EVP_PKEY_set1_EC_KEY(pk.get(), ec.get()),
60  1,
61  "private key assignment failed");
62 
63  X509_set_version(crt.get(), 2);
64  static int serial = 0;
65  ASN1_INTEGER_set(X509_get_serialNumber(crt.get()), serial++);
66  X509_gmtime_adj(X509_get_notBefore(crt.get()), 0);
67  X509_gmtime_adj(X509_get_notAfter(crt.get()), 31536000);
68 
69  throwIfNeq(
70  X509_set_pubkey(crt.get(), pk.get()), 1, "public key assignment failed");
71 
72  X509_NAME* name = X509_get_subject_name(crt.get());
73  const std::vector<std::pair<std::string, std::string>> entries{
74  {"C", "US"}, {"O", "Facebook, Inc."}, {"CN", cn}};
75  for (const auto& entry : entries) {
76  throwIfNeq(
77  X509_NAME_add_entry_by_txt(
78  name,
79  entry.first.c_str(),
80  MBSTRING_ASC,
81  reinterpret_cast<const unsigned char*>(entry.second.c_str()),
82  -1,
83  -1,
84  0),
85  1,
86  std::string("failed to set name entry: ") + entry.first);
87  }
88 
89  if (ca) {
90  X509V3_CTX ctx;
91  X509V3_set_ctx_nodb(&ctx);
92  std::array<char, 8> constraint{"CA:TRUE"};
93  folly::ssl::X509ExtensionUniquePtr ext(X509V3_EXT_conf_nid(
94  nullptr, &ctx, NID_basic_constraints, constraint.data()));
95  throwIfNull(ext, "failed to create extension");
96  throwIfNeq(
97  X509_EXTENSION_set_critical(ext.get(), 1), 1, "failed to set critical");
98  throwIfNeq(
99  X509_add_ext(crt.get(), ext.get(), -1), 1, "failed to add extension");
100  }
101 
102  if (issuer) {
103  throwIfNeq(
104  X509_set_issuer_name(
105  crt.get(), X509_get_subject_name(issuer->cert.get())),
106  1,
107  "failed to set issuer");
108  if (X509_sign(crt.get(), issuer->key.get(), EVP_sha256()) == 0) {
109  throw std::runtime_error("failed to sign certificate");
110  }
111  } else {
112  throwIfNeq(
113  X509_set_issuer_name(crt.get(), name), 1, "failed to set issuer");
114  if (X509_sign(crt.get(), pk.get(), EVP_sha256()) == 0) {
115  throw std::runtime_error("failed to self-sign certificate");
116  }
117  }
118 
119  return {std::move(crt), std::move(pk)};
120 }
void throwIfNull(const A &a, const std::string &msg)
Definition: Utilities.h:29
std::unique_ptr< X509, X509Deleter > X509UniquePtr
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
const char * name
Definition: http_parser.c:437
std::unique_ptr< EC_GROUP, EcGroupDeleter > EcGroupUniquePtr
std::unique_ptr< X509_EXTENSION, X509ExtensionDeleter > X509ExtensionUniquePtr
const char * string
Definition: Conv.cpp:212
void throwIfNeq(const A &a, const B &b, const std::string &msg)
Definition: Utilities.h:22
std::unique_ptr<folly::IOBuf> fizz::test::defaultCreator ( size_t  len,
size_t   
)

Definition at line 18 of file TestUtil.cpp.

References folly::IOBuf::create().

Referenced by chunkIOBuf().

18  {
19  return IOBuf::create(len);
20 }
bool fizz::test::extensionsMatch ( const Extension expected,
const Extension actual 
)

Definition at line 168 of file HandshakeTypesTest.cpp.

References fizz::Extension::extension_data, and fizz::Extension::extension_type.

Referenced by TEST_F().

168  {
169  if (expected.extension_type != actual.extension_type) {
170  return false;
171  }
172  return folly::IOBufEqualTo()(
173  *expected.extension_data, *actual.extension_data);
174 }
static EvpPkeyUniquePtr fizz::test::generateKey ( )
static

Definition at line 26 of file RSAPSSSignatureTest.cpp.

Referenced by TEST_F().

26  {
27  std::unique_ptr<
28  EVP_PKEY_CTX,
30  ctx(EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr));
31  EVP_PKEY_keygen_init(ctx.get());
32  EVP_PKEY_CTX_set_rsa_keygen_bits(ctx.get(), 2048);
33  EVP_PKEY* keyPtr{nullptr};
34  EVP_PKEY_keygen(ctx.get(), &keyPtr);
35  return EvpPkeyUniquePtr(keyPtr);
36 }
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
folly::ssl::X509UniquePtr fizz::test::getCert ( folly::StringPiece  cert)

Definition at line 48 of file TestUtil.cpp.

References folly::Range< Iter >::data(), and folly::Range< Iter >::size().

Referenced by getCert< P256Test >(), getCert< P384Test >(), getCert< P521Test >(), getCert< RSATest >(), getCertData(), fizz::server::test::ServerProtocolTest::SetUp(), fizz::test::HandshakeTest::SetUp(), TEST(), fizz::server::test::TEST(), fizz::server::test::TEST_F(), and TEST_F().

48  {
49  BioUniquePtr bio(BIO_new(BIO_s_mem()));
50  CHECK(bio);
51  CHECK_EQ(BIO_write(bio.get(), cert.data(), cert.size()), cert.size());
52  X509UniquePtr x509(PEM_read_bio_X509(bio.get(), nullptr, nullptr, nullptr));
53  CHECK(x509);
54  return x509;
55 }
std::unique_ptr< X509, X509Deleter > X509UniquePtr
std::unique_ptr< BIO, BioDeleter > BioUniquePtr
constexpr size_type size() const
Definition: Range.h:431
constexpr Iter data() const
Definition: Range.h:446
template<typename T >
static ssl::X509UniquePtr fizz::test::getCert ( )
static

Referenced by TEST().

Definition at line 58 of file CertTest.cpp.

References getCert(), and kP256Certificate.

58  {
60 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41

Definition at line 63 of file CertTest.cpp.

References getCert(), and kP384Certificate.

63  {
65 }
constexpr folly::StringPiece kP384Certificate
Definition: TestUtil.h:74
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48

Definition at line 68 of file CertTest.cpp.

References getCert(), and kP521Certificate.

68  {
70 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
constexpr folly::StringPiece kP521Certificate
Definition: TestUtil.h:110

Definition at line 73 of file CertTest.cpp.

References getCert(), getKey(), and kRSACertificate.

73  {
75 }
constexpr folly::StringPiece kRSACertificate
Definition: TestUtil.h:159
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
std::unique_ptr< folly::IOBuf > fizz::test::getCertData ( folly::StringPiece  cert)

Definition at line 57 of file TestUtil.cpp.

References folly::ssl::OpenSSLCertUtils::derEncode(), and getCert().

57  {
58  return OpenSSLCertUtils::derEncode(*getCert(cert));
59 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
std::unique_ptr<Aead> fizz::test::getCipher ( const CipherParams params)

Definition at line 42 of file OpenSSLEVPCipherTest.cpp.

References fizz::test::CipherParams::cipher, cipher, fizz::TrafficKey::iv, fizz::test::CipherParams::iv, fizz::TrafficKey::key, fizz::test::CipherParams::key, folly::gen::move, and toIOBuf().

Referenced by fizz::test::AsyncFizzBaseTest::getApplicationProtocol(), fizz::test::MockAsyncFizzBase::getApplicationProtocol(), TEST(), and TEST_P().

42  {
43  std::unique_ptr<Aead> cipher;
44  switch (params.cipher) {
45  case CipherSuite::TLS_AES_128_GCM_SHA256:
46  cipher = std::make_unique<OpenSSLEVPCipher<AESGCM128>>();
47  break;
48  case CipherSuite::TLS_AES_256_GCM_SHA384:
49  cipher = std::make_unique<OpenSSLEVPCipher<AESGCM256>>();
50  break;
51  case CipherSuite::TLS_CHACHA20_POLY1305_SHA256:
52  cipher = std::make_unique<OpenSSLEVPCipher<ChaCha20Poly1305>>();
53  break;
54  case CipherSuite::TLS_AES_128_OCB_SHA256_EXPERIMENTAL:
55  cipher = std::make_unique<OpenSSLEVPCipher<AESOCB128>>();
56  break;
57  default:
58  throw std::runtime_error("Invalid cipher");
59  }
60 
61  TrafficKey trafficKey;
62  trafficKey.key = toIOBuf(params.key);
63  trafficKey.iv = toIOBuf(params.iv);
64  cipher->setKey(std::move(trafficKey));
65  cipher->setEncryptedBufferHeadroom(kHeadroom);
66  return cipher;
67 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
CipherSuite cipher
constexpr Params params[]
constexpr size_t kHeadroom
template<typename T >
static ssl::EvpPkeyUniquePtr fizz::test::getKey ( )
static

Definition at line 36 of file EncryptedRecordBench.cpp.

References fizz::TrafficKey::iv, fizz::TrafficKey::key, and toIOBuf().

Referenced by encryptGCM(), getCert< RSATest >(), folly::settings::detail::SettingCore< T >::set(), fizz::testing::TEST_P(), and TEST_P().

36  {
37  TrafficKey trafficKey;
38  trafficKey.key = toIOBuf("000102030405060708090A0B0C0D0E0F");
39  trafficKey.iv = toIOBuf("000102030405060708090A0B");
40  return trafficKey;
41 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
std::unique_ptr< folly::IOBuf > key
Definition: Aead.h:17
std::unique_ptr< folly::IOBuf > iv
Definition: Aead.h:18
EvpPkeyUniquePtr fizz::test::getKey ( const Params param)

Definition at line 204 of file ECKeyExchangeTest.cpp.

References getNid(), fizz::test::Params::priv, fizz::test::Params::privX, fizz::test::Params::privY, setPoint(), uint8_t, and folly::unhexlify().

204  {
205  auto privKeyBin = unhexlify(param.priv);
206  BIGNUMUniquePtr privateBn(
207  BN_bin2bn((uint8_t*)privKeyBin.c_str(), privKeyBin.size(), nullptr));
208  EcKeyUniquePtr privateKey(EC_KEY_new_by_curve_name(getNid(param)));
209  EC_KEY_set_private_key(privateKey.get(), privateBn.get());
210  setPoint(privateKey, param.privX, param.privY);
211  EvpPkeyUniquePtr pkeyPrivateKey(EVP_PKEY_new());
212  EVP_PKEY_set1_EC_KEY(pkeyPrivateKey.get(), privateKey.get());
213  return pkeyPrivateKey;
214 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
std::unique_ptr< BIGNUM, BIGNUMDeleter > BIGNUMUniquePtr
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
int getNid(const Params &param)
void setPoint(EcKeyUniquePtr &key, std::string x, std::string y)

Definition at line 81 of file CertTest.cpp.

References getPrivateKey(), and kP256Key.

81  {
82  return getPrivateKey(kP256Key);
83 }
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21

Definition at line 86 of file CertTest.cpp.

References getPrivateKey(), and kP384Key.

86  {
87  return getPrivateKey(kP384Key);
88 }
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
constexpr folly::StringPiece kP384Key
Definition: TestUtil.h:57

Definition at line 91 of file CertTest.cpp.

References getPrivateKey(), and kP521Key.

91  {
92  return getPrivateKey(kP521Key);
93 }
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
constexpr folly::StringPiece kP521Key
Definition: TestUtil.h:91

Definition at line 96 of file CertTest.cpp.

References getPrivateKey(), and kRSAKey.

96  {
97  return getPrivateKey(kRSAKey);
98 }
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
constexpr folly::StringPiece kRSAKey
Definition: TestUtil.h:129
int fizz::test::getNid ( const Params param)

Definition at line 183 of file ECKeyExchangeTest.cpp.

References fizz::test::Params::key.

Referenced by getKey(), and TEST_P().

183  {
184  switch (param.key) {
185  case KeyType::P256:
186  return P256::curveNid;
187  case KeyType::P384:
188  return P384::curveNid;
189  case KeyType::P521:
190  return P521::curveNid;
191  default:
192  throw std::runtime_error("invalid key type");
193  }
194 }
std::shared_ptr<PeerCert> fizz::test::getPeerCert ( const CertAndKey cert)

Definition at line 122 of file Utilities.h.

References fizz::test::CertAndKey::cert.

Referenced by fizz::test::MockAsyncFizzBase::MockAsyncFizzBase(), fizz::test::AsyncFizzBaseTest::TearDown(), and TEST_F().

122  {
123  return std::make_shared<PeerCertImpl<KeyType::P256>>(
124  folly::ssl::X509UniquePtr(X509_dup(cert.cert.get())));
125 }
std::unique_ptr< X509, X509Deleter > X509UniquePtr
folly::ssl::EvpPkeyUniquePtr fizz::test::getPrivateKey ( StringPiece  key)

Definition at line 21 of file TestUtil.cpp.

References folly::Range< Iter >::data(), and folly::Range< Iter >::size().

Referenced by getKey< P256Test >(), getKey< P384Test >(), getKey< P521Test >(), getKey< RSATest >(), fizz::test::HandshakeTest::SetUp(), TEST(), TEST(), TEST_F(), and TYPED_TEST().

21  {
22  BioUniquePtr bio(BIO_new(BIO_s_mem()));
23  CHECK(bio);
24  CHECK_EQ(BIO_write(bio.get(), key.data(), key.size()), key.size());
25  EvpPkeyUniquePtr pkey(
26  PEM_read_bio_PrivateKey(bio.get(), nullptr, nullptr, nullptr));
27  CHECK(pkey);
28  return pkey;
29 }
std::unique_ptr< BIO, BioDeleter > BioUniquePtr
constexpr size_type size() const
Definition: Range.h:431
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
constexpr Iter data() const
Definition: Range.h:446
folly::ssl::EvpPkeyUniquePtr fizz::test::getPublicKey ( StringPiece  key)

Definition at line 31 of file TestUtil.cpp.

References folly::Range< Iter >::data(), and folly::Range< Iter >::size().

Referenced by TEST().

31  {
32  BioUniquePtr bio(BIO_new(BIO_s_mem()));
33  CHECK(bio);
34  CHECK_EQ(BIO_write(bio.get(), key.data(), key.size()), key.size());
35  EvpPkeyUniquePtr pkey(
36  PEM_read_bio_PUBKEY(bio.get(), nullptr, nullptr, nullptr));
37  CHECK(pkey);
38  return pkey;
39 }
std::unique_ptr< BIO, BioDeleter > BioUniquePtr
constexpr size_type size() const
Definition: Range.h:431
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
constexpr Iter data() const
Definition: Range.h:446
fizz::test::INSTANTIATE_TEST_CASE_P ( TestVectors  ,
HkdfTest  ,
::testing::Values(HashParams{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b","000102030405060708090a0b0c","f0f1f2f3f4f5f6f7f8f9", 42,"3cb25f25faacd57a90434f64d0362f2a""2d2d0a90cf1a5a4c5db02d56ecc4c5bf""34007208d5b887185865"}, HashParams{"000102030405060708090a0b0c0d0e0f""101112131415161718191a1b1c1d1e1f""202122232425262728292a2b2c2d2e2f""303132333435363738393a3b3c3d3e3f""404142434445464748494a4b4c4d4e4f","606162636465666768696a6b6c6d6e6f""707172737475767778797a7b7c7d7e7f""808182838485868788898a8b8c8d8e8f""909192939495969798999a9b9c9d9e9f""a0a1a2a3a4a5a6a7a8a9aaabacadaeaf","b0b1b2b3b4b5b6b7b8b9babbbcbdbebf""c0c1c2c3c4c5c6c7c8c9cacbcccdcecf""d0d1d2d3d4d5d6d7d8d9dadbdcdddedf""e0e1e2e3e4e5e6e7e8e9eaebecedeeef""f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", 82,"b11e398dc80327a1c8e7f78c596a4934""4f012eda2d4efad8a050cc4c19afa97c""59045a99cac7827271cb41c65e590e09""da3275600c2f09b8367793a9aca3db71""cc30c58179ec3e87c14c01d5c1f3434f""1d87"}, HashParams{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b","","", 42,"8da4e775a563c18f715f802a063c5a31""b8a11f5c5ee1879ec3454e5f3c738d2d""9d201395faa4b61a96c8"})   
)
fizz::test::INSTANTIATE_TEST_CASE_P ( TestVectors  ,
ECDHTest  ,
::testing::Values(Params{"e19007eb245d6995ffa8b3ede1e59193aa6cfaaf4cc1e1d126948610c9b3f44c","758b2f0e79a3d0a94f521ae31dcff50fabd394bb4bbec8fa37d1566f463444e7","b981e686e53e9e9dc2e3f263e810c89b4c271e62392f59ed45ed30ac3a5bfd33","8171000763de347d0eb650dd6fddac2ad48ec122c162d66c3df257aea13192fb","c22ac2ee50e771a93b2b6a42c5e9b76b45a56e0d0011e34aa790283ede61f3d9","0ef754edae5e79c518f1056aa5179cbb6a3a4b7c9654b5048f4259bd2597e57d","5cbea453310285b22f128178bd09b906fde9e660b5a17a7cec809a5a9a1e9287", true, KeyType::P256}, Params{"0ced658b6113979f8d05fd7b305ce0b8d70f45034d021b052cbcb318e0cfd602","acbcb31f5f6798a00f28aa4a634873744768db612925336efca98122a76d1b5e","7dcefeb3ccb530029a8b62e5a7f00c42fc7ebeac8f469c289ea77b6186d661f0","64e23f7a2d279930f1de66b4bc147786b168d059f581268c24f6650362246e63","ba393b401354aa9552c4289b7a55288d97590429a4003913a243081bacf88acf","d089687aa5442684d71b805ea2b36f6c1c783833346dfdd8208768ed2a7e767d","f70e4fc9ba68aafe07be1767620e64dd5e5bb7ab279f0657465cddeb69e36fa9", true, KeyType::P256}, Params{"0ced658b6113979f8d05fd7b305ce0b8d70f45034d021b052cbcb318e0cfd602","758b2f0e79a3d0a94f521ae31dcff50fabd394bb4bbec8fa37d1566f463444e7","b981e686e53e9e9dc2e3f263e810c89b4c271e62392f59ed45ed30ac3a5bfd33","8171000763de347d0eb650dd6fddac2ad48ec122c162d66c3df257aea13192fb","c22ac2ee50e771a93b2b6a42c5e9b76b45a56e0d0011e34aa790283ede61f3d9","0ef754edae5e79c518f1056aa5179cbb6a3a4b7c9654b5048f4259bd2597e57d","5cbea453310285b22f128178bd09b906fde9e660b5a17a7cec809a5a9a1e9287", true, KeyType::P256}, Params{"639ef9ee75a3888617fdd7ed89d62f7398b0eb4f20ccbd35026e150fc937c927","1d2dda4a3735be1f3aedfa8a7bb1410c3867c5d67f55a3dd5376b137352f113d","eca92fb210b1813f51ea2483ff461eb24786afb41f1a00870cf65aab5bbd725e","e062138981049c3b4b964fa5a28569e0142c2c51d6ca0bebdb3270e2ab77fb30","9aa8dd75f7d929b1f5f123aa9f3265be34f771c20bb50deea684a139a10938f8","2b74f503fa7b08db1c76d97c2e571cb91f68a93413daf102c47fee1b8a264d93","9f5f64d76f9bb2f2af24debdd47323d5df9d2b84fc7c7aac1f6d41678adec7de", false, KeyType::P256}, Params{"305dfb4a8850cc59280891147baf457bfe5e2bae984571634a77dc8d3472fa9b","202cb5a224e6c2a84e624094486edf04116c8d68ec1f4a0e0ed9ee090e1a900b","cacf3a5789bb33954be600425d62d9eae5371f90f88167258814213e4a4f4b1a","72cc52808f294b64b6f7233c3d2f5d96cc1d29287320e39e1c151deef0bc14eb","49a768c9a4ca56e374f685dd76a461b1016c59dcded2c8d8cbd9f23ca453831f","b1e3bb9b5f12a3b5ae788535d4554bd8c46e0e6130075e4e437d3854cf8f1c34","c0147c3c2691b450b5edc08b51aea224d9f4359ff67aab6da3146f396dbceaea", false, KeyType::P256}, Params{"0e5c98ff2d2a3aab14ad0067b60dbe64e4f541ab5bed11c5a0c55ae1e60b51ff5faaf377837977d80cbfdc33c2ff542b","d1bf2ac21637d66d6398aac01dcd56ac6f065fb45d1f6f16747bab9e9b01b4630b59b20927aea147355bf41838acb482","4c9e23f1c5a41647d094086bf4ed31708651f21d996c47780688ac10f77deee2e43b5241b6caecd2fd5444bc50472e0e","f865418473e5bf7d2e1bbcd9bd5a9270c003a9dd35e778133ca59fcab4bb64fe24d6800e7047bdd033abc8bfa8db35b5","32b72ab9b558249dcbc6cbade234f58e4f7aa5d3f6420ea99a5f997e8c2a91fb7fd83779d0d2169428683771c745fd1a","c749e02a3719bb56bf1dfc4ba3820309c01ab6e84cb29db7cdd80f127233f5295687f8178f3a8704c1063b84c2ee472f","a781430e6078a179df3f9ee27cd8fdc6188f161b6c4ccc4053ef6c6ca6fc222946883a53c06db08f0a020023ced055aa", true, KeyType::P384}, Params{"925065e50f7eae1319865720ae483de4dba7449dc144c4b50b8e96c4f4fcd9f8b3fbf693262429c91c69d8dd8355fdd8","4c619593e459e4aca7c572834064134d93e8b1b676388b0ff67b893722cf7e8396cd953df38a42e4131dbad29518b2af","dbe261af918baade39070e88f62eabe4ee9d5f2563707271cc566dd7a2380aa4707d15d6eef142a52d75a67429afd0c6","c40c805488115e43279c99797bcbfff8d9922ea9aec471d9ba659590034c3fb739d23661c0aae6e7ada2a1de36eb63a1","a95b7ad4de234e9be8b260313ddb96a404b75b3a7e0f234981f3b189d86ac31bbe3937776c0608024871ef64815784b3","4890ee227219ca5ce34632cbca5732accc2d276fa1b1cc9d14f6b7e4b0f5e116a92cbef743de3e69537e250f27125e82","128934db846099c8d8caa788b0b84bb65bd57b20774ff7f8e7f29939297d72bbc232c5d2b2c8ef1d63e3d75d3908e778", true, KeyType::P384}, Params{"259c53eec19d01d19428f6cc5cd445ab685578c53325f6d2f157bd0328deca4ffb8c21dca891d59e34a807203f7e9a5d","d18832f4cf3013e514b4fb4c42bbeb15708e20ed91b982598deb2d67b37275587fcb35cf214039ec4fd1834d704c1faf","917c49465bef063949957256eddbece762090ef10f8c48566bd71dc0ad9eb3bc00f0b3f6a88d614210804dd633ca6e68","3120ee90dcce02bac90a66d30ad602e94edcce482dbc5245a136df1d0509b04f6ee305fedd290775c71f1631684f5c0a","7a3e0fd767acf409cebe6fe0222974438bccdefb13f0d668b8daad43a6fdbdf46845c45b9594ffd6742a615dd834f1a5","e3cc9f7153b6ffd3b285349996b952905466942d17f6a9685a11318b0c2c72904961d246cbe3ef98903dbbfb0fbe55b0","5c8d476518873208e1c97685c033a1ba6ec279b8674060cc1a99469908604353043bf488109150b9b2f9b3b1440a426c", true, KeyType::P384}, Params{"4e422a76b085ae939a8166afb98e344b9ac30bab610e90b3d7449de0a0de6b88fadb095e4818521bb1473540a7ec73ee","de464ed2129eef42ef23cb1bfad27382293edad91d867b1b8b82a19bd17516daf0a73548787a733d66ca4f4d40b52da1","f07bd6003229de37d6293513cbace59ebc24efb571c065df2bc1465c4570928fd612a59a46805b6adce7fb94e36ad043","f8f6697507aeec09fe024f974e00e67f12a14c130df875732b450b3ae8d2cbbb1fcf46bac9207e89a297352eeade7df5","c1db2e81eca0e5b02e8736ff351aa8e59bdadd1c9c7428faf93493c7b93153ec2c55964a157025ff6ddb4523d8e0a453","98daa370a6610ecf604e38e1e70b7f57657c49908eb15634a3a65a175ca7b8cfe1ad535037928ae95c80107a1e018b3c","d80415977c3ce1737fd574596e981c767ecaf5c70084fae6c2072f0ccecc8bdda54a0bf44357981303a2ecc78b26e97c", false, KeyType::P384}, Params{"4ee6a24b5dca82b215c92cb298d5ac24b77820c7b7e9c8fe4d05d7a297b8f6be40f8d8cf09a4bb238cfdbe05f851c493","1f9af3b14439d4c56b353b5892dd85b6a27053e1d23f5f05ff95ea3fa942eb463e1074b01828a79c865b16fde0fc0f24","01a81aaef502fe84508b054924d90078f68d8d4e9ae5299bd0ea60a97167c549011f4a024e964292d378e82b6874caad","3d715cd0d6490ba5607e7eae2c74361be65de413f10576c1d996658e20c78f8110c70104067922d48303f6ccb1b23f46","2fa7d2ea93945b41c929279a750ded758d9db93d120b5eeda3d9994e36e3381f653d19dcae0eccb1a12153ce4025a62e","04c6e45983485529e9dacba8d609cffaec849f7c5e5cf4a025ce2c0ff9ae6679b4564b9af58fab58c7f92837597b830b","5e77e466aeae9c10ff8d255e07cf0ad9eae50c8a6fd2c7cd889d73d968c423a15c0462b05bf985cbf679a629e380ce80", false, KeyType::P384}, Params{"0000002fef62381162942889a6094a6bb9ac1f4ddf66d9cda9f618232d31b90c50d7da78a47ed91d40cae946898571db972dc294b109815f38feee9eaac0d5f7c3250728","0000004b05ffa025113390797f2736174aa1c784f4dd34e764ee40d40e4d2442677ebea3498086c9473e5c92789cbdb02bb327bbd61d58690f6a83d9ca73bccbde37dec4","0000004da67cffc98070b82af61feba78787efefb13bd810d80ff92304788e49a4e5b634b3565474a8ecb1615d7b1b77a7a27875adb73a8a5d8f3f84e5e8b744cda250b0","00000311a5e520e238141527671a38cb6f776d96a9f82ef70dffa11dc0895f4060f1abbb9ad6fd259e4a7beaf5f7266ea1bb45bcbfebfda2705e5c551e710fb1d745f57e","0000010ba3778cb2cc965834c0a9593adc6a222692656d657fb0d15293edf0ab33762384a96a16fddea7540b7ccbcca46ec4ac9bcf95fdb5aa18e158aab4d91981bd733e","0000018522df93ddd636e5bc94daecdc600fa241686ec18634fd30b7cbdfdc9ffba1166ac08df34a31896f6fad191414929261ebd7187afb72919f8a0c926be37f99c1e5","01a5e4b31be4b1346e53906b6767b1fe94ec1a8a5abc28fb6f01518c056959af3bc9335dddab178b52318cc5512559931b8dc18de0ce810c2c7f15769d7ce70e719c", false, KeyType::P521}, Params{"0000013262b7f4f36de274b2c60e4a812866740e545186953f798ac07b5d74e4f0cc1123a9bfcbf77850e2d856246065c54a2437a2816a7d79d6180a9a6ba17f18df8b65","000001474af758238005238b2fa253c4f9c557de664d64c66d7d88f334555997591ccc242ff3c6d0e34d07fc835aaae024c2bd21f2ba5c0b0a8ac3fdd90e1c479cb8e538","000000a721b04654204ca19064b37a4abf4247413a6d29e9211a0df9d50975c7d8d4654dc04a478455ea24993f0fef5460f189c4729c15fba385fd85ef42ae7610e39450","000001a23de55fb7ad153e7e65d21ad10c77fdf2072b2a5aa116aaf1bc31a345420c1fe8eaccbbcdeb07b73ba2fa706c7498e3a4828f348b00af9df1551780e709a7754c","000000ed7bc3a95ef74dc3a9893a5ec7c9fab723c16dc21b30341c374c25e1334dada7f92d62967f3bca4da70b0a77fa0732dac05a3d19cb04e50b3cd1894549ac1d3c6e","000001c30d23ea4c140aabfba3753ce40c788010342c15c51d2dd6e9b079194e593ba965ea419ef37746f954027fa1b8159ccd3b54aece67451c7e892d6f6e1fb44c548c","01e8ff7a8c57b017f8b8266adab65fe2c417173566087e15c5fc972071cc560ac93908a806468bc44b8312a8a48464886ca0d767db938447387a348f3f56c6463796", true, KeyType::P521}, Params{"000000364b6cc953c841d2e1c8c292fadaa673ea073d150da4cec9c0c6544c92373c6a42a781283bedb080a4de720b99769869019a38023019b9d15c99b2a08a02104cc7","000001abbbcd3912723cbb3147145a12b8f2f40d1fe6484fa831250435ffb8eb751bccdf425e81d8e79518ec84c56bd28763c417f30a16c213abbfd8e5871d93dcb3f0d0","00000237c413a4527ca89dee7c8a5c45fc0207627e3db79353ee506857d68f746ea2c7b4d04ab1c10df56b1a706012f616ec9a5510467c49a56941841a1636f620dc3ac4","000000e04b0e32496f1d43ff48d759dc57d586c6c55efb6460fc1148021afa1943180aea2a1be7721a69ebf9d55585a4d4bdb6ff3e177448568c0b45542eddb936fbd870","00000195a305d23a94794e680b211b8ec4a5c2150a2002afdc4ff5da254c438b5686b12dda72bd8dbb009d07d469c3d664e67da274de7f2e2dc84661d2a054638cf6fc98","000000e56b77c46a997c06da59033e1c57939f6f8513329ebe93dcb00857a8ff850428473d937528e85c15a5fe46df1ffb7aeed4b17f7fc9ad08fb121045e2eea5a316b2","013eeaad91133eb338a4c1f27af66aa7f7614619b6c21c20f0e2d68fca2e9cbaa224104a45aa4dbefcb1e49b7f1a36171a35102d2b7d2ffbade07e600b4a7e28c05c", false, KeyType::P521}, Params{"000001ef093db892daaa05d43e70654bd702d7e177465b00a5ff70a9a072774d7cda3893c181ad1dbb23f8352d3098025406a442c60afaf949dd37ee9c36ee2f785dc693","0000017e817b93e7e3eb95291545afffa2dcd1ff90b97c2b7d9cc7a46511cbdf7a7afe7a2ce126822d08bc71519542743dfece750e18f1e01bb5201e622e2697e5b1faa6","00000025e5e302514ccb15ed84291ba30746b1176f2b080bfa78ef7ce5721fd00d3d717421932d61ad74068c36885a9a0e6537183209a79054fcb8df43b83066f60c47d5","0000004e9f4ebd9f4772df7c003828210d087aa41c0154394428f5f8624536a15c157634c5200de037e46698d4f8484feb164374899b2d9d5e258080dae6b3429c965154","0000021fb91b2abbdd7dee5e2750a1fce602e235a6512b429ab0a3845bd8c8a630d9d35850e0ba78f01c01ffae6ca1a88c93c153a6fdc09f76fae768bdd449e7f6730b68","0000005cb38e5272648f2adcb5ec7a37f3b2135c93a0202f2c822383eae29468392f4baeddabf0acd3bee0cbc1dd540b435d34ecb008408ac093978976741d1afa374c72","01bca2f6325ccf7a6a213b2678ded8ce3e687497c7f7f46a4a06bf3e69dabb745a883d130936c786debf2fe5ef8880f1bb976a79e33b68d30d7356b5a4672e65fcea", false, KeyType::P521}, Params{"0000014199e2e81aa1f98bf0f39d069e720820d0433222f5b8ca26606fe7c4d0cd619b415d2a629674479a6ec6171f05f657a168aad9342e8489a39cf485a396a8400c59","00000070ce983ca6d0a7aa7849bef13e11e3dc1d62e1ddb85b54d4a3c9de5b47a078846f92105304efe4a4e71d7ff91c19a7b4e03fd87c2d8fb70732e274b114a0bf3bd2","0000009f564f73a5c7282556437dc4c2fbdf87d5fcfbaab0feecf1f7a88104f15a7314b083f711bd7b3a2c74b1096fdccdac01e0a35b8fd86d99ba9d64d10e190033c3df","000000c0b19361224245482bbe42110f9aa44f2818b5146710c24b4825a9a3e0a4743fc7983df560bd85d30639bbdb4d7fc0c56a862e0ef349801bef06ed0a9774463e9f","000000231f2c5c2ad3894b81ad2c8942221d06041f37b8d520e926701b9fb38e32833f9b2b99142d0e54baef33c17b2bd0f23ec3e1b08b9a87f65942384e5863607ba65c","0000005e3b734d4207b51259a1fca526161250176eab1364930d7d06259f43e68202962d9bb818a44bf3bf4a385e634a8d52489c58e2c9234670ae9f30668a2f5553c261","01186d749c6b2a215c59df35ef6f2f6ed1745a9b2e15fca225e79faa7c5b9af44821d50765b45c3c66e210ec78d4bccb7f8c44c19cf80f5357938df48e320fa1ed88", true, KeyType::P521})   
)

Referenced by TEST_P().

fizz::test::INSTANTIATE_TEST_CASE_P ( AESGCM128TestVectors  ,
OpenSSLEVPCipherTest  ,
::testing::Values(CipherParams{"87f6c12b1ae8a9b7efafc65af0f5c994","479e25839c19e0476f95a6f5", 1,"","010015","9d4db5ecd768198892531eebac72cf1d477dd0", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"911dc107aa6eccb6706bdcc37e76a07a","11c7fa13e9499ed042b09e57", 0,"","14000020de15cbc8c62d0e6fef73a6d4e70e5c372c2b94fe08ea40d11166a7e6c967ba9c16","56a21739148c898fe807026a179d59202647a3b1e01267a3883cf5f69fd233f63ff12c1c71b4c8f3d6086affb49621f96b842e1d35", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cae6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec5c241e994fb7d889e1b61d1db2b9be6777f5a393", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"fda2a4404670808f4937478b8b6e3fe1","b5f3a3fae1cb25c9dcd73993", 0,"","0800001e001c000a00140012001d00170018001901000101010201030104000000000b0001b9000001b50001b0308201ac30820115a003020102020102300d06092a864886f70d01010b0500300e310c300a06035504031303727361301e170d3136303733303031323335395a170d3236303733303031323335395a300e310c300a0603550403130372736130819f300d06092a864886f70d010101050003818d0030818902818100b4bb498f8279303d980836399b36c6988c0c68de55e1bdb826d3901a2461eafd2de49a91d015abbc9a95137ace6c1af19eaa6af98c7ced43120998e187a80ee0ccb0524b1b018c3e0b63264d449a6d38e22a5fda430846748030530ef0461c8ca9d9efbfae8ea6d1d03e2bd193eff0ab9a8002c47428a6d35a8d88d79f7f1e3f0203010001a31a301830090603551d1304023000300b0603551d0f0404030205a0300d06092a864886f70d01010b05000381810085aad2a0e5b9276b908c65f73a7267170618a54c5f8a7b337d2df7a594365417f2eae8f8a58c8f8172f9319cf36b7fd6c55b80f21a03015156726096fd335e5e67f2dbf102702e608ccae6bec1fc63a42a99be5c3eb7107c3c54e9b9eb2bd5203b1c3b84e0a8b2f759409ba3eac9d91d402dcc0cc8f8961229ac9187b42b4de100000f000084080400804547d6168f2510c550bd949cd2bc631ff134fa10a827ff69b166a6bd95e249ed0daf571592ebbe9ff13de6b03acc218146781f693b5a692b7319d74fd2e53b6a2df0f6785d624f024a44030ca00b869ae81a532b19e47e525ff4a62c51a5889eb565fee268590d8a3ca3c1bc3bd5404e39720ca2eaee308f4e0700761e986389140000209efee03ebffbc0dc23d26d958744c09e3000477eff7ae3148a50e5670013aaaa16","c1e631f81d2af221ebb6a957f58f3ee266272635e67f99a752f0df08adeb33bab8611e55f33d72cf84382461a8bfe0a659ba2dd1873f6fcc707a9841cefc1fb03526b9ca4fe343e5805e95a5c01e56570638a76a4bc8feb07be879f90568617d905fecd5b1619fb8ec4a6628d1bb2bb224c490ff97a6c0e9acd03604bc3a59d86bdab4e084c1c1450f9c9d2afeb172c07234d739868ebd62de2060a8de989414a82920dacd1cac0c6e72ecd7f4018574ceaca6d29f361bc37ee2888b8e302ca9561a9de9163edfa66badd4894884c7b359bcacae5908051b37952e10a45fe73fda126ebd67575f1bed8a992a89474d7dec1eed327824123a414adb66d5ef7d0836ff98c2cdd7fb0781e192bf0c7568bf7d890a51c332879b5037b212d622412ca48e8323817bd6d746eef683845cec4e3ef64b3a18fcce513ea951f3366693a7ff490d09d08ab1f63e13625a545961599c0d9c7a099d1163cad1b9bcf8e917d766b98853ef6877834f891df16be1fcc9c18ea1882ea3f1f4b64358e1b146cebfb3e02e153fdb73af2693f22c6f593fa475380ba6611740ad20e319a654ac5684775236162e8447ed808861bfbda6e18ec97ae090bf703475cfb90fe20a3c55bef6f5eba6e6a1da6a1996b8bde42180608ca2279def8e8153895cc850db6420561c04b5729cc6883436ea02ee07eb9baee2fb3a9e1bbda8730d6b220576e24df70af6928eb865fee8a1d1c0f1818aca68d5002ae4c65b2f49c9e6e21dcf76784adbd0e887a36832ef85beb10587f16c6ffe60d7451059ec7f1014c3efe19e56aedb5ad31a9f29dc4458cfbf0c7070c175dcad46e1675226b47c071aad3172ebd33e45d741cb91253a01a69ae3cc292bce9c03246ac951e45e97ebf04a9d51fab5cf06d9485cce746b1c077be69ad153f1656ef89fc7d1ed8c3e2da7a2", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cbe6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec5c241e994fb7d889e1b61d1db2b9be6777f5a393", false, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"a0f49e7076cae6eb25ca23a2da0eaf12","3485d33f22128dff91e47062", 0,"","41424344454617","92fdec", false, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"AD7A2BD03EAC835A6F620FDCB506B345","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","701AFA1CC039C0D765128A665DAB69243899BF7318CCDC81C9931DA17FBE8EDD7D17CB8B4C26FC81E3284F2B7FBA713D4F8D55E7D3F06FD5A13C0C29B9D5B880", true, CipherSuite::TLS_AES_128_GCM_SHA256}, CipherParams{"AD7A2BD03EAC835A6F620FDCB506B345","12153524C0895E81B2C28465", 0,"D609B1F056637A1D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","701AFA1CC039C0D765128A665DAB69243899BF7318CCDC81C9931DA17FBE8EDD7D17CB8B4C26FC81E3284F2B7FBA713D4F8D55E7D3F06FD5A13C0C29B9D5B880", false, CipherSuite::TLS_AES_128_GCM_SHA256})   
)
fizz::test::INSTANTIATE_TEST_CASE_P ( AESGCM256TestVectors  ,
OpenSSLEVPCipherTest  ,
::testing::Values(CipherParams{"E3C08A8F06C6E3AD95A70557B23F75483CE33021A9C72B7025666204C69C0B72","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","E2006EB42F5277022D9B19925BC419D7A592666C925FE2EF718EB4E308EFEAA7C5273B394118860A5BE2A97F56AB78365CA597CDBB3EDB8D1A1151EA0AF7B436", true, CipherSuite::TLS_AES_256_GCM_SHA384}, CipherParams{"E3C08A8F06C6E3AD95A70557B23F75483CE33021A9C72B7025666204C69C0B72","12153524C0895E81B2C28465", 0,"D609B1F056637A0D46DF998D88E52E00B2C2846512153524C0895E81","08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0002","E2006EB42F5277022D9B19925BC419D7A592666C925FE2EF718EB4E308EFEAA7C5273B394118860A5BE2A97F56AB78365CA597CDBB3EDB8D1A1151EA1AF7B436", false, CipherSuite::TLS_AES_256_GCM_SHA384})   
)

Referenced by TEST_P().

Referenced by TEST_F().

fizz::test::MATCHER_P ( BufMatches  ,
expected  ,
""   
)

Definition at line 17 of file Matchers.h.

References folly::IOBuf::copyBuffer().

17  {
18  return folly::IOBufEqualTo()(folly::IOBuf::copyBuffer(expected), arg);
19 }
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::MATCHER_P ( RangeMatches  ,
expected  ,
""   
)

Definition at line 21 of file Matchers.h.

References folly::Range< Iter >::data(), and folly::Range< Iter >::size().

21  {
22  folly::StringPiece exp(expected);
23  return exp.size() == arg.size() &&
24  (exp.size() == 0 || memcmp(exp.data(), arg.data(), exp.size()) == 0);
25 }
fizz::test::MATCHER_P ( WriteNewSessionTicketMatches  ,
expected  ,
""   
)

Definition at line 36 of file FizzBaseTest.cpp.

References folly::IOBuf::copyBuffer().

36  {
37  return IOBufEqualTo()(IOBuf::copyBuffer(expected), arg.appToken);
38 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::MATCHER_P ( WriteMatches  ,
expected  ,
""   
)

Definition at line 40 of file FizzBaseTest.cpp.

References folly::IOBuf::copyBuffer().

40  {
41  return IOBufEqualTo()(IOBuf::copyBuffer(expected), arg.data);
42 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
void fizz::test::setPoint ( EcKeyUniquePtr key,
std::string  x,
std::string  y 
)

Definition at line 196 of file ECKeyExchangeTest.cpp.

References uint8_t, and folly::unhexlify().

Referenced by getKey(), and TEST_P().

196  {
197  auto binX = unhexlify(x);
198  auto binY = unhexlify(y);
199  BIGNUMUniquePtr numX(BN_bin2bn((uint8_t*)binX.data(), binX.size(), nullptr));
200  BIGNUMUniquePtr numY(BN_bin2bn((uint8_t*)binY.data(), binY.size(), nullptr));
201  EC_KEY_set_public_key_affine_coordinates(key.get(), numX.get(), numY.get());
202 }
Definition: InvokeTest.cpp:58
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
std::unique_ptr< BIGNUM, BIGNUMDeleter > BIGNUMUniquePtr
Definition: InvokeTest.cpp:65
fizz::test::TEST ( UtilsTest  ,
TestEqualWrongSize   
)

Definition at line 19 of file UtilsTest.cpp.

References a, b, and EXPECT_FALSE.

19  {
20  StringPiece a{"hi"};
21  StringPiece b{"hello"};
22  EXPECT_FALSE(CryptoUtils::equal(a, b));
23  EXPECT_FALSE(CryptoUtils::equal(b, a));
24 }
char b
char a
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST ( IOBufUtilTest  ,
TrimBytes   
)

Definition at line 19 of file IOBufUtilTest.cpp.

References folly::Range< Iter >::castToConst(), folly::IOBuf::copyBuffer(), folly::IOBuf::create(), folly::eq, EXPECT_EQ, EXPECT_TRUE, and fizz::trimBytes().

19  {
20  auto buf = IOBuf::copyBuffer("hello");
21  buf->prependChain(IOBuf::copyBuffer("world"));
22  buf->prependChain(IOBuf::copyBuffer("I"));
23  buf->prependChain(IOBuf::create(0));
24  buf->prependChain(IOBuf::copyBuffer("speak"));
25 
26  auto expected = IOBuf::copyBuffer("Ispeak");
27  auto bufExpected = IOBuf::copyBuffer("helloworld");
28  auto bufLen = buf->computeChainDataLength();
29  constexpr size_t trimLen = 6;
30  std::array<uint8_t, trimLen> trimData;
31  folly::MutableByteRange trim(trimData);
32  trimBytes(*buf, trim);
33 
35  EXPECT_EQ(expected->coalesce(), trim.castToConst());
36  EXPECT_EQ(bufLen - trimLen, buf->computeChainDataLength());
37  EXPECT_TRUE(eq(bufExpected, buf));
38 }
void trimBytes(IOBuf &buf, folly::MutableByteRange trimmed)
Definition: IOBufUtil.cpp:15
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST ( X25519KeyExchange  ,
KeyExchange   
)

Definition at line 20 of file X25519KeyExchangeTest.cpp.

References fizz::X25519KeyExchange::generateKeyPair(), fizz::X25519KeyExchange::generateSharedSecret(), folly::range(), and folly::unhexlify().

20  {
21  static constexpr StringPiece keyShareHex =
22  "c81e57c7485ba417280bc2d48d864afd3966ff77b684bfaf85f418f9b4583347";
23  auto keyShare = unhexlify(keyShareHex);
24  X25519KeyExchange kex;
25  kex.generateKeyPair();
26  auto out = kex.generateSharedSecret(folly::range(keyShare));
27 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
fizz::test::TEST ( RandomGeneratorTest  ,
TestRandom   
)

Definition at line 20 of file RandomGeneratorTest.cpp.

References EXPECT_EQ, random(), and useMockRandom().

20  {
21  useMockRandom();
22 
23  auto random = RandomGenerator<32>().generateRandom();
24  std::array<uint8_t, 32> expected;
25  expected.fill(0x44);
26  EXPECT_EQ(random, expected);
27 }
Integral2 random(Integral1 low, Integral2 up)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void useMockRandom()
Definition: TestUtil.cpp:69
fizz::test::TEST ( ValidateECKey  ,
GoodPrivateKey   
)

Definition at line 22 of file OpenSSLKeyUtilsTest.cpp.

References getPrivateKey(), kP256Key, and fizz::detail::validateECKey().

22  {
23  auto key = getPrivateKey(kP256Key);
24  detail::validateECKey(key, NID_X9_62_prime256v1);
25 }
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
void validateECKey(const folly::ssl::EvpPkeyUniquePtr &key, int curveNid)
fizz::test::TEST ( UtilTest  ,
GetAlpnFromNpn   
)

Definition at line 23 of file FizzUtilTest.cpp.

References folly::test::begin(), folly::test::end(), and EXPECT_EQ.

23  {
24  std::list<folly::SSLContext::NextProtocolsItem> npList;
25  std::list<std::string> protocolList1{"test", "test2"};
26  std::list<std::string> protocolList2{"test3", "test4"};
27 
28  npList.push_back(folly::SSLContext::NextProtocolsItem(1, protocolList1));
29  {
30  std::vector<std::string> expectedList{std::begin(protocolList1),
31  std::end(protocolList1)};
32  EXPECT_EQ(FizzUtil::getAlpnsFromNpnList(npList), expectedList);
33  }
34 
35  npList.push_back(folly::SSLContext::NextProtocolsItem(2, protocolList2));
36  {
37  std::vector<std::string> expectedList{std::begin(protocolList2),
38  std::end(protocolList2)};
39  EXPECT_EQ(FizzUtil::getAlpnsFromNpnList(npList), expectedList);
40  }
41 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
fizz::test::TEST ( ExporterTest  ,
TestExporterBasic   
)

Definition at line 24 of file ExporterTest.cpp.

References fizz::extensions::test::ekm, EXPECT_EQ, and folly::unhexlify().

24  {
25  auto ekm = Exporter::getEkm(
26  CipherSuite::TLS_AES_128_GCM_SHA256,
28  label,
29  nullptr,
30  32);
31 
33 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
StringPiece exporter_master
StringPiece basic_expected_ekm
Range< const char * > StringPiece
StringPiece label
fizz::test::TEST ( UtilsTest  ,
TestEqual   
)

Definition at line 26 of file UtilsTest.cpp.

References a, b, c, EXPECT_FALSE, and EXPECT_TRUE.

26  {
27  StringPiece a{"hello!!"};
28  StringPiece b{"hello!!"};
29  StringPiece c{"goodbye"};
30  EXPECT_TRUE(CryptoUtils::equal(a, b));
31  EXPECT_FALSE(CryptoUtils::equal(a, c));
32 }
char b
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
char c
fizz::test::TEST ( TestTypes  ,
WriteAndRead24BitsNormal   
)

Definition at line 26 of file TypesTest.cpp.

References folly::IOBuf::create(), EXPECT_EQ, fizz::detail::readBits24(), uint32_t, and fizz::detail::writeBits24().

26  {
27  uint32_t len = 0x102030;
28  auto buf = IOBuf::create(3);
29  Appender appender(buf.get(), 0);
30  detail::writeBits24(len, appender);
31 
32  EXPECT_EQ(0x10, buf->data()[0]);
33  EXPECT_EQ(0x20, buf->data()[1]);
34  EXPECT_EQ(0x30, buf->data()[2]);
35 
36  Cursor cursor(buf.get());
37  uint32_t actualLength = detail::readBits24(cursor);
38  EXPECT_EQ(len, actualLength);
39 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void writeBits24(T len, folly::io::Appender &out)
Definition: Types-inl.h:102
uint32_t readBits24(folly::io::Cursor &cursor)
Definition: Types-inl.h:210
fizz::test::TEST ( ValidateECKey  ,
GoodPubicKey   
)

Definition at line 27 of file OpenSSLKeyUtilsTest.cpp.

References getPublicKey(), kP256PublicKey, and fizz::detail::validateECKey().

27  {
28  auto key = getPublicKey(kP256PublicKey);
29  detail::validateECKey(key, NID_X9_62_prime256v1);
30 }
constexpr folly::StringPiece kP256PublicKey
Definition: TestUtil.h:26
void validateECKey(const folly::ssl::EvpPkeyUniquePtr &key, int curveNid)
EvpPkeyUniquePtr getPublicKey(StringPiece key)
Definition: TestUtil.cpp:31
fizz::test::TEST ( X25519KeyExchange  ,
SmallKeyExchange   
)

Definition at line 29 of file X25519KeyExchangeTest.cpp.

References EXPECT_THROW, fizz::X25519KeyExchange::generateKeyPair(), fizz::X25519KeyExchange::generateSharedSecret(), folly::range(), and folly::unhexlify().

29  {
30  static constexpr StringPiece keyShareHex = "c81e57c7485ba4";
31  auto keyShare = unhexlify(keyShareHex);
32  X25519KeyExchange kex;
33  kex.generateKeyPair();
35  kex.generateSharedSecret(folly::range(keyShare)), std::runtime_error);
36 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
fizz::test::TEST ( RandomGeneratorTest  ,
TestRandomUInt32   
)

Definition at line 29 of file RandomGeneratorTest.cpp.

References EXPECT_EQ, random(), and useMockRandom().

29  {
30  useMockRandom();
31 
32  auto random = RandomNumGenerator<uint32_t>().generateRandom();
33  EXPECT_EQ(random, 0x44444444);
34 }
Integral2 random(Integral1 low, Integral2 up)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void useMockRandom()
Definition: TestUtil.cpp:69
fizz::test::TEST ( ValidateECKey  ,
WrongKeyType   
)

Definition at line 32 of file OpenSSLKeyUtilsTest.cpp.

References EXPECT_THROW, getPrivateKey(), kRSAKey, and fizz::detail::validateECKey().

32  {
33  auto key = getPrivateKey(kRSAKey);
35  detail::validateECKey(key, NID_X9_62_prime256v1), std::runtime_error);
36 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
void validateECKey(const folly::ssl::EvpPkeyUniquePtr &key, int curveNid)
constexpr folly::StringPiece kRSAKey
Definition: TestUtil.h:129
fizz::test::TEST ( UtilsTest  ,
TestClean   
)

Definition at line 34 of file UtilsTest.cpp.

References a, EXPECT_EQ, and folly::range().

34  {
35  std::array<uint8_t, 8> a{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
36  CryptoUtils::clean(range(a));
37  for (auto byte : a) {
38  EXPECT_EQ(byte, 0);
39  }
40 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Gen range(Value begin, Value end)
Definition: Base.h:467
char a
fizz::test::TEST ( ValidateECKey  ,
WrongCurve   
)

Definition at line 38 of file OpenSSLKeyUtilsTest.cpp.

References EXPECT_THROW, getPrivateKey(), kP256Key, and fizz::detail::validateECKey().

38  {
39  auto key = getPrivateKey(kP256Key);
41  detail::validateECKey(key, NID_X9_62_prime239v3), std::runtime_error);
42 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
void validateECKey(const folly::ssl::EvpPkeyUniquePtr &key, int curveNid)
fizz::test::TEST ( ExportedAuthenticatorTest  ,
TestAuthenticatorRequest   
)

Definition at line 39 of file ExportedAuthenticatorTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, EXPECT_TRUE, folly::hexlify(), folly::gen::move, and folly::unhexlify().

39  {
41  folly::io::Cursor cursor(buf.get());
42  CertificateRequest cr = decode<CertificateRequest>(cursor);
43  EXPECT_EQ(cr.certificate_request_context->computeChainDataLength(), 20);
44  EXPECT_EQ(cr.extensions.size(), 1);
45  EXPECT_TRUE(getExtension<SignatureAlgorithms>(cr.extensions).hasValue());
46  auto encodedAuthRequest = ExportedAuthenticator::getAuthenticatorRequest(
47  std::move(cr.certificate_request_context), std::move(cr.extensions));
48  EXPECT_EQ(
50  StringPiece(hexlify(encodedAuthRequest->coalesce())));
51 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
Range< const char * > StringPiece
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
StringPiece expected_auth_request
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferInplace   
)

Definition at line 40 of file IOBufUtilTest.cpp.

References folly::IOBuf::copyBuffer(), folly::IOBuf::create(), folly::eq, EXPECT_TRUE, fizz::transformBuffer(), and uint8_t.

40  {
41  auto buf = IOBuf::copyBuffer("hello");
42  buf->prependChain(IOBuf::copyBuffer("world"));
43  buf->prependChain(IOBuf::copyBuffer("I"));
44  buf->prependChain(IOBuf::create(0));
45  buf->prependChain(IOBuf::copyBuffer("speak"));
46 
47  auto expected = IOBuf::create(buf->computeChainDataLength());
48  expected->append(buf->computeChainDataLength());
49  memset(expected->writableData(), 'w', expected->length());
50 
52  *buf, *buf, [](uint8_t* out, const uint8_t* /*in*/, size_t len) {
53  memset(out, 'w', len);
54  });
56  EXPECT_TRUE(eq(expected, buf));
57 }
void transformBuffer(const folly::IOBuf &in, folly::IOBuf &out, Func func)
Definition: IOBufUtil.h:38
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST ( TestTypes  ,
Write24BitsOverflow   
)

Definition at line 41 of file TypesTest.cpp.

References folly::IOBuf::create(), EXPECT_THROW, uint32_t, and fizz::detail::writeBits24().

41  {
42  uint32_t len = 0x10203040;
43  auto buf = IOBuf::create(3);
44  Appender appender(buf.get(), 0);
45  EXPECT_THROW(detail::writeBits24(len, appender), std::runtime_error);
46 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
void writeBits24(T len, folly::io::Appender &out)
Definition: Types-inl.h:102
fizz::test::TEST ( UtilTest  ,
CreateTickerCipher   
)

Definition at line 43 of file FizzUtilTest.cpp.

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

43  {
44  auto cipher = FizzUtil::createTicketCipher<server::AES128TicketCipher>(
45  std::vector<std::string>(),
46  "fakeSecretttttttttttttttttttttttttt",
47  std::vector<std::string>(),
48  // any number high enough to last the duration of the test should be fine
49  std::chrono::seconds(100),
50  folly::Optional<std::string>("fakeContext"));
51  {
52  server::ResumptionState state;
53  auto blob = cipher->encrypt(std::move(state)).get();
54  EXPECT_EQ(
55  std::get<0>(cipher->decrypt(std::move(std::get<0>(*blob))).get()),
56  PskType::Resumption);
57  }
58  {
59  auto newCipher = FizzUtil::createTicketCipher<server::AES128TicketCipher>(
60  std::vector<std::string>(),
61  "fakeSecrettttttttttttttttttttttttt2",
62  std::vector<std::string>(),
63  std::chrono::seconds(100),
64  folly::Optional<std::string>("fakeContext"));
65  server::ResumptionState state;
66  auto blob = cipher->encrypt(std::move(state)).get();
67  EXPECT_EQ(
68  std::get<0>(newCipher->decrypt(std::move(std::get<0>(*blob))).get()),
69  PskType::Rejected);
70  }
71 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
CipherSuite cipher
state
Definition: http_parser.c:272
fizz::test::TEST ( TestTypes  ,
Write24BitsBuffer   
)

Definition at line 48 of file TypesTest.cpp.

References folly::IOBuf::create(), and EXPECT_EQ.

48  {
49  auto buf = IOBuf::create(0x1020);
50  buf->append(0x1020);
51 
52  auto out = IOBuf::create(10);
53  Appender appender(out.get(), 10);
54  detail::writeBuf<detail::bits24>(buf, appender);
55  EXPECT_EQ(buf->length() + 3, out->computeChainDataLength());
56 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST ( ExportedAuthenticatorTest  ,
TestEmptyAuthenticatorRequest   
)

Definition at line 53 of file ExportedAuthenticatorTest.cpp.

References folly::IOBuf::create(), EXPECT_THROW, and folly::gen::move.

53  {
55  ExportedAuthenticator::getAuthenticatorRequest(
56  nullptr, std::vector<fizz::Extension>()),
57  FizzException);
58  auto emptyContext = folly::IOBuf::create(0);
60  ExportedAuthenticator::getAuthenticatorRequest(
61  std::move(emptyContext), std::vector<fizz::Extension>()),
62  FizzException);
63 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TEST ( TestTypes  ,
Write24BitsBufferOverflow   
)

Definition at line 58 of file TypesTest.cpp.

References folly::IOBuf::create(), EXPECT_THROW, and max.

58  {
59  auto buf = IOBuf::create(std::numeric_limits<uint32_t>::max());
61 
62  auto out = IOBuf::create(10);
63  Appender appender(out.get(), 0);
65  detail::writeBuf<detail::bits24>(buf, appender), std::runtime_error);
66 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
LogLevel max
Definition: LogLevel.cpp:31
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferWithFragmentedBuffer   
)

Definition at line 65 of file IOBufUtilTest.cpp.

References folly::IOBuf::copyBuffer(), folly::IOBuf::create(), createBuf(), folly::eq, EXPECT_TRUE, folly::gen::move, fizz::transformBuffer(), and uint8_t.

65  {
66  auto buf = IOBuf::copyBuffer("hello");
67  buf->prependChain(IOBuf::copyBuffer("world"));
68  buf->prependChain(IOBuf::copyBuffer("I"));
69  buf->prependChain(IOBuf::create(0));
70  buf->prependChain(IOBuf::copyBuffer("speak"));
71 
72  // needs to add up to 16
73  auto fragmented = createBuf(3);
74  auto fragment1 = createBuf(6);
75  auto fragment2 = createBuf(0);
76  auto fragment3 = createBuf(2);
77  auto fragment4 = createBuf(4);
78  auto fragment5 = createBuf(1);
79 
80  fragmented->prependChain(std::move(fragment1));
81  fragmented->prependChain(std::move(fragment2));
82  fragmented->prependChain(std::move(fragment3));
83  fragmented->prependChain(std::move(fragment4));
84  fragmented->prependChain(std::move(fragment5));
85 
87  *buf, *fragmented, [](uint8_t* out, const uint8_t* in, size_t len) {
88  memcpy(out, in, len);
89  });
91  EXPECT_TRUE(eq(buf, fragmented));
92 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void transformBuffer(const folly::IOBuf &in, folly::IOBuf &out, Func func)
Definition: IOBufUtil.h:38
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST ( TestTypes  ,
WriteBuf   
)

Definition at line 68 of file TypesTest.cpp.

References folly::IOBuf::create(), and EXPECT_EQ.

68  {
69  auto buf = IOBuf::create(20);
70  buf->append(20);
71 
72  auto out1 = IOBuf::create(10);
73  Appender appender1(out1.get(), 10);
74  detail::writeBuf<uint16_t>(buf, appender1);
75  EXPECT_EQ(2 + buf->length(), out1->computeChainDataLength());
76 
77  auto out2 = IOBuf::create(10);
78  Appender appender2(out2.get(), 10);
79  detail::writeBuf<uint64_t>(buf, appender2);
80  EXPECT_EQ(8 + buf->length(), out2->computeChainDataLength());
81 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST ( UtilTest  ,
ReadPKey   
)

Definition at line 73 of file FizzUtilTest.cpp.

References EXPECT_THROW, kP256Key, folly::test::TemporaryFile::path(), and folly::writeFileAtomic().

73  {
74  {
75  folly::test::TemporaryFile testFile("test");
76  folly::writeFileAtomic(testFile.path().native(), kP256Key);
77  FizzUtil::readPrivateKey(testFile.path().native(), "");
78  }
79  {
80  folly::test::TemporaryFile testFile("test");
82  testFile.path().native(), folly::StringPiece("test"));
84  FizzUtil::readPrivateKey(testFile.path().native(), ""),
85  std::runtime_error);
86  }
87 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
void writeFileAtomic(StringPiece filename, iovec *iov, int count, mode_t permissions)
Definition: FileUtil.cpp:224
Range< const char * > StringPiece
fizz::test::TEST ( UtilTest  ,
ReadChainFile   
)

Definition at line 89 of file FizzUtilTest.cpp.

References EXPECT_EQ, EXPECT_THROW, kP256Certificate, kP384Key, folly::test::TemporaryFile::path(), folly::size(), and folly::writeFileAtomic().

89  {
90  {
91  folly::test::TemporaryFile testFile("test");
92  folly::writeFileAtomic(testFile.path().native(), kP256Certificate);
93  EXPECT_EQ(FizzUtil::readChainFile(testFile.path().native()).size(), 1);
94  }
95  {
96  folly::test::TemporaryFile testFile("test");
97  folly::writeFileAtomic(testFile.path().native(), kP384Key);
99  FizzUtil::readChainFile(testFile.path().native()), std::runtime_error);
100  }
101  {
102  EXPECT_THROW(
103  FizzUtil::readChainFile("test_file_does_not_exist"),
104  std::runtime_error);
105  }
106 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void writeFileAtomic(StringPiece filename, iovec *iov, int count, mode_t permissions)
Definition: FileUtil.cpp:224
constexpr folly::StringPiece kP384Key
Definition: TestUtil.h:57
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST ( ContextTest  ,
TestAscendingVersionsNotSet   
)

Definition at line 93 of file TokenBindingTest.cpp.

References EXPECT_EQ, EXPECT_THROW, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_10, fizz::extensions::token_binding_0_11, and fizz::extensions::token_binding_0_12.

93  {
94  std::vector<TokenBindingProtocolVersion> ascending{
95  TokenBindingProtocolVersion::token_binding_0_10,
96  TokenBindingProtocolVersion::token_binding_0_11,
97  TokenBindingProtocolVersion::token_binding_0_12};
99  auto before = ctx.getSupportedVersions();
100  EXPECT_THROW(ctx.setSupportedVersions(ascending), std::runtime_error);
101  auto after = ctx.getSupportedVersions();
102  EXPECT_EQ(before, after);
103 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( ContextTest  ,
TestShuffledNotSet   
)

Definition at line 105 of file TokenBindingTest.cpp.

References EXPECT_EQ, EXPECT_THROW, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_10, fizz::extensions::token_binding_0_12, and fizz::extensions::token_binding_0_13.

105  {
106  std::vector<TokenBindingProtocolVersion> shuffled{
107  TokenBindingProtocolVersion::token_binding_0_10,
108  TokenBindingProtocolVersion::token_binding_0_13,
109  TokenBindingProtocolVersion::token_binding_0_12};
111  auto before = ctx.getSupportedVersions();
112  EXPECT_THROW(ctx.setSupportedVersions(shuffled), std::runtime_error);
113  auto after = ctx.getSupportedVersions();
114  EXPECT_EQ(before, after);
115 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( CertTest  ,
GetIdentity   
)

Definition at line 111 of file CertTest.cpp.

References fizz::certificate, EXPECT_EQ, fizz::SelfCertImpl< T >::getAltIdentities(), getCert(), fizz::SelfCertImpl< T >::getIdentity(), getPrivateKey(), kP256Certificate, kP256Key, and folly::gen::move.

111  {
112  auto cert = getCert(kP256Certificate);
113  auto key = getPrivateKey(kP256Key);
114  std::vector<folly::ssl::X509UniquePtr> certs;
115  certs.push_back(std::move(cert));
116  SelfCertImpl<KeyType::P256> certificate(std::move(key), std::move(certs));
117  EXPECT_EQ(certificate.getIdentity(), "Fizz");
118  EXPECT_EQ(certificate.getAltIdentities().size(), 0);
119 }
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
static ssl::X509UniquePtr getCert()
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST ( ContextTest  ,
TestDoubleNotSet   
)

Definition at line 117 of file TokenBindingTest.cpp.

References EXPECT_EQ, EXPECT_THROW, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_10, and fizz::extensions::token_binding_0_11.

117  {
118  std::vector<TokenBindingProtocolVersion> two{
119  TokenBindingProtocolVersion::token_binding_0_10,
120  TokenBindingProtocolVersion::token_binding_0_11};
122  auto before = ctx.getSupportedVersions();
123  EXPECT_THROW(ctx.setSupportedVersions(two), std::runtime_error);
124  auto after = ctx.getSupportedVersions();
125  EXPECT_EQ(before, after);
126 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( CertTest  ,
GetAltIdentity   
)

Definition at line 121 of file CertTest.cpp.

References fizz::certificate, EXPECT_EQ, fizz::SelfCertImpl< T >::getAltIdentities(), getCert(), fizz::SelfCertImpl< T >::getIdentity(), getPrivateKey(), kRSACertificate, kRSAKey, and folly::gen::move.

121  {
122  auto cert = getCert(kRSACertificate);
123  auto key = getPrivateKey(kRSAKey);
124  std::vector<folly::ssl::X509UniquePtr> certs;
125  certs.push_back(std::move(cert));
126  SelfCertImpl<KeyType::RSA> certificate(std::move(key), std::move(certs));
127  EXPECT_EQ(certificate.getIdentity(), "Fizz");
128  auto alts = certificate.getAltIdentities();
129  EXPECT_EQ(alts.size(), 3);
130  EXPECT_EQ(alts[0], "*.fizz.com");
131  EXPECT_EQ(alts[1], "fizz.com");
132  EXPECT_EQ(alts[2], "example.net");
133 }
constexpr folly::StringPiece kRSACertificate
Definition: TestUtil.h:159
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
static ssl::X509UniquePtr getCert()
constexpr folly::StringPiece kRSAKey
Definition: TestUtil.h:129
fizz::test::TEST ( ContextTest  ,
TestEmptySet   
)

Definition at line 128 of file TokenBindingTest.cpp.

References folly::empty(), EXPECT_EQ, fizz::extensions::TokenBindingContext::getSupportedVersions(), and fizz::extensions::TokenBindingContext::setSupportedVersions().

128  {
129  std::vector<TokenBindingProtocolVersion> empty;
131  ctx.setSupportedVersions(empty);
132  auto after = ctx.getSupportedVersions();
133  EXPECT_EQ(empty, after);
134 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
constexpr auto empty(C const &c) -> decltype(c.empty())
Definition: Access.h:55
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocks   
)

Definition at line 129 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), createBuf(), folly::eq, EXPECT_TRUE, gmock_output_test::output, and uint8_t.

129  {
130  // 2 blocks of size 8
131  auto buf = IOBuf::copyBuffer("0000111122223333");
132  auto output = createBuf(16);
133 
134  BlockWriter writer;
135  transformBufferBlocks<8>(
136  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
137  return writer.copy(out, in, len);
138  });
140  EXPECT_TRUE(eq(buf, output));
141 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST ( CertTest  ,
GetCertMessage   
)

Definition at line 135 of file CertTest.cpp.

References ASSERT_EQ, fizz::certificate, EXPECT_EQ, getCert(), fizz::SelfCertImpl< T >::getCertMessage(), getPrivateKey(), kP256Certificate, kP256Key, and folly::gen::move.

135  {
136  auto cert = getCert(kP256Certificate);
137  auto key = getPrivateKey(kP256Key);
138  std::vector<folly::ssl::X509UniquePtr> certs;
139  certs.push_back(std::move(cert));
140  SelfCertImpl<KeyType::P256> certificate(std::move(key), std::move(certs));
141  auto msg = certificate.getCertMessage();
142  ASSERT_EQ(msg.certificate_list.size(), 1);
143  auto& firstCertEntry = msg.certificate_list[0];
144  auto firstCertData = firstCertEntry.cert_data->coalesce();
145  auto firstCertDataPtr = firstCertData.data();
146  folly::ssl::X509UniquePtr firstEncodedCert(
147  d2i_X509(nullptr, &firstCertDataPtr, firstCertData.size()));
148  CHECK(firstEncodedCert);
149 
150  auto certCopy = getCert(kP256Certificate);
151  EXPECT_EQ(X509_cmp(firstEncodedCert.get(), certCopy.get()), 0);
152 }
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
std::unique_ptr< X509, X509Deleter > X509UniquePtr
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
static ssl::X509UniquePtr getCert()
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST ( ContextTest  ,
TestSingleSet   
)

Definition at line 136 of file TokenBindingTest.cpp.

References EXPECT_EQ, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), single, and fizz::extensions::token_binding_0_10.

136  {
137  std::vector<TokenBindingProtocolVersion> single{
138  TokenBindingProtocolVersion::token_binding_0_10};
141  auto after = ctx.getSupportedVersions();
142  EXPECT_EQ(single, after);
143 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
countdownsingle single
fizz::test::TEST ( ExportedAuthenticatorTest  ,
TestGetContext   
)

Definition at line 138 of file ExportedAuthenticatorTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, folly::hexlify(), folly::gen::move, and folly::unhexlify().

138  {
139  StringPiece authenticator = {
140  "0b00020f14303132333435363738396162636465666768696a0001f70001f2308201ee30820195a003020102020900c569eec901ce86d9300a06082a8648ce3d0403023054310b3009060355040613025553310b300906035504080c024e59310b300906035504070c024e59310d300b060355040a0c0446697a7a310d300b060355040b0c0446697a7a310d300b06035504030c0446697a7a301e170d3137303430343138323930395a170d3431313132343138323930395a3054310b3009060355040613025553310b300906035504080c024e59310b300906035504070c024e59310d300b060355040a0c0446697a7a310d300b060355040b0c0446697a7a310d300b06035504030c0446697a7a3059301306072a8648ce3d020106082a8648ce3d030107034200049d87bcaddb65d8dcf6df8b148a9679b5b710db19c95a9badfff13468cb358b4e21d24a5c826112658ebb96d64e2985dfb41c1948334391a4aa81b67837e2dbf0a350304e301d0603551d0e041604143c5b8ba954d9752faf3c8ad6d1a62449dccaa850301f0603551d230418301680143c5b8ba954d9752faf3c8ad6d1a62449dccaa850300c0603551d13040530030101ff300a06082a8648ce3d04030203470030440220349b7d34d7132fb2756576e0bfa36cbe1723337a7a6f5ef9c8d3bf1aa7efa4a5022025c50a91e0aa4272f1f52c3d5583a7d7cee14b178835273a0bd814303e62d71400000f00004a04030046304402204ee36706cefd7b5de1b87eef8a756b1f69365451cae050163e030d7cb7594fbc022040aaadc7770b0404c5deb6fd9d9a2161423fb993a0a5b9e38f2c0e0d9183a52d1400002001dd31f46369c46fe41712e83ae7c46d31fdae816024edbb3b58cc29e2234852"};
141  auto buf = folly::IOBuf::copyBuffer(unhexlify(authenticator));
142  auto certRequestContext =
143  ExportedAuthenticator::getAuthenticatorContext(std::move(buf));
144  EXPECT_EQ(
146  StringPiece(hexlify(certRequestContext->coalesce())));
147 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
StringPiece expected_cr_context
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Range< const char * > StringPiece
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocksSplit   
)

Definition at line 143 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), createBuf(), folly::eq, EXPECT_TRUE, folly::gen::move, gmock_output_test::output, and uint8_t.

143  {
144  // 1 block of size 8
145  auto buf = IOBuf::copyBuffer("0000");
146  buf->prependChain(IOBuf::copyBuffer("1111"));
147  auto output = createBuf(4);
148  auto fragment1 = createBuf(4);
149  output->prependChain(std::move(fragment1));
150 
151  BlockWriter writer;
152  transformBufferBlocks<8>(
153  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
154  return writer.copy(out, in, len);
155  });
157  EXPECT_TRUE(eq(buf, output));
158 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST ( ContextTest  ,
TestDescendingVersionsSet   
)

Definition at line 145 of file TokenBindingTest.cpp.

References EXPECT_EQ, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_10, fizz::extensions::token_binding_0_11, and fizz::extensions::token_binding_0_12.

145  {
146  std::vector<TokenBindingProtocolVersion> descending{
147  TokenBindingProtocolVersion::token_binding_0_12,
148  TokenBindingProtocolVersion::token_binding_0_11,
149  TokenBindingProtocolVersion::token_binding_0_10};
151  ctx.setSupportedVersions(descending);
152  auto after = ctx.getSupportedVersions();
153  EXPECT_EQ(descending, after);
154 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( CertTest  ,
PrepareSignData   
)

Definition at line 155 of file CertTest.cpp.

References EXPECT_EQ, folly::hexlify(), folly::range(), and string.

155  {
156  std::array<uint8_t, 32> toBeSigned;
157  memset(toBeSigned.data(), 1, toBeSigned.size());
158  auto out = CertUtils::prepareSignData(
159  CertificateVerifyContext::Server, folly::range(toBeSigned));
160  auto hex = hexlify(out->moveToFbString());
161  std::string expected =
162  "2020202020202020202020202020202020202020202020202020202020202020"
163  "2020202020202020202020202020202020202020202020202020202020202020"
164  "544c5320312e332c207365727665722043657274696669636174655665726966"
165  "79"
166  "00"
167  "0101010101010101010101010101010101010101010101010101010101010101";
168  EXPECT_EQ(hex, expected);
169 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
const char * string
Definition: Conv.cpp:212
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
fizz::test::TEST ( ContextTest  ,
TestDoubleSet   
)

Definition at line 156 of file TokenBindingTest.cpp.

References EXPECT_EQ, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_10, and fizz::extensions::token_binding_0_11.

156  {
157  std::vector<TokenBindingProtocolVersion> two{
158  TokenBindingProtocolVersion::token_binding_0_11,
159  TokenBindingProtocolVersion::token_binding_0_10};
161  ctx.setSupportedVersions(two);
162  auto after = ctx.getSupportedVersions();
163  EXPECT_EQ(two, after);
164 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocksInputFragmented   
)

Definition at line 160 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), folly::IOBuf::create(), folly::eq, EXPECT_TRUE, gmock_output_test::output, and uint8_t.

160  {
161  // do 3 blocks
162  auto buf = IOBuf::copyBuffer("00");
163  buf->prependChain(IOBuf::copyBuffer("00"));
164  buf->prependChain(IOBuf::copyBuffer("1"));
165  buf->prependChain(IOBuf::create(0));
166  buf->prependChain(IOBuf::copyBuffer("11122223"));
167  buf->prependChain(IOBuf::copyBuffer("33344"));
168  buf->prependChain(IOBuf::copyBuffer("44"));
169  buf->prependChain(IOBuf::copyBuffer("5555"));
170 
171  auto output = IOBuf::create(24);
172  output->append(24);
173 
174  BlockWriter writer;
175  transformBufferBlocks<8>(
176  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
177  return writer.copy(out, in, len);
178  });
180  EXPECT_TRUE(eq(buf, output));
181 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST ( ContextTest  ,
TestDescendingDuplicatesNotSet   
)

Definition at line 166 of file TokenBindingTest.cpp.

References EXPECT_EQ, EXPECT_THROW, fizz::extensions::TokenBindingContext::getSupportedVersions(), fizz::extensions::TokenBindingContext::setSupportedVersions(), fizz::extensions::token_binding_0_11, and fizz::extensions::token_binding_0_12.

166  {
167  std::vector<TokenBindingProtocolVersion> duplicate{
168  TokenBindingProtocolVersion::token_binding_0_12,
169  TokenBindingProtocolVersion::token_binding_0_11,
170  TokenBindingProtocolVersion::token_binding_0_11};
172  auto before = ctx.getSupportedVersions();
173  EXPECT_THROW(ctx.setSupportedVersions(duplicate), std::runtime_error);
174  auto after = ctx.getSupportedVersions();
175  EXPECT_EQ(before, after);
176 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setSupportedVersions(std::vector< TokenBindingProtocolVersion > versions)
fizz::test::TEST ( CertTest  ,
MakePeerCertEmpty   
)

Definition at line 171 of file CertTest.cpp.

References folly::IOBuf::copyBuffer(), and EXPECT_THROW.

171  {
172  EXPECT_THROW(
173  CertUtils::makePeerCert(IOBuf::copyBuffer("")), std::runtime_error);
174 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::TEST ( CertTest  ,
MakePeerCertJunk   
)

Definition at line 176 of file CertTest.cpp.

References folly::IOBuf::copyBuffer(), and EXPECT_THROW.

176  {
177  EXPECT_THROW(
178  CertUtils::makePeerCert(IOBuf::copyBuffer("blah")), std::runtime_error);
179 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::TEST ( CertTest  ,
PeerCertGetX509   
)

Definition at line 181 of file CertTest.cpp.

References EXPECT_NE, getCert(), fizz::PeerCertImpl< T >::getX509(), and kP256Certificate.

181  {
182  PeerCertImpl<KeyType::P256> peerCert(getCert(kP256Certificate));
183  auto x509 = peerCert.getX509();
184  EXPECT_NE(x509.get(), nullptr);
185 }
static ssl::X509UniquePtr getCert()
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocksOutputFragmented   
)

Definition at line 183 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), createBuf(), folly::eq, EXPECT_TRUE, gmock_output_test::output, and uint8_t.

183  {
184  // 3 blocks of 8
185  auto buf = IOBuf::copyBuffer("fizzbuzzfizzbuzzfizzbuzz");
186 
187  // needs to add up to 24
188  auto output = createBuf(3);
189  output->prependChain(createBuf(6));
190  output->prependChain(createBuf(0));
191  output->prependChain(createBuf(2));
192  output->prependChain(createBuf(4));
193  output->prependChain(createBuf(1));
194  output->prependChain(createBuf(1));
195  output->prependChain(createBuf(7));
196 
197  BlockWriter writer;
198  transformBufferBlocks<8>(
199  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
200  return writer.copy(out, in, len);
201  });
203  EXPECT_TRUE(eq(buf, output));
204 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocksInputFragmented2   
)

Definition at line 206 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), createBuf(), folly::eq, EXPECT_TRUE, gmock_output_test::output, and uint8_t.

206  {
207  auto buf = IOBuf::copyBuffer("1111111122222222");
208  auto output = createBuf(10);
209  output->prependChain(createBuf(6));
210  BlockWriter writer;
211  transformBufferBlocks<8>(
212  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
213  return writer.copy(out, in, len);
214  });
216  EXPECT_TRUE(eq(buf, output));
217 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST ( IOBufUtilTest  ,
TransformBufferBlocksFragmented   
)

Definition at line 219 of file IOBufUtilTest.cpp.

References fizz::test::BlockWriter::copy(), folly::IOBuf::copyBuffer(), folly::IOBuf::create(), createBuf(), folly::eq, EXPECT_TRUE, gmock_output_test::output, and uint8_t.

219  {
220  auto buf = IOBuf::copyBuffer("00");
221  buf->prependChain(IOBuf::copyBuffer("00"));
222  buf->prependChain(IOBuf::copyBuffer("1"));
223  buf->prependChain(IOBuf::create(0));
224  buf->prependChain(IOBuf::copyBuffer("11122223"));
225  buf->prependChain(IOBuf::copyBuffer("33344"));
226  buf->prependChain(IOBuf::copyBuffer("44"));
227  buf->prependChain(IOBuf::copyBuffer("5555"));
228 
229  // needs to add up to 24
230  auto output = createBuf(3);
231  output->prependChain(createBuf(6));
232  output->prependChain(createBuf(0));
233  output->prependChain(createBuf(2));
234  output->prependChain(createBuf(4));
235  output->prependChain(createBuf(1));
236  output->prependChain(createBuf(1));
237  output->prependChain(createBuf(7));
238 
239  BlockWriter writer;
240  transformBufferBlocks<8>(
241  *buf, *output, [&writer](uint8_t* out, const uint8_t* in, size_t len) {
242  return writer.copy(out, in, len);
243  });
245  EXPECT_TRUE(eq(buf, output));
246 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< IOBuf > createBuf(size_t len)
fizz::test::TEST_F ( HandshakeContextTest  ,
TestHandshakeContextSingle   
)

Definition at line 22 of file HandshakeContextTest.cpp.

References context, folly::IOBuf::copyBuffer(), fizz::kHkdfLabelPrefix, and folly::Range< Iter >::str().

22  {
23  HandshakeContextImpl<Sha256> context(kHkdfLabelPrefix.str());
24  context.appendToTranscript(folly::IOBuf::copyBuffer("ClientHello"));
25  context.getHandshakeContext();
26 }
std::string str() const
Definition: Range.h:591
context
Definition: CMakeCache.txt:563
constexpr folly::StringPiece kHkdfLabelPrefix
Definition: Types.h:20
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::TEST_F ( HandshakeContextTest  ,
TestHandshakeContextMultiple   
)

Definition at line 28 of file HandshakeContextTest.cpp.

References context, folly::IOBuf::copyBuffer(), fizz::kHkdfLabelPrefix, and folly::Range< Iter >::str().

28  {
29  HandshakeContextImpl<Sha256> context(kHkdfLabelPrefix.str());
30  context.appendToTranscript(folly::IOBuf::copyBuffer("ClientHello"));
31  context.appendToTranscript(folly::IOBuf::copyBuffer("ServerHello"));
32  context.getHandshakeContext();
33 }
std::string str() const
Definition: Range.h:591
context
Definition: CMakeCache.txt:563
constexpr folly::StringPiece kHkdfLabelPrefix
Definition: Types.h:20
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::TEST_F ( ExtensionsTest  ,
TokenBindingParameters   
)

Definition at line 35 of file TokenBindingTest.cpp.

References fizz::extensions::ecdsap256, EXPECT_EQ, folly::gen::move, fizz::extensions::token_binding_0_13, and tokenBinding.

35  {
36  auto exts = getExtensions(tokenBinding);
37  auto ext = getExtension<TokenBindingParameters>(exts);
38 
39  EXPECT_EQ(ext->version, TokenBindingProtocolVersion::token_binding_0_13);
40  EXPECT_EQ(ext->key_parameters_list.size(), 1);
41  EXPECT_EQ(ext->key_parameters_list[0], TokenBindingKeyParameters::ecdsap256);
42 
43  checkEncode(std::move(*ext), tokenBinding);
44 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece tokenBinding
fizz::test::TEST_F ( HandshakeContextTest  ,
TestFinished   
)

Definition at line 35 of file HandshakeContextTest.cpp.

References context, folly::IOBuf::copyBuffer(), fizz::kHkdfLabelPrefix, folly::range(), and folly::Range< Iter >::str().

35  {
36  HandshakeContextImpl<Sha256> context(kHkdfLabelPrefix.str());
37  context.appendToTranscript(folly::IOBuf::copyBuffer("ClientHello"));
38  std::vector<uint8_t> baseKey(Sha256::HashLen);
39  context.getFinishedData(range(baseKey));
40 }
std::string str() const
Definition: Range.h:591
context
Definition: CMakeCache.txt:563
Gen range(Value begin, Value end)
Definition: Base.h:467
constexpr folly::StringPiece kHkdfLabelPrefix
Definition: Types.h:20
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::TEST_F ( ExtensionsTest  ,
TestProtocolNameList   
)

Definition at line 36 of file ExtensionsTest.cpp.

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

36  {
37  auto exts = getExtensions(alpn);
38  auto ext = getExtension<ProtocolNameList>(exts);
39 
40  EXPECT_EQ(ext->protocol_name_list.size(), 3);
41  EXPECT_EQ(
42  StringPiece(ext->protocol_name_list[0].name->coalesce()),
43  StringPiece("h2"));
44  EXPECT_EQ(
45  StringPiece(ext->protocol_name_list[1].name->coalesce()),
46  StringPiece("spdy/3.1"));
47  EXPECT_EQ(
48  StringPiece(ext->protocol_name_list[2].name->coalesce()),
49  StringPiece("http/1.1"));
50 
51  checkEncode(std::move(*ext), alpn);
52 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece alpn
Range< const char * > StringPiece
fizz::test::TEST_F ( KeySchedulerTest  ,
TestEarly   
)

Definition at line 38 of file KeySchedulerTest.cpp.

References testing::_, and EXPECT_CALL.

38  {
39  StringPiece psk{"psk"};
40  EXPECT_CALL(*kd_, hkdfExtract(_, _));
41  ks_->deriveEarlySecret(psk);
42  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(4);
43  ks_->getSecret(EarlySecrets::ExternalPskBinder, transcript_);
44  ks_->getSecret(EarlySecrets::ResumptionPskBinder, transcript_);
45  ks_->getSecret(EarlySecrets::ResumptionPskBinder, transcript_);
46  ks_->getSecret(EarlySecrets::EarlyExporter, transcript_);
47 
48  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
49  EXPECT_CALL(*kd_, hkdfExtract(_, _));
50  ks_->deriveHandshakeSecret();
51  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
52  ks_->getSecret(HandshakeSecrets::ClientHandshakeTraffic, transcript_);
53  ks_->getSecret(HandshakeSecrets::ServerHandshakeTraffic, transcript_);
54 
55  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
56  EXPECT_CALL(*kd_, hkdfExtract(_, _));
57  ks_->deriveMasterSecret();
58  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
59  ks_->getSecret(MasterSecrets::ExporterMaster, transcript_);
60  ks_->getSecret(MasterSecrets::ResumptionMaster, transcript_);
61 
62  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
63  ks_->deriveAppTrafficSecrets(transcript_);
64  ks_->getSecret(AppTrafficSecrets::ClientAppTraffic);
65  ks_->getSecret(AppTrafficSecrets::ServerAppTraffic);
66 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( RSAPSSTest  ,
TestSignVerify   
)

Definition at line 38 of file RSAPSSSignatureTest.cpp.

References generateKey(), fizz::OpenSSLSignature< T >::setKey(), folly::sig, fizz::OpenSSLSignature< T >::sign(), and fizz::OpenSSLSignature< T >::verify().

38  {
39  OpenSSLSignature<KeyType::RSA> rsa;
40  rsa.setKey(generateKey());
41  static constexpr StringPiece msg{"message"};
42  auto sig = rsa.sign<SignatureScheme::rsa_pss_sha256>(msg);
43  rsa.verify<SignatureScheme::rsa_pss_sha256>(msg, sig->coalesce());
44 }
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
static EvpPkeyUniquePtr generateKey()
fizz::test::TEST_F ( HandshakeContextTest  ,
TestEmpty   
)

Definition at line 42 of file HandshakeContextTest.cpp.

References context, fizz::kHkdfLabelPrefix, folly::range(), and folly::Range< Iter >::str().

42  {
43  HandshakeContextImpl<Sha256> context(kHkdfLabelPrefix.str());
44  context.getHandshakeContext();
45  std::array<uint8_t, Sha256::HashLen> key{4};
46  context.getFinishedData(folly::range(key));
47 }
std::string str() const
Definition: Range.h:591
context
Definition: CMakeCache.txt:563
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
constexpr folly::StringPiece kHkdfLabelPrefix
Definition: Types.h:20
fizz::test::TEST_F ( CertDecompressionManagerTest  ,
TestBasic   
)

Definition at line 43 of file CertDecompressionManagerTest.cpp.

References EXPECT_EQ.

43  {
44  auto decomp1 = makeMockDecompressor(1);
45  auto decomp2 = makeMockDecompressor(2);
46 
47  manager_->setDecompressors(
48  {std::static_pointer_cast<CertificateDecompressor>(decomp1),
49  std::static_pointer_cast<CertificateDecompressor>(decomp2)});
50 
51  auto supported = manager_->getSupportedAlgorithms();
52  EXPECT_EQ(supported.size(), 2);
53  EXPECT_EQ(supported[0], toAlgo(1));
54  EXPECT_EQ(supported[1], toAlgo(2));
55  auto fetchedDecomp1 = manager_->getDecompressor(toAlgo(1));
56  auto fetchedDecomp2 = manager_->getDecompressor(toAlgo(2));
57  auto invalidDecomp = manager_->getDecompressor(toAlgo(3));
58  EXPECT_EQ(decomp1, fetchedDecomp1);
59  EXPECT_EQ(decomp2, fetchedDecomp2);
60  EXPECT_EQ(invalidDecomp, nullptr);
61 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST_F ( ExtensionsTest  ,
TokenBindingMessageFromChrome   
)

Definition at line 46 of file TokenBindingTest.cpp.

References fizz::extensions::ecdsap256, fizz::encode(), EXPECT_EQ, EXPECT_TRUE, folly::gen::move, fizz::extensions::provided_token_binding, and tokenBindingMessage.

46  {
47  auto buf = getBuf(tokenBindingMessage);
48  auto message = decode<TokenBindingMessage>(std::move(buf));
49  EXPECT_EQ(message.tokenbindings.size(), 1);
50  auto& tokenbinding = message.tokenbindings.front();
51  EXPECT_EQ(
52  tokenbinding.tokenbinding_type, TokenBindingType::provided_token_binding);
53  auto& id = tokenbinding.tokenbindingid;
54  EXPECT_EQ(id.key_parameters, TokenBindingKeyParameters::ecdsap256);
55 
56  // 32 * 2 for the key + 1 for size of point
57  EXPECT_EQ(id.key->computeChainDataLength(), 65);
58 
59  // No extensions
60  EXPECT_EQ(tokenbinding.extensions->computeChainDataLength(), 0);
61 
62  // 32 * 2 for the signature with this algorithm
63  EXPECT_EQ(tokenbinding.signature->computeChainDataLength(), 64);
64  auto encodedBuf = encode(std::move(message));
65  EXPECT_TRUE(folly::IOBufEqualTo()(encodedBuf, buf));
66 }
Definition: test.c:42
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece tokenBindingMessage
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( RSAPSSTest  ,
TestVerifyDifferent   
)

Definition at line 46 of file RSAPSSSignatureTest.cpp.

References EXPECT_THROW, generateKey(), fizz::OpenSSLSignature< T >::setKey(), folly::sig, fizz::OpenSSLSignature< T >::sign(), and fizz::OpenSSLSignature< T >::verify().

46  {
47  OpenSSLSignature<KeyType::RSA> rsa;
48  rsa.setKey(generateKey());
49  static constexpr StringPiece msg1{"message"};
50  static constexpr StringPiece msg2{"somethingelse"};
51  auto sig = rsa.sign<SignatureScheme::rsa_pss_sha256>(msg1);
53  rsa.verify<SignatureScheme::rsa_pss_sha256>(msg2, sig->coalesce()),
54  std::runtime_error);
55 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
static EvpPkeyUniquePtr generateKey()
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestReadEmpty   
)

Definition at line 49 of file PlaintextRecordTest.cpp.

References EXPECT_FALSE.

49  {
50  EXPECT_FALSE(read_.read(queue_).hasValue());
51 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifySuccess   
)

Definition at line 50 of file DefaultCertificateVerifierTest.cpp.

References getPeerCert(), and verifier_.

50  {
51  verifier_->verify({getPeerCert(leafCertAndKey_)});
52 }
std::shared_ptr< PeerCert > getPeerCert(const CertAndKey &cert)
Definition: Utilities.h:122
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestReadHandshake   
)

Definition at line 53 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_TRUE.

53  {
54  addToQueue("16030100050123456789");
55  auto msg = read_.read(queue_);
56  EXPECT_EQ(msg->type, ContentType::handshake);
57  expectSame(msg->fragment, "0123456789");
58  EXPECT_TRUE(queue_.empty());
59 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( ExtensionsTest  ,
TestServerNameList   
)

Definition at line 54 of file ExtensionsTest.cpp.

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

54  {
55  auto exts = getExtensions(sni);
56  auto ext = getExtension<ServerNameList>(exts);
57 
58  EXPECT_EQ(ext->server_name_list.size(), 1);
59  EXPECT_EQ(ext->server_name_list[0].name_type, ServerNameType::host_name);
60  EXPECT_EQ(
61  StringPiece(ext->server_name_list[0].hostname->coalesce()),
62  StringPiece("www.facebook.com"));
63 
64  checkEncode(std::move(*ext), sni);
65 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece sni
Range< const char * > StringPiece
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifyWithIntermediates   
)

Definition at line 54 of file DefaultCertificateVerifierTest.cpp.

References createCert(), getPeerCert(), and verifier_.

54  {
55  auto subauth = createCert("subauth", true, &rootCertAndKey_);
56  auto subleaf = createCert("subleaf", false, &subauth);
57  verifier_->verify({getPeerCert(subleaf), getPeerCert(subauth)});
58 }
std::shared_ptr< PeerCert > getPeerCert(const CertAndKey &cert)
Definition: Utilities.h:122
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( RSAPSSTest  ,
TestVerifyFailure   
)

Definition at line 57 of file RSAPSSSignatureTest.cpp.

References EXPECT_THROW, generateKey(), fizz::OpenSSLSignature< T >::setKey(), folly::sig, fizz::OpenSSLSignature< T >::sign(), and fizz::OpenSSLSignature< T >::verify().

57  {
58  OpenSSLSignature<KeyType::RSA> rsa;
59  rsa.setKey(generateKey());
60  static constexpr StringPiece msg{"message"};
61  auto sig = rsa.sign<SignatureScheme::rsa_pss_sha256>(msg);
62  sig->writableData()[1] ^= 0x2;
64  rsa.verify<SignatureScheme::rsa_pss_sha256>(msg, sig->coalesce()),
65  std::runtime_error);
66 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
static EvpPkeyUniquePtr generateKey()
fizz::test::TEST_F ( RecordTest  ,
TestNoData   
)

Definition at line 59 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, testing::InvokeWithoutArgs(), folly::none, and fizz::detail::read().

59  {
60  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
61  return none;
62  }));
63  EXPECT_FALSE(read_.readEvent(queue_).hasValue());
64 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifySelfSignedCert   
)

Definition at line 60 of file DefaultCertificateVerifierTest.cpp.

References createCert(), EXPECT_THROW, and verifier_.

60  {
61  auto selfsigned = createCert("self", false, nullptr);
63  verifier_->verify({getPeerCert(selfsigned)}), std::runtime_error);
64 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestReadAlert   
)

Definition at line 61 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_TRUE.

61  {
62  addToQueue("15030100050123456789");
63  auto msg = read_.read(queue_);
64  EXPECT_EQ(msg->type, ContentType::alert);
65  expectSame(msg->fragment, "0123456789");
66  EXPECT_TRUE(queue_.empty());
67 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadEmpty   
)

Definition at line 62 of file EncryptedRecordTest.cpp.

References EXPECT_FALSE.

62  {
63  EXPECT_FALSE(read_.read(queue_).hasValue());
64 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( CertDecompressionManagerTest  ,
TestSameOverwrites   
)

Definition at line 63 of file CertDecompressionManagerTest.cpp.

References EXPECT_EQ, and EXPECT_NE.

63  {
64  auto decomp1 = makeMockDecompressor(1);
65  auto decomp2 = makeMockDecompressor(1);
66  auto decomp3 = makeMockDecompressor(2);
67 
68  manager_->setDecompressors(
69  {std::static_pointer_cast<CertificateDecompressor>(decomp1),
70  std::static_pointer_cast<CertificateDecompressor>(decomp2),
71  std::static_pointer_cast<CertificateDecompressor>(decomp3)});
72 
73  auto supported = manager_->getSupportedAlgorithms();
74  EXPECT_EQ(supported.size(), 2);
75  EXPECT_EQ(supported[0], toAlgo(1));
76  EXPECT_EQ(supported[1], toAlgo(2));
77  auto fetchedDecomp1 = manager_->getDecompressor(toAlgo(1));
78  auto fetchedDecomp2 = manager_->getDecompressor(toAlgo(2));
79  EXPECT_EQ(decomp2, fetchedDecomp1);
80  EXPECT_NE(decomp1, fetchedDecomp1);
81  EXPECT_EQ(decomp3, fetchedDecomp2);
82 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadHandshake   
)

Definition at line 66 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), and uint64_t.

66  {
67  addToQueue("17030100050123456789");
68  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
69  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
70  expectSame(buf, "0123456789");
71  return getBuf("abcdef16");
72  }));
73  auto msg = read_.read(queue_);
74  EXPECT_EQ(msg->type, ContentType::handshake);
75  expectSame(msg->fragment, "abcdef");
76  EXPECT_TRUE(queue_.empty());
77 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( RecordTest  ,
TestReadAppData   
)

Definition at line 66 of file RecordTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), EXPECT_CALL, EXPECT_TRUE, testing::InvokeWithoutArgs(), and fizz::detail::read().

66  {
67  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
68  return TLSMessage{ContentType::application_data, IOBuf::copyBuffer("hi")};
69  }));
70  auto param = read_.readEvent(queue_);
71  auto& appData = boost::get<AppData>(*param);
72  EXPECT_TRUE(eq_(appData.data, IOBuf::copyBuffer("hi")));
73 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifySelfSignedCertWithOverride   
)

Definition at line 66 of file DefaultCertificateVerifierTest.cpp.

References createCert(), getPeerCert(), and verifier_.

66  {
67  auto selfsigned = createCert("self", false, nullptr);
68  verifier_->setCustomVerifyCallback(
69  &DefaultCertificateVerifierTest::allowSelfSignedLeafCertCallback);
70  // Will not throw because the override allows for this type of error.
71  verifier_->verify({getPeerCert(selfsigned)});
72 }
std::shared_ptr< PeerCert > getPeerCert(const CertAndKey &cert)
Definition: Utilities.h:122
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( ExtensionsTest  ,
TestHelloRetryRequestKeyShare   
)

Definition at line 67 of file ExtensionsTest.cpp.

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

67  {
68  auto exts = getExtensions(helloRetryRequestKeyShare);
69  auto ext = getExtension<HelloRetryRequestKeyShare>(exts);
70 
71  EXPECT_EQ(ext->selected_group, NamedGroup::secp256r1);
72 
73  checkEncode(std::move(*ext), helloRetryRequestKeyShare);
74 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece helloRetryRequestKeyShare
fizz::test::TEST_F ( KeySchedulerTest  ,
TestEarlyEcdhe   
)

Definition at line 68 of file KeySchedulerTest.cpp.

References testing::_, and EXPECT_CALL.

68  {
69  StringPiece psk{"psk"};
70  EXPECT_CALL(*kd_, hkdfExtract(_, _));
71  ks_->deriveEarlySecret(psk);
72  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(4);
73  ks_->getSecret(EarlySecrets::ExternalPskBinder, transcript_);
74  ks_->getSecret(EarlySecrets::ResumptionPskBinder, transcript_);
75  ks_->getSecret(EarlySecrets::ResumptionPskBinder, transcript_);
76  ks_->getSecret(EarlySecrets::EarlyExporter, transcript_);
77 
78  StringPiece ecdhe{"ecdhe"};
79  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
80  EXPECT_CALL(*kd_, hkdfExtract(_, _));
81  ks_->deriveHandshakeSecret(ecdhe);
82  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
83  ks_->getSecret(HandshakeSecrets::ClientHandshakeTraffic, transcript_);
84  ks_->getSecret(HandshakeSecrets::ServerHandshakeTraffic, transcript_);
85 
86  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
87  EXPECT_CALL(*kd_, hkdfExtract(_, _));
88  ks_->deriveMasterSecret();
89  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
90  ks_->getSecret(MasterSecrets::ExporterMaster, transcript_);
91  ks_->getSecret(MasterSecrets::ResumptionMaster, transcript_);
92 
93  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
94  ks_->deriveAppTrafficSecrets(transcript_);
95  ks_->getSecret(AppTrafficSecrets::ClientAppTraffic);
96  ks_->getSecret(AppTrafficSecrets::ServerAppTraffic);
97 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ExtensionsTest  ,
TokenBindingMessageSelfCreated   
)

Definition at line 68 of file TokenBindingTest.cpp.

References folly::IOBuf::create(), fizz::encode(), EXPECT_EQ, fizz::extensions::TokenBinding::extensions, fizz::extensions::TokenBindingID::key_parameters, message, folly::gen::move, fizz::extensions::referred_token_binding, fizz::extensions::rsa2048_pkcs1_5, fizz::extensions::TokenBinding::signature, tokenBinding, fizz::extensions::TokenBinding::tokenbinding_type, fizz::extensions::TokenBinding::tokenbindingid, and fizz::extensions::TokenBindingMessage::tokenbindings.

68  {
71  tokenBinding.tokenbinding_type = TokenBindingType::referred_token_binding;
72  TokenBindingID id;
73  id.key_parameters = TokenBindingKeyParameters::rsa2048_pkcs1_5;
74  id.key = folly::IOBuf::create(10);
75  tokenBinding.tokenbindingid = std::move(id);
76  tokenBinding.signature = folly::IOBuf::create(10);
77  tokenBinding.extensions = folly::IOBuf::create(10);
78  message.tokenbindings.push_back(std::move(tokenBinding));
79 
80  auto encoded = encode(std::move(message));
81  auto decoded = decode<TokenBindingMessage>(std::move(encoded));
82 
83  EXPECT_EQ(decoded.tokenbindings.size(), 1);
84  auto& decodedTokenBinding = message.tokenbindings.front();
85  auto& decodedId = decodedTokenBinding.tokenbindingid;
86  EXPECT_EQ(
87  decodedTokenBinding.tokenbinding_type,
88  TokenBindingType::referred_token_binding);
89  EXPECT_EQ(
90  decodedId.key_parameters, TokenBindingKeyParameters::rsa2048_pkcs1_5);
91 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TokenBindingType tokenbinding_type
Definition: Types.h:57
std::vector< TokenBinding > tokenbindings
Definition: Types.h:66
std::string message
Definition: SPDYCodec.cpp:133
StringPiece tokenBinding
TokenBindingKeyParameters key_parameters
Definition: Types.h:47
TokenBindingID tokenbindingid
Definition: Types.h:58
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestReadAppData   
)

Definition at line 69 of file PlaintextRecordTest.cpp.

References EXPECT_ANY_THROW.

69  {
70  addToQueue("17030100050123456789");
71  EXPECT_ANY_THROW(read_.read(queue_));
72 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWaitForData   
)

Definition at line 74 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

74  {
75  addToQueue("160301000512345678");
76  EXPECT_FALSE(read_.read(queue_).hasValue());
77  EXPECT_EQ(queue_.chainLength(), 9);
78 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifyWithIntermediateMissing   
)

Definition at line 74 of file DefaultCertificateVerifierTest.cpp.

References createCert(), EXPECT_THROW, and verifier_.

74  {
75  auto subauth = createCert("subauth", true, &rootCertAndKey_);
76  auto subleaf = createCert("subleaf", false, &subauth);
77  EXPECT_THROW(verifier_->verify({getPeerCert(subleaf)}), std::runtime_error);
78 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( RecordTest  ,
TestAlert   
)

Definition at line 75 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, testing::InvokeWithoutArgs(), and fizz::detail::read().

75  {
76  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
77  return TLSMessage{ContentType::alert, getBuf("0202")};
78  }));
79  auto param = read_.readEvent(queue_);
80  boost::get<Alert>(*param);
81 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ExtensionsTest  ,
TestClientEarlyData   
)

Definition at line 76 of file ExtensionsTest.cpp.

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

76  {
77  auto exts = getExtensions(clientEarlyData);
78  auto ext = getExtension<ClientEarlyData>(exts);
79  checkEncode(std::move(*ext), clientEarlyData);
80 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece clientEarlyData
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadAlert   
)

Definition at line 79 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), and uint64_t.

79  {
80  addToQueue("17030100050123456789");
81  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
82  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
83  expectSame(buf, "0123456789");
84  return getBuf("020215");
85  }));
86  auto msg = read_.read(queue_);
87  EXPECT_EQ(msg->type, ContentType::alert);
88  expectSame(msg->fragment, "0202");
89  EXPECT_TRUE(queue_.empty());
90 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWaitForHeader   
)

Definition at line 80 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

80  {
81  addToQueue("16030102");
82  EXPECT_FALSE(read_.read(queue_).hasValue());
83  EXPECT_EQ(queue_.chainLength(), 4);
84 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifyWithIntermediateMissingWithOverride   
)

Definition at line 80 of file DefaultCertificateVerifierTest.cpp.

References createCert(), EXPECT_THROW, and verifier_.

82  {
83  auto subauth = createCert("subauth", true, &rootCertAndKey_);
84  auto subleaf = createCert("subleaf", false, &subauth);
85  verifier_->setCustomVerifyCallback(
86  &DefaultCertificateVerifierTest::allowSelfSignedLeafCertCallback);
87  // The override is irrelevant to the error here. So exception is expected.
88  EXPECT_THROW(verifier_->verify({getPeerCert(subleaf)}), std::runtime_error);
89 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( ExtensionsTest  ,
TestServerEarlyData   
)

Definition at line 82 of file ExtensionsTest.cpp.

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

82  {
83  auto exts = getExtensions(serverEarlyData);
84  auto ext = getExtension<ServerEarlyData>(exts);
85  checkEncode(std::move(*ext), serverEarlyData);
86 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece serverEarlyData
fizz::test::TEST_F ( RecordTest  ,
TestHandshake   
)

Definition at line 83 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, fizz::finished, testing::InvokeWithoutArgs(), and fizz::detail::read().

83  {
84  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
85  return TLSMessage{ContentType::handshake, getBuf("140000023232")};
86  }));
87  auto param = read_.readEvent(queue_);
88  auto& finished = boost::get<Finished>(*param);
89  expectSame(finished.verify_data, "3232");
90  expectSame(*finished.originalEncoding, "140000023232");
91 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestMaxSize   
)

Definition at line 86 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

86  {
87  addToQueue("1603014000");
88  EXPECT_FALSE(read_.read(queue_).hasValue());
89  EXPECT_EQ(queue_.chainLength(), 5);
90 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( ExtensionsTest  ,
TestTicketEarlyData   
)

Definition at line 88 of file ExtensionsTest.cpp.

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

88  {
89  auto exts = getExtensions(ticketEarlyData);
90  auto ext = getExtension<TicketEarlyData>(exts);
91  EXPECT_EQ(ext->max_early_data_size, 5);
92  checkEncode(std::move(*ext), ticketEarlyData);
93 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece ticketEarlyData
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifyWithBadIntermediate   
)

Definition at line 91 of file DefaultCertificateVerifierTest.cpp.

References createCert(), EXPECT_THROW, and verifier_.

91  {
92  auto subauth = createCert("badsubauth", false, &rootCertAndKey_);
93  auto subleaf = createCert("badsubleaf", false, &subauth);
94  EXPECT_THROW(verifier_->verify({getPeerCert(subleaf)}), std::runtime_error);
95 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadAppData   
)

Definition at line 92 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), and uint64_t.

92  {
93  addToQueue("17030100050123456789");
94  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
95  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
96  expectSame(buf, "0123456789");
97  return getBuf("1234abcd17");
98  }));
99  auto msg = read_.read(queue_);
100  EXPECT_EQ(msg->type, ContentType::application_data);
101  expectSame(msg->fragment, "1234abcd");
102  EXPECT_TRUE(queue_.empty());
103 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestOverSize   
)

Definition at line 92 of file PlaintextRecordTest.cpp.

References EXPECT_ANY_THROW.

92  {
93  addToQueue("1603014001");
94  EXPECT_ANY_THROW(read_.read(queue_));
95 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
fizz::test::TEST_F ( RecordTest  ,
TestHandshakeTooLong   
)

Definition at line 93 of file RecordTest.cpp.

References testing::_, EXPECT_ANY_THROW, EXPECT_CALL, testing::InvokeWithoutArgs(), and fizz::detail::read().

93  {
94  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
95  return TLSMessage{ContentType::handshake, getBuf("14400000")};
96  }));
97  EXPECT_ANY_THROW(read_.readEvent(queue_));
98 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AuthenticatorTest  ,
TestValidAuthenticator   
)

Definition at line 94 of file ExportedAuthenticatorTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), EXPECT_CALL, EXPECT_EQ, folly::hexlify(), testing::InvokeWithoutArgs(), folly::gen::move, and testing::Return().

94  {
95  auto mockCert = std::make_shared<MockSelfCert>();
96  EXPECT_CALL(*mockCert, _getCertMessage(_)).WillOnce(InvokeWithoutArgs([]() {
97  return TestMessages::certificate();
98  }));
99  EXPECT_CALL(*mockCert, getSigSchemes())
100  .WillOnce(Return(std::vector<SignatureScheme>(
101  1, SignatureScheme::ecdsa_secp256r1_sha256)));
102  EXPECT_CALL(*mockCert, sign(_, CertificateVerifyContext::Authenticator, _))
103  .WillOnce(
104  InvokeWithoutArgs([]() { return IOBuf::copyBuffer("signature"); }));
105 
106  auto reencodedAuthenticator = ExportedAuthenticator::makeAuthenticator(
107  deriver_,
108  schemes_,
109  *mockCert,
110  std::move(authrequest_),
111  std::move(handshakeContext_),
112  std::move(finishedKey_),
113  CertificateVerifyContext::Authenticator);
114  EXPECT_EQ(
116  (StringPiece(hexlify(reencodedAuthenticator->coalesce()))));
117 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
StringPiece expected_authenticator
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
Range< const char * > StringPiece
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( ExtensionsTest  ,
TestCookie   
)

Definition at line 95 of file ExtensionsTest.cpp.

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

95  {
96  auto exts = getExtensions(cookie);
97  auto ext = getExtension<Cookie>(exts);
98 
99  EXPECT_EQ(StringPiece(ext->cookie->coalesce()), StringPiece("cookie"));
100 
101  checkEncode(std::move(*ext), cookie);
102 }
StringPiece cookie
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Range< const char * > StringPiece
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestEmpty   
)

Definition at line 97 of file PlaintextRecordTest.cpp.

References EXPECT_ANY_THROW.

97  {
98  addToQueue("1603010000aa");
99  EXPECT_ANY_THROW(read_.read(queue_));
100 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
fizz::test::TEST_F ( DefaultCertificateVerifierTest  ,
TestVerifyWithBadRoot   
)

Definition at line 97 of file DefaultCertificateVerifierTest.cpp.

References createCert(), EXPECT_THROW, and verifier_.

97  {
98  auto newroot = createCert("root2", true, nullptr);
99  auto subauth = createCert("subauth2", true, &newroot);
100  auto subleaf = createCert("leaf2", false, &subauth);
101  EXPECT_THROW(
102  verifier_->verify({getPeerCert(subleaf), getPeerCert(subauth)}),
103  std::runtime_error);
104 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
std::shared_ptr< const CertificateVerifier > verifier_
fizz::test::TEST_F ( KeySchedulerTest  ,
TestNoEarly   
)

Definition at line 99 of file KeySchedulerTest.cpp.

References testing::_, and EXPECT_CALL.

99  {
100  StringPiece ecdhe{"ecdhe"};
101  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
102  EXPECT_CALL(*kd_, hkdfExtract(_, _)).Times(2);
103  ks_->deriveHandshakeSecret(ecdhe);
104  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
105  ks_->getSecret(HandshakeSecrets::ClientHandshakeTraffic, transcript_);
106  ks_->getSecret(HandshakeSecrets::ServerHandshakeTraffic, transcript_);
107 
108  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(1);
109  EXPECT_CALL(*kd_, hkdfExtract(_, _));
110  ks_->deriveMasterSecret();
111  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
112  ks_->getSecret(MasterSecrets::ExporterMaster, transcript_);
113  ks_->getSecret(MasterSecrets::ResumptionMaster, transcript_);
114 
115  EXPECT_CALL(*kd_, deriveSecret(_, _, _)).Times(2);
116  ks_->deriveAppTrafficSecrets(transcript_);
117  ks_->getSecret(AppTrafficSecrets::ClientAppTraffic);
118  ks_->getSecret(AppTrafficSecrets::ServerAppTraffic);
119 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( RecordTest  ,
TestHandshakeFragmentedImmediate   
)

Definition at line 100 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, fizz::finished, testing::InvokeWithoutArgs(), and fizz::detail::read().

100  {
101  EXPECT_CALL(read_, read(_))
102  .WillOnce(InvokeWithoutArgs([]() {
103  return TLSMessage{ContentType::handshake, getBuf("14000008aabbccdd")};
104  }))
105  .WillOnce(InvokeWithoutArgs([]() {
106  return TLSMessage{ContentType::handshake, getBuf("11223344")};
107  }));
108  auto param = read_.readEvent(queue_);
109  EXPECT_FALSE(read_.hasUnparsedHandshakeData());
110  auto& finished = boost::get<Finished>(*param);
111  expectSame(finished.verify_data, "aabbccdd11223344");
112 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestDataRemaining   
)

Definition at line 102 of file PlaintextRecordTest.cpp.

References EXPECT_EQ.

102  {
103  addToQueue("16030100050123456789160301");
104  auto msg = read_.read(queue_);
105  EXPECT_EQ(msg->type, ContentType::handshake);
106  expectSame(msg->fragment, "0123456789");
107  EXPECT_EQ(queue_.chainLength(), 3);
108  expectSame(queue_.move(), "160301");
109 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST_F ( ExtensionsTest  ,
TestCertificateAuthorities   
)

Definition at line 104 of file ExtensionsTest.cpp.

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

104  {
105  auto exts = getExtensions(authorities);
106  auto ext = getExtension<CertificateAuthorities>(exts);
107 
108  EXPECT_EQ(ext->authorities.size(), 2);
109  EXPECT_EQ(
110  StringPiece(ext->authorities[0].encoded_name->coalesce()),
111  StringPiece("CN=Liminality, OU=Fizz, O=Facebook, C=US"));
112  EXPECT_EQ(
113  StringPiece(ext->authorities[1].encoded_name->coalesce()),
114  StringPiece("CN=Eternity, OU=Fizz, O=Facebook, C=US"));
115 
116  checkEncode(std::move(*ext), authorities);
117 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece authorities
Range< const char * > StringPiece
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadUnknown   
)

Definition at line 105 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_ANY_THROW, EXPECT_CALL, testing::Invoke(), and uint64_t.

105  {
106  addToQueue("17030100050123456789");
107  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
108  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
109  expectSame(buf, "0123456789");
110  return getBuf("1234abcd20");
111  }));
112  EXPECT_ANY_THROW(read_.read(queue_));
113 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
ChloEncodeDecode   
)

Definition at line 106 of file HandshakeTypesTest.cpp.

References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, chlo, EXPECT_EQ, and folly::gen::move.

106  {
107  auto clientHello = decodeHex<ClientHello>(chlo);
108 
109  auto sigAlgs = getExtension<SignatureAlgorithms>(clientHello.extensions);
110  ASSERT_TRUE(sigAlgs);
111  const auto& schemes = sigAlgs->supported_signature_algorithms;
112  ASSERT_EQ(11, schemes.size());
113  ASSERT_FALSE(
114  schemes.end() ==
115  std::find(
116  schemes.begin(),
117  schemes.end(),
118  SignatureScheme::ecdsa_secp256r1_sha256));
119 
120  auto groups = getExtension<SupportedGroups>(clientHello.extensions);
121  const auto& groupNames = groups->named_group_list;
122  ASSERT_EQ(3, groupNames.size());
123  ASSERT_FALSE(
124  groupNames.end() ==
125  std::find(groupNames.begin(), groupNames.end(), NamedGroup::secp256r1));
126 
127  auto clientShares = getExtension<ClientKeyShare>(clientHello.extensions);
128  ASSERT_TRUE(clientShares);
129  ASSERT_EQ(2, clientShares->client_shares.size());
130 
131  ASSERT_FALSE(getExtension<ClientPresharedKey>(clientHello.extensions));
132  ASSERT_FALSE(getExtension<ClientEarlyData>(clientHello.extensions));
133  ASSERT_FALSE(getExtension<Cookie>(clientHello.extensions));
134 
135  auto reencoded = encodeHex(std::move(clientHello));
136  EXPECT_EQ(chlo, reencoded);
137 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
static const std::string chlo
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestSkipAndWait   
)

Definition at line 111 of file PlaintextRecordTest.cpp.

References EXPECT_FALSE, and EXPECT_TRUE.

111  {
112  read_.setSkipEncryptedRecords(true);
113  addToQueue("17030100050123456789");
114  EXPECT_FALSE(read_.read(queue_).hasValue());
115  EXPECT_TRUE(queue_.empty());
116 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( RecordTest  ,
TestHandshakeFragmentedDelayed   
)

Definition at line 114 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, fizz::finished, testing::InvokeWithoutArgs(), folly::none, and fizz::detail::read().

114  {
115  EXPECT_CALL(read_, read(_))
116  .WillOnce(InvokeWithoutArgs([]() {
117  return TLSMessage{ContentType::handshake, getBuf("14000008aabbccdd")};
118  }))
119  .WillOnce(InvokeWithoutArgs([]() { return folly::none; }));
120  EXPECT_FALSE(read_.readEvent(queue_).hasValue());
121  EXPECT_TRUE(read_.hasUnparsedHandshakeData());
122  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
123  return TLSMessage{ContentType::handshake, getBuf("11223344")};
124  }));
125  auto param = read_.readEvent(queue_);
126  auto& finished = boost::get<Finished>(*param);
127  expectSame(finished.verify_data, "aabbccdd11223344");
128 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWaitForData   
)

Definition at line 115 of file EncryptedRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

115  {
116  addToQueue("1703010010012345");
117  EXPECT_FALSE(read_.read(queue_).hasValue());
118  EXPECT_EQ(queue_.chainLength(), 8);
119 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWaitBeforeSkip   
)

Definition at line 118 of file PlaintextRecordTest.cpp.

References EXPECT_FALSE.

118  {
119  read_.setSkipEncryptedRecords(true);
120  addToQueue("170301000501234567");
121  EXPECT_FALSE(read_.read(queue_).hasValue());
122  expectSame(queue_.move(), "170301000501234567");
123 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestIsFizz   
)

Definition at line 119 of file AsyncFizzBaseTest.cpp.

References EXPECT_EQ.

119  {
120  EXPECT_EQ(getSecurityProtocol(), "Fizz");
121 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST_F ( AuthenticatorTest  ,
TestEmptyAuthenticator   
)

Definition at line 119 of file ExportedAuthenticatorTest.cpp.

References EXPECT_CALL, EXPECT_EQ, folly::hexlify(), folly::gen::move, and testing::Return().

119  {
120  auto mockCert = std::make_shared<MockSelfCert>();
121  EXPECT_CALL(*mockCert, getSigSchemes())
122  .WillOnce(Return(std::vector<SignatureScheme>(
123  1, SignatureScheme::ecdsa_secp256r1_sha256)));
124  schemes_.clear();
125  auto reencodedAuthenticator = ExportedAuthenticator::makeAuthenticator(
126  deriver_,
127  schemes_,
128  *mockCert,
129  std::move(authrequest_),
130  std::move(handshakeContext_),
131  std::move(finishedKey_),
132  CertificateVerifyContext::Authenticator);
133  EXPECT_EQ(
135  StringPiece(hexlify(reencodedAuthenticator->coalesce())));
136 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece expected_empty_authenticator
#define EXPECT_CALL(obj, call)
Range< const char * > StringPiece
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( ExtensionsTest  ,
TestCertificateCompressionAlgorithms   
)

Definition at line 119 of file ExtensionsTest.cpp.

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

119  {
120  auto exts = getExtensions(certCompressionAlgorithms);
121  auto ext = getExtension<CertificateCompressionAlgorithms>(exts);
122 
123  EXPECT_EQ(ext->algorithms.size(), 1);
124  EXPECT_EQ(ext->algorithms[0], CertificateCompressionAlgorithm::zlib);
125  checkEncode(std::move(*ext), certCompressionAlgorithms);
126 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece certCompressionAlgorithms
fizz::test::TEST_F ( KeySchedulerTest  ,
TestKeyUpdate   
)

Definition at line 121 of file KeySchedulerTest.cpp.

References testing::_, EXPECT_CALL, and EXPECT_EQ.

121  {
122  StringPiece ecdhe{"ecdhe"};
123  ks_->deriveHandshakeSecret(ecdhe);
124  ks_->deriveMasterSecret();
125  ks_->deriveAppTrafficSecrets(transcript_);
126 
127  EXPECT_CALL(*kd_, _expandLabel(_, _, _, _));
128  EXPECT_EQ(ks_->clientKeyUpdate(), 1);
129  EXPECT_CALL(*kd_, _expandLabel(_, _, _, _));
130  EXPECT_EQ(ks_->clientKeyUpdate(), 2);
131 
132  EXPECT_CALL(*kd_, _expandLabel(_, _, _, _));
133  EXPECT_EQ(ks_->serverKeyUpdate(), 1);
134  EXPECT_CALL(*kd_, _expandLabel(_, _, _, _));
135  EXPECT_EQ(ks_->serverKeyUpdate(), 2);
136 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWaitForHeader   
)

Definition at line 121 of file EncryptedRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

121  {
122  addToQueue("16030102");
123  EXPECT_FALSE(read_.read(queue_).hasValue());
124  EXPECT_EQ(queue_.chainLength(), 4);
125 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestAppBytesWritten   
)

Definition at line 123 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, and folly::gen::move.

123  {
124  EXPECT_EQ(getAppBytesWritten(), 0);
125 
126  auto four = IOBuf::copyBuffer("4444");
127  writeChain(nullptr, std::move(four));
128  EXPECT_EQ(getAppBytesWritten(), 4);
129 
130  auto eight = IOBuf::copyBuffer("88888888");
131  auto two = IOBuf::copyBuffer("22");
132  eight->prependChain(std::move(two));
133  writeChain(nullptr, std::move(eight));
134  EXPECT_EQ(getAppBytesWritten(), 14);
135 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestSkipAndRead   
)

Definition at line 125 of file PlaintextRecordTest.cpp.

References EXPECT_EQ, and EXPECT_TRUE.

125  {
126  read_.setSkipEncryptedRecords(true);
127  addToQueue("170301000501234567891703010005012345678916030100050123456789");
128  auto msg = read_.read(queue_);
129  EXPECT_EQ(msg->type, ContentType::handshake);
130  expectSame(msg->fragment, "0123456789");
131  EXPECT_TRUE(queue_.empty());
132 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestMaxSize   
)

Definition at line 127 of file EncryptedRecordTest.cpp.

References EXPECT_EQ, and EXPECT_FALSE.

127  {
128  addToQueue("1603014100");
129  EXPECT_FALSE(read_.read(queue_).hasValue());
130  EXPECT_EQ(queue_.chainLength(), 5);
131 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( ExtensionsTest  ,
TestBadlyFormedExtension   
)

Definition at line 128 of file ExtensionsTest.cpp.

References EXPECT_THROW, fizz::Extension::extension_data, fizz::Extension::extension_type, folly::gen::move, and sni.

128  {
129  auto buf = getBuf(sni);
130  buf->reserve(0, 1);
131  buf->append(1);
132  std::vector<Extension> exts;
133  Extension ext;
134  ext.extension_type = ExtensionType::server_name;
135  ext.extension_data = std::move(buf);
136  exts.push_back(std::move(ext));
137  EXPECT_THROW(getExtension<ServerNameList>(exts), std::runtime_error);
138 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StringPiece sni
fizz::test::TEST_F ( RecordTest  ,
TestHandshakeCoalesced   
)

Definition at line 130 of file RecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, fizz::finished, testing::InvokeWithoutArgs(), and fizz::detail::read().

130  {
131  EXPECT_CALL(read_, read(_)).WillOnce(InvokeWithoutArgs([]() {
132  return TLSMessage{ContentType::handshake,
133  getBuf("14000002aabb14000002ccdd")};
134  }));
135  auto param = read_.readEvent(queue_);
136  auto& finished = boost::get<Finished>(*param);
137  expectSame(finished.verify_data, "aabb");
138  EXPECT_TRUE(read_.hasUnparsedHandshakeData());
139  param = read_.readEvent(queue_);
140  auto& finished2 = boost::get<Finished>(*param);
141  expectSame(finished2.verify_data, "ccdd");
142  EXPECT_FALSE(read_.hasUnparsedHandshakeData());
143 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestOverSize   
)

Definition at line 133 of file EncryptedRecordTest.cpp.

References EXPECT_ANY_THROW.

133  {
134  addToQueue("1603015000");
135  EXPECT_ANY_THROW(read_.read(queue_));
136 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWriteHandshake   
)

Definition at line 134 of file PlaintextRecordTest.cpp.

References folly::gen::move.

134  {
135  TLSMessage msg{ContentType::handshake, getBuf("1234567890")};
136  auto buf = write_.write(std::move(msg));
137  expectSame(buf.data, "16030300051234567890");
138 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestAppBytesReceived   
)

Definition at line 137 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, and folly::gen::move.

137  {
138  EXPECT_EQ(getAppBytesReceived(), 0);
139 
140  auto four = IOBuf::copyBuffer("4444");
141  deliverAppData(std::move(four));
142  EXPECT_EQ(getAppBytesReceived(), 4);
143 
144  auto eight = IOBuf::copyBuffer("88888888");
145  auto two = IOBuf::copyBuffer("22");
146  eight->prependChain(std::move(two));
147  deliverAppData(std::move(eight));
148  EXPECT_EQ(getAppBytesReceived(), 14);
149 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::TEST_F ( KeySchedulerTest  ,
TestTrafficKey   
)

Definition at line 138 of file KeySchedulerTest.cpp.

References testing::_, and EXPECT_CALL.

138  {
139  EXPECT_CALL(*kd_, _expandLabel(_, _, _, _)).Times(2);
140  StringPiece trafficSecret{"secret"};
141  ks_->getTrafficKey(trafficSecret, 10, 10);
142 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestDataRemaining   
)

Definition at line 138 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, testing::Invoke(), and uint64_t.

138  {
139  addToQueue("17030100050123456789aa");
140  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
141  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
142  expectSame(buf, "0123456789");
143  return getBuf("abcdef16");
144  }));
145  read_.read(queue_);
146  EXPECT_EQ(queue_.chainLength(), 1);
147 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
SSL3ChloDecode   
)

Definition at line 139 of file HandshakeTypesTest.cpp.

References EXPECT_TRUE, and ssl3chlo.

139  {
140  auto clientHello = decodeHex<ClientHello>(ssl3chlo);
141  EXPECT_TRUE(clientHello.extensions.empty());
142 }
static const std::string ssl3chlo
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWriteClientHello   
)

Definition at line 140 of file PlaintextRecordTest.cpp.

140  {
141  auto buf = write_.writeInitialClientHello(getBuf("1234567890"));
142  expectSame(buf.data, "16030100051234567890");
143 }
fizz::test::TEST_F ( HandshakeTypesTest  ,
ChloDecidePsk   
)

Definition at line 144 of file HandshakeTypesTest.cpp.

References chloPsk, EXPECT_EQ, and fizz::getBinderLength().

144  {
145  auto clientHello = decodeHex<ClientHello>(chloPsk);
146 
147  EXPECT_EQ(35, getBinderLength(clientHello));
148 }
size_t getBinderLength(const ClientHello &chlo)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const std::string chloPsk
fizz::test::TEST_F ( RecordTest  ,
TestHandshakeSpliced   
)

Definition at line 145 of file RecordTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), EXPECT_ANY_THROW, EXPECT_CALL, testing::InvokeWithoutArgs(), and fizz::detail::read().

145  {
146  EXPECT_CALL(read_, read(_))
147  .WillOnce(InvokeWithoutArgs([]() {
148  return TLSMessage{ContentType::handshake, getBuf("01000010abcd")};
149  }))
150  .WillOnce(InvokeWithoutArgs([]() {
151  return TLSMessage{ContentType::application_data,
152  IOBuf::copyBuffer("hi")};
153  }));
154  EXPECT_ANY_THROW(read_.readEvent(queue_));
155 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestWriteAppData   
)

Definition at line 145 of file PlaintextRecordTest.cpp.

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

145  {
146  TLSMessage msg{ContentType::application_data};
147  EXPECT_ANY_THROW(write_.write(std::move(msg)));
148 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TEST_F ( FizzBaseTest  ,
TestReadSingle   
)

Definition at line 149 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), and testing::InvokeWithoutArgs().

149  {
150  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
151  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
152  EXPECT_CALL(testFizz_->visitor_, a1()).WillOnce(Invoke([this]() {
153  testFizz_->waitForData();
154  }));
155  testFizz_->newTransportData();
156 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestPadding   
)

Definition at line 149 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), and uint64_t.

149  {
150  addToQueue("17030100050123456789");
151  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
152  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
153  expectSame(buf, "0123456789");
154  return getBuf("1234abcd17000000");
155  }));
156  auto msg = read_.read(queue_);
157  EXPECT_EQ(msg->type, ContentType::application_data);
158  expectSame(msg->fragment, "1234abcd");
159  EXPECT_TRUE(queue_.empty());
160 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
ChloEncodeCopy   
)

Definition at line 150 of file HandshakeTypesTest.cpp.

References chlo, and EXPECT_EQ.

150  {
151  auto clientHello = decodeHex<ClientHello>(chlo);
152  EXPECT_EQ(encodeHex(clientHello), chlo);
153  EXPECT_EQ(encodeHex(clientHello), chlo);
154 }
static const std::string chlo
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fizz::test::TEST_F ( PlaintextRecordTest  ,
TestFragmentedWrite   
)

Definition at line 150 of file PlaintextRecordTest.cpp.

References folly::IOBuf::create(), folly::eq, EXPECT_TRUE, folly::gen::move, and fizz::detail::write().

150  {
151  TLSMessage msg{ContentType::handshake, IOBuf::create(0)};
152  auto buf = IOBuf::create(0x4010);
153  buf->append(0x4010);
154  memset(buf->writableData(), 0x1, buf->length());
155  msg.fragment->prependChain(std::move(buf));
156  auto write = write_.write(std::move(msg));
157 
158  TLSMessage msg1{ContentType::handshake, IOBuf::create(0)};
159  buf = IOBuf::create(0x4000);
160  buf->append(0x4000);
161  memset(buf->writableData(), 0x1, buf->length());
162  msg1.fragment->prependChain(std::move(buf));
163  auto write1 = write_.write(std::move(msg1));
164 
165  TLSMessage msg2{ContentType::handshake, IOBuf::create(0)};
166  buf = IOBuf::create(0x10);
167  buf->append(0x10);
168  memset(buf->writableData(), 0x1, buf->length());
169  msg2.fragment->prependChain(std::move(buf));
170  auto write2 = write_.write(std::move(msg2));
171 
172  write1.data->prependChain(std::move(write2.data));
174  EXPECT_TRUE(eq(write.data, write1.data));
175 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestWrite   
)

Definition at line 151 of file AsyncFizzBaseTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), EXPECT_CALL, and folly::gen::move.

151  {
152  auto buf = IOBuf::copyBuffer("buf");
153 
154  EXPECT_CALL(*this, writeAppDataInternal(_, _, _));
155  writeChain(nullptr, std::move(buf));
156 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
NstEncodeDecode   
)

Definition at line 156 of file HandshakeTypesTest.cpp.

References folly::Range< Iter >::empty(), EXPECT_EQ, EXPECT_TRUE, folly::gen::move, nst, and ticket.

156  {
157  auto ticket = decodeHex<NewSessionTicket>(nst);
158 
159  EXPECT_EQ(ticket.ticket_lifetime, 0x0002a300);
160  EXPECT_EQ(ticket.ticket_age_add, 0xd0a8dc29);
161  EXPECT_TRUE(ticket.ticket_nonce->empty());
162  EXPECT_EQ(ticket.ticket->computeChainDataLength(), 146);
163 
164  auto reencoded = encodeHex(std::move(ticket));
165  EXPECT_EQ(nst, reencoded);
166 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static constexpr StringPiece ticket
constexpr bool empty() const
Definition: Range.h:443
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static const std::string nst
fizz::test::TEST_F ( RecordTest  ,
TestWriteAppData   
)

Definition at line 157 of file RecordTest.cpp.

References testing::_, fizz::TLSContent::contentType, folly::IOBuf::copyBuffer(), fizz::TLSContent::data, fizz::TLSContent::encryptionLevel, EXPECT_CALL, EXPECT_EQ, testing::Invoke(), and fizz::TLSMessage::type.

157  {
158  EXPECT_CALL(write_, _write(_)).WillOnce(Invoke([&](TLSMessage& msg) {
159  TLSContent content;
160  content.contentType = msg.type;
161  content.encryptionLevel = write_.getEncryptionLevel();
162  content.data = nullptr;
163  EXPECT_EQ(msg.type, ContentType::application_data);
164  return content;
165  }));
166  write_.writeAppData(IOBuf::copyBuffer("hi"));
167 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadErr   
)

Definition at line 158 of file AsyncFizzBaseTest.cpp.

References testing::_, folly::netops::close(), EXPECT_CALL, EXPECT_EQ, and socket_.

158  {
159  setReadCB(&readCallback_);
160 
161  EXPECT_CALL(readCallback_, readErr_(_));
163  deliverError(ase_);
164  EXPECT_EQ(getReadCallback(), nullptr);
165 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
AsyncServerSocket::UniquePtr socket_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
int close(NetworkSocket s)
Definition: NetOps.cpp:90
fizz::test::TEST_F ( FizzBaseTest  ,
TestReadMulti   
)

Definition at line 158 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

158  {
159  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
160  .InSequence(s_)
161  .WillOnce(InvokeWithoutArgs([]() {
162  return Actions{A1(), A2(), A1()};
163  }));
164  EXPECT_CALL(testFizz_->visitor_, a1()).InSequence(s_);
165  EXPECT_CALL(testFizz_->visitor_, a2()).InSequence(s_);
166  EXPECT_CALL(testFizz_->visitor_, a1()).InSequence(s_);
167  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
168  .InSequence(s_)
169  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
170  EXPECT_CALL(testFizz_->visitor_, a2()).InSequence(s_);
171  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
172  .InSequence(s_)
173  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
174  EXPECT_CALL(testFizz_->visitor_, a1())
175  .InSequence(s_)
176  .WillOnce(Invoke([this]() { testFizz_->waitForData(); }));
177  testFizz_->newTransportData();
178 }
std::string s_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestAllPaddingAppData   
)

Definition at line 162 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), and uint64_t.

162  {
163  addToQueue("17030100050123456789");
164  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
165  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
166  expectSame(buf, "0123456789");
167  return getBuf("17000000");
168  }));
169  auto msg = read_.read(queue_);
170  EXPECT_EQ(msg->type, ContentType::application_data);
171  EXPECT_TRUE(msg->fragment->empty());
172  EXPECT_TRUE(queue_.empty());
173 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadErrNoCallback   
)

Definition at line 167 of file AsyncFizzBaseTest.cpp.

References folly::netops::close(), EXPECT_CALL, and socket_.

167  {
169  deliverError(ase_);
170 }
AsyncServerSocket::UniquePtr socket_
#define EXPECT_CALL(obj, call)
int close(NetworkSocket s)
Definition: NetOps.cpp:90
fizz::test::TEST_F ( RecordTest  ,
TestWriteAlert   
)

Definition at line 169 of file RecordTest.cpp.

References testing::_, fizz::TLSContent::contentType, fizz::TLSContent::data, fizz::TLSContent::encryptionLevel, EXPECT_CALL, EXPECT_EQ, testing::Invoke(), and fizz::TLSMessage::type.

169  {
170  EXPECT_CALL(write_, _write(_)).WillOnce(Invoke([&](TLSMessage& msg) {
171  EXPECT_EQ(msg.type, ContentType::alert);
172  TLSContent content;
173  content.contentType = msg.type;
174  content.encryptionLevel = write_.getEncryptionLevel();
175  content.data = nullptr;
176  return content;
177  }));
178  write_.writeAlert(Alert());
179 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ValidateAuthenticatorTest  ,
TestValidateValidAuthenticator   
)

Definition at line 170 of file ExportedAuthenticatorTest.cpp.

References fizz::certificate, folly::IOBuf::copyBuffer(), EXPECT_EQ, EXPECT_TRUE, getCert(), getPrivateKey(), folly::hexlify(), kP256Certificate, kP256Key, folly::gen::move, and folly::unhexlify().

170  {
173  std::vector<folly::ssl::X509UniquePtr> certs;
174  certs.push_back(std::move(cert));
175  SelfCertImpl<KeyType::P256> certificate(std::move(key), std::move(certs));
176  auto authenticatorRequest = folly::IOBuf::copyBuffer(unhexlify(authrequest_));
177  auto handshakeContext =
178  folly::IOBuf::copyBuffer(unhexlify(handshakeContext_));
179  auto finishedMacKey = folly::IOBuf::copyBuffer(unhexlify(finishedKey_));
180  auto authenticator = ExportedAuthenticator::makeAuthenticator(
181  deriver_,
182  schemes_,
183  certificate,
184  std::move(authenticatorRequest),
185  std::move(handshakeContext),
186  std::move(finishedMacKey),
187  CertificateVerifyContext::Authenticator);
188 
189  authenticatorRequest = folly::IOBuf::copyBuffer(unhexlify(authrequest_));
190  handshakeContext = folly::IOBuf::copyBuffer(unhexlify(handshakeContext_));
191  finishedMacKey = folly::IOBuf::copyBuffer(unhexlify(finishedKey_));
192  auto decodedCerts = ExportedAuthenticator::validate(
193  deriver_,
194  std::move(authenticatorRequest),
195  std::move(authenticator),
196  std::move(handshakeContext),
197  std::move(finishedMacKey),
198  CertificateVerifyContext::Authenticator);
199  EXPECT_TRUE(decodedCerts.hasValue());
200  EXPECT_EQ((*decodedCerts).size(), 1);
201  EXPECT_EQ(
203  StringPiece(hexlify(((*decodedCerts)[0].cert_data)->coalesce())));
204 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
StringPiece expected_cert
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
Range< const char * > StringPiece
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadErrAsync   
)

Definition at line 172 of file AsyncFizzBaseTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, ON_CALL, and testing::Return().

172  {
173  ON_CALL(*this, good()).WillByDefault(Return(false));
174  deliverError(ase_);
175 
176  EXPECT_CALL(readCallback_, readErr_(_));
177  setReadCB(&readCallback_);
178  EXPECT_EQ(getReadCallback(), nullptr);
179 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define ON_CALL(obj, call)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestAllPaddingHandshake   
)

Definition at line 175 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_ANY_THROW, EXPECT_CALL, testing::Invoke(), and uint64_t.

175  {
176  addToQueue("17030100050123456789");
177  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
178  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
179  expectSame(buf, "0123456789");
180  return getBuf("16000000");
181  }));
182  EXPECT_ANY_THROW(read_.read(queue_));
183 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeSigAlgs   
)

Definition at line 176 of file HandshakeTypesTest.cpp.

References ASSERT_TRUE, chlo, fizz::encodeExtension(), EXPECT_TRUE, extensionsMatch(), and fizz::findExtension().

176  {
177  auto clientHello = decodeHex<ClientHello>(chlo);
178  auto sigAlgs = getExtension<SignatureAlgorithms>(clientHello.extensions);
179  ASSERT_TRUE(sigAlgs);
180  auto ext = encodeExtension(*sigAlgs);
181  auto original = findExtension(
182  clientHello.extensions, ExtensionType::signature_algorithms);
183  EXPECT_TRUE(extensionsMatch(*original, ext));
184 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
static const std::string chlo
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
Extension encodeExtension(const TokenBindingParameters &params)
Definition: Types.cpp:113
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
bool extensionsMatch(const Extension &expected, const Extension &actual)
fizz::test::TEST_F ( FizzBaseTest  ,
TestReadNoActions   
)

Definition at line 180 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

180  {
181  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
182  .InSequence(s_)
183  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
184  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
185  .InSequence(s_)
186  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
187  EXPECT_CALL(testFizz_->visitor_, a1())
188  .InSequence(s_)
189  .WillOnce(Invoke([this]() { testFizz_->waitForData(); }));
190  testFizz_->newTransportData();
191 }
std::string s_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadEOF   
)

Definition at line 181 of file AsyncFizzBaseTest.cpp.

References EXPECT_CALL, and EXPECT_EQ.

181  {
182  setReadCB(&readCallback_);
183 
184  EXPECT_CALL(readCallback_, readEOF_());
185  deliverError(eof_);
186  EXPECT_EQ(getReadCallback(), nullptr);
187 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
fizz::test::TEST_F ( RecordTest  ,
TestWriteHandshake   
)

Definition at line 181 of file RecordTest.cpp.

References testing::_, fizz::TLSContent::contentType, folly::IOBuf::copyBuffer(), fizz::TLSContent::data, fizz::TLSContent::encryptionLevel, EXPECT_CALL, EXPECT_EQ, testing::Invoke(), and fizz::TLSMessage::type.

181  {
182  EXPECT_CALL(write_, _write(_)).WillOnce(Invoke([&](TLSMessage& msg) {
183  EXPECT_EQ(msg.type, ContentType::handshake);
184  TLSContent content;
185  content.contentType = msg.type;
186  content.encryptionLevel = write_.getEncryptionLevel();
187  content.data = nullptr;
188  return content;
189  }));
190  write_.writeHandshake(IOBuf::copyBuffer("msg1"), IOBuf::copyBuffer("msg2"));
191 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestNoContentType   
)

Definition at line 185 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_ANY_THROW, EXPECT_CALL, testing::Invoke(), and uint64_t.

185  {
186  addToQueue("17030100050123456789");
187  EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
188  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
189  expectSame(buf, "0123456789");
190  return getBuf("00000000");
191  }));
192  EXPECT_ANY_THROW(read_.read(queue_));
193 }
#define EXPECT_ANY_THROW(statement)
Definition: gtest.h:1847
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeClientKeyShare   
)

Definition at line 186 of file HandshakeTypesTest.cpp.

References ASSERT_TRUE, chlo, fizz::encodeExtension(), EXPECT_TRUE, extensionsMatch(), fizz::findExtension(), and folly::pushmi::operators::share.

186  {
187  auto clientHello = decodeHex<ClientHello>(chlo);
188  auto share = getExtension<ClientKeyShare>(clientHello.extensions);
189  ASSERT_TRUE(share);
190  auto ext = encodeExtension(*share);
191  auto original =
192  findExtension(clientHello.extensions, ExtensionType::key_share);
193  EXPECT_TRUE(extensionsMatch(*original, ext));
194 }
std::vector< Extension >::const_iterator findExtension(const std::vector< Extension > &extensions, ExtensionType type)
static const std::string chlo
PUSHMI_INLINE_VAR constexpr detail::share_fn< TN... > share
Definition: share.h:53
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
Extension encodeExtension(const TokenBindingParameters &params)
Definition: Types.cpp:113
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
bool extensionsMatch(const Extension &expected, const Extension &actual)
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadEOFNoCallback   
)

Definition at line 189 of file AsyncFizzBaseTest.cpp.

189  {
190  deliverError(eof_);
191 }
fizz::test::TEST_F ( FizzBaseTest  ,
TestWriteNewSessionTicket   
)

Definition at line 193 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

193  {
194  EXPECT_CALL(*TestStateMachine::instance, processWriteNewSessionTicket_(_, _))
195  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
196  EXPECT_CALL(testFizz_->visitor_, a1());
197  testFizz_->writeNewSessionTicket(WriteNewSessionTicket());
198 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestMovableBuffer   
)

Definition at line 193 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, and testing::Return().

193  {
194  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(true));
195 
196  setReadCB(&readCallback_);
197 
198  auto buf = IOBuf::copyBuffer("buf");
199  EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf.get())));
200  deliverAppData(buf->clone());
201 
202  auto buf2 = IOBuf::copyBuffer("buf2");
203  EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf2.get())));
204  deliverAppData(buf2->clone());
205 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestReadSeqNum   
)

Definition at line 195 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, i, testing::Invoke(), and uint64_t.

195  {
196  for (int i = 0; i < 10; i++) {
197  addToQueue("17030100050123456789");
198  EXPECT_CALL(*readAead_, _decrypt(_, _, i))
199  .WillOnce(
200  Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
201  expectSame(buf, "0123456789");
202  return getBuf("1234abcd17");
203  }));
204  read_.read(queue_);
205  }
206 }
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeServerHello   
)

Definition at line 196 of file HandshakeTypesTest.cpp.

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

196  {
197  auto shlo = decodeHex<ServerHello>(encodedShlo);
198  EXPECT_EQ(shlo.legacy_version, ProtocolVersion::tls_1_2);
199  EXPECT_EQ(shlo.random.front(), 0x9f);
200  EXPECT_EQ(shlo.random.back(), 0x5b);
201  EXPECT_EQ(shlo.cipher_suite, CipherSuite::TLS_AES_128_GCM_SHA256);
202  EXPECT_EQ(shlo.extensions.size(), 2);
203  EXPECT_TRUE(getExtension<ServerKeyShare>(shlo.extensions).hasValue());
204  EXPECT_TRUE(
205  getExtension<ServerSupportedVersions>(shlo.extensions).hasValue());
206  auto reencoded = encodeHex(std::move(shlo));
207  EXPECT_EQ(reencoded, encodedShlo);
208 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static const std::string encodedShlo
fizz::test::TEST_F ( FizzBaseTest  ,
TestWrite   
)

Definition at line 200 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

200  {
201  EXPECT_CALL(*TestStateMachine::instance, processAppWrite_(_, _))
202  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
203  EXPECT_CALL(testFizz_->visitor_, a1());
204  testFizz_->appWrite(AppWrite());
205 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ValidateAuthenticatorTest  ,
TestValidateEmptyAuthenticator   
)

Definition at line 206 of file ExportedAuthenticatorTest.cpp.

References fizz::certificate, folly::IOBuf::copyBuffer(), EXPECT_EQ, EXPECT_TRUE, getCert(), getPrivateKey(), kP256Certificate, kP256Key, folly::gen::move, and folly::unhexlify().

206  {
209  std::vector<folly::ssl::X509UniquePtr> certs;
210  certs.push_back(std::move(cert));
211  SelfCertImpl<KeyType::P256> certificate(std::move(key), std::move(certs));
212  schemes_.clear();
213  auto authenticatorRequest = folly::IOBuf::copyBuffer(unhexlify(authrequest_));
214  auto handshakeContext =
215  folly::IOBuf::copyBuffer(unhexlify(handshakeContext_));
216  auto finishedMacKey = folly::IOBuf::copyBuffer(unhexlify(finishedKey_));
217  auto authenticator = ExportedAuthenticator::makeAuthenticator(
218  deriver_,
219  schemes_,
220  certificate,
221  std::move(authenticatorRequest),
222  std::move(handshakeContext),
223  std::move(finishedMacKey),
224  CertificateVerifyContext::Authenticator);
225 
226  authenticatorRequest = folly::IOBuf::copyBuffer(unhexlify(authrequest_));
227  handshakeContext = folly::IOBuf::copyBuffer(unhexlify(handshakeContext_));
228  finishedMacKey = folly::IOBuf::copyBuffer(unhexlify(finishedKey_));
229  auto decodedCerts = ExportedAuthenticator::validate(
230  deriver_,
231  std::move(authenticatorRequest),
232  std::move(authenticator),
233  std::move(handshakeContext),
234  std::move(finishedMacKey),
235  CertificateVerifyContext::Authenticator);
236  EXPECT_TRUE(decodedCerts.hasValue());
237  EXPECT_EQ((*decodedCerts).size(), 0);
238 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
constexpr folly::StringPiece kP256Certificate
Definition: TestUtil.h:41
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestMovableBufferAsyncCallback   
)

Definition at line 207 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, and testing::Return().

207  {
208  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(true));
209 
210  auto buf = IOBuf::copyBuffer("buf");
211  deliverAppData(std::move(buf));
212 
213  auto buf2 = IOBuf::copyBuffer("buf2");
214  deliverAppData(std::move(buf2));
215 
216  auto expected = IOBuf::copyBuffer("bufbuf2");
217  EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(expected.get())));
218  setReadCB(&readCallback_);
219 
220  auto buf3 = IOBuf::copyBuffer("buf3");
221  EXPECT_CALL(readCallback_, readBufferAvailable_(BufMatches(buf3.get())));
222  deliverAppData(buf3->clone());
223 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( FizzBaseTest  ,
TestEarlyWrite   
)

Definition at line 207 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

207  {
208  EXPECT_CALL(*TestStateMachine::instance, processEarlyAppWrite_(_, _))
209  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
210  EXPECT_CALL(testFizz_->visitor_, a1());
211  testFizz_->earlyAppWrite(EarlyAppWrite());
212 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestSkipAndWait   
)

Definition at line 208 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, testing::Invoke(), folly::none, and uint64_t.

208  {
209  read_.setSkipFailedDecryption(true);
210  addToQueue("17030100050123456789");
211  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
212  .WillOnce(
213  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
214  return folly::none;
215  }));
216  EXPECT_FALSE(read_.read(queue_).hasValue());
217  EXPECT_TRUE(queue_.empty());
218 }
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeEndOfEarlyData   
)

Definition at line 210 of file HandshakeTypesTest.cpp.

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

210  {
211  auto eoed = decodeHex<EndOfEarlyData>(encodedEoed);
212  auto reencoded = encodeHex(std::move(eoed));
213  EXPECT_EQ(reencoded, encodedEoed);
214 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string encodedEoed
fizz::test::TEST_F ( FizzBaseTest  ,
TestWriteMulti   
)

Definition at line 214 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, and testing::InvokeWithoutArgs().

214  {
215  EXPECT_CALL(
216  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
217  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
218  EXPECT_CALL(testFizz_->visitor_, a1());
219  testFizz_->appWrite(appWrite("write1"));
220  EXPECT_CALL(
221  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
222  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
223  EXPECT_CALL(testFizz_->visitor_, a2());
224  testFizz_->appWrite(appWrite("write2"));
225 }
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ZlibCertificateCompressorTest  ,
TestCompressDecompress   
)

Definition at line 214 of file ZlibCertificateCompressorTest.cpp.

References fizz::CertificateAuthorities::authorities, folly::IOBuf::copyBuffer(), createCert(), encode(), fizz::DistinguishedName::encoded_name, fizz::encodeExtension(), EXPECT_EQ, EXPECT_TRUE, and folly::gen::move.

214  {
215  auto certAndKey = createCert("fizz-selfsigned", false, nullptr);
216  std::vector<folly::ssl::X509UniquePtr> certs;
217  certs.push_back(std::move(certAndKey.cert));
218  auto cert =
219  CertUtils::makeSelfCert(std::move(certs), std::move(certAndKey.key));
220  auto certMsg = cert->getCertMessage();
221 
222  // Add extension
223  CertificateAuthorities auth;
224  DistinguishedName dn;
225  dn.encoded_name = IOBuf::copyBuffer("DistinguishedName");
226  auth.authorities.push_back(std::move(dn));
227  certMsg.certificate_list[0].extensions.push_back(encodeExtension(auth));
228 
229  auto compressedCertMsg = compressor_->compress(certMsg);
230  EXPECT_EQ(compressedCertMsg.algorithm, CertificateCompressionAlgorithm::zlib);
231 
232  auto decompressedCertMsg = decompressor_->decompress(compressedCertMsg);
233  EXPECT_TRUE(decompressedCertMsg.certificate_request_context->empty());
234  EXPECT_EQ(decompressedCertMsg.certificate_list.size(), 1);
235  auto& certEntry = decompressedCertMsg.certificate_list.at(0);
236  EXPECT_EQ(certEntry.extensions.size(), 1);
237  auto decompressedPeer = CertUtils::makePeerCert(certEntry.cert_data->clone());
238  EXPECT_EQ(decompressedPeer->getIdentity(), cert->getIdentity());
239 
240  EXPECT_TRUE(IOBufEqualTo()(encode(certMsg), encode(decompressedCertMsg)));
241 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
Extension encodeExtension(const TokenBindingParameters &params)
Definition: Types.cpp:113
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeEncryptedExtensions   
)

Definition at line 216 of file HandshakeTypesTest.cpp.

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

216  {
217  auto ee = decodeHex<EncryptedExtensions>(encodedEncryptedExtensions);
218  EXPECT_EQ(ee.extensions.size(), 2);
219  EXPECT_TRUE(getExtension<SupportedGroups>(ee.extensions).hasValue());
220  auto reencoded = encodeHex(std::move(ee));
222 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string encodedEncryptedExtensions
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestSkipAndRead   
)

Definition at line 220 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, testing::Invoke(), folly::none, s, and uint64_t.

220  {
221  Sequence s;
222  read_.setSkipFailedDecryption(true);
223  addToQueue("1703010005012345678917030100050123456789170301000501234567aa");
224  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
225  .InSequence(s)
226  .WillOnce(
227  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
228  return folly::none;
229  }));
230  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
231  .InSequence(s)
232  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
233  expectSame(buf, "0123456789");
234  return getBuf("1234abcd17");
235  }));
236  auto msg = read_.read(queue_);
237  EXPECT_EQ(msg->type, ContentType::application_data);
238  expectSame(msg->fragment, "1234abcd");
239  EXPECT_EQ(queue_.chainLength(), 10);
240  EXPECT_CALL(*readAead_, _decrypt(_, _, 1))
241  .InSequence(s)
242  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
243  expectSame(buf, "01234567aa");
244  return getBuf("1234abaa17");
245  }));
246  msg = read_.read(queue_);
247  EXPECT_EQ(msg->type, ContentType::application_data);
248  expectSame(msg->fragment, "1234abaa");
249  EXPECT_TRUE(queue_.empty());
250 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodedCertificate   
)

Definition at line 224 of file HandshakeTypesTest.cpp.

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

224  {
225  auto cert = decodeHex<CertificateMsg>(encodedCertificate);
226  EXPECT_EQ(cert.certificate_request_context->computeChainDataLength(), 0);
227  EXPECT_EQ(cert.certificate_list.size(), 1);
228  EXPECT_EQ(cert.certificate_list[0].cert_data->computeChainDataLength(), 432);
229  EXPECT_TRUE(cert.certificate_list[0].extensions.empty());
230  auto reencoded = encodeHex(std::move(cert));
231  EXPECT_EQ(reencoded, encodedCertificate);
232 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string encodedCertificate
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferLarger   
)

Definition at line 225 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, and testing::Return().

225  {
226  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
227 
228  setReadCB(&readCallback_);
229 
230  auto buf = IOBuf::copyBuffer("sup");
231  expectReadBufRequest(20);
232  expectReadData("sup");
233  deliverAppData(std::move(buf));
234 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( FizzBaseTest  ,
TestAppClose   
)

Definition at line 227 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

227  {
228  EXPECT_CALL(*TestStateMachine::instance, processAppClose(_))
229  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
230  EXPECT_CALL(testFizz_->visitor_, a1());
231  testFizz_->appClose();
232 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( FizzBaseTest  ,
TestWriteNewSessionTicketInCallback   
)

Definition at line 234 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), s_, and writeNewSessionTicket().

234  {
235  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
236  .InSequence(s_)
237  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
238  EXPECT_CALL(testFizz_->visitor_, a1())
239  .InSequence(s_)
240  .WillOnce(Invoke([this]() {
241  testFizz_->waitForData();
242  testFizz_->writeNewSessionTicket(writeNewSessionTicket("appToken"));
243  }));
244  EXPECT_CALL(
245  *TestStateMachine::instance,
246  processWriteNewSessionTicket_(
247  _, WriteNewSessionTicketMatches("appToken")))
248  .InSequence(s_)
249  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
250  EXPECT_CALL(testFizz_->visitor_, a2())
251  .InSequence(s_)
252  .WillOnce(Invoke([this]() { testFizz_->appWrite(appWrite("write")); }));
253  EXPECT_CALL(
254  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write")))
255  .InSequence(s_)
256  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
257  testFizz_->newTransportData();
258 }
static WriteNewSessionTicket writeNewSessionTicket(const std::string &str)
std::string s_
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodedAndDecodeCertificateVerify   
)

Definition at line 234 of file HandshakeTypesTest.cpp.

References encodedCertVerify, EXPECT_EQ, folly::gen::move, and verify().

234  {
235  auto verify = decodeHex<CertificateVerify>(encodedCertVerify);
236  EXPECT_EQ(verify.algorithm, SignatureScheme::rsa_pss_sha256);
237  EXPECT_EQ(verify.signature->computeChainDataLength(), 128);
238  auto reencoded = encodeHex(std::move(verify));
239  EXPECT_EQ(reencoded, encodedCertVerify);
240 }
void verify(int extras)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string encodedCertVerify
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferExact   
)

Definition at line 236 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, and testing::Return().

236  {
237  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
238 
239  setReadCB(&readCallback_);
240 
241  auto buf = IOBuf::copyBuffer("sup");
242  expectReadBufRequest(3);
243  expectReadData("sup");
244  deliverAppData(std::move(buf));
245 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodedAndDecodeKeyUpdated   
)

Definition at line 242 of file HandshakeTypesTest.cpp.

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

242  {
243  auto keyUpdate = decodeHex<KeyUpdate>(encodedKeyUpdate);
244  EXPECT_EQ(keyUpdate.request_update, KeyUpdateRequest::update_not_requested);
245  auto reencoded = encodeHex(std::move(keyUpdate));
246  EXPECT_EQ(reencoded, encodedKeyUpdate);
247 }
static const std::string encodedKeyUpdate
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TEST_F ( ZlibCertificateCompressorTest  ,
TestHugeCompressedCert   
)

Definition at line 243 of file ZlibCertificateCompressorTest.cpp.

References cc, EXPECT_THAT, FAIL, testing::HasSubstr(), and tooLargeCompressedCertificate.

243  {
244  auto cc = decodeHex<CompressedCertificate>(tooLargeCompressedCertificate);
245 
246  try {
247  decompressor_->decompress(cc);
248  FAIL() << "Decompressor decompressed excessively large cert";
249  } catch (const std::exception& e) {
250  EXPECT_THAT(
251  e.what(), HasSubstr("exceeds maximum certificate message size"));
252  }
253 
254  // Lie about size, should still error.
255  cc.uncompressed_length = 64;
256 
257  try {
258  decompressor_->decompress(cc);
259  FAIL() << "Decompressor decompressed cert erroneously";
260  } catch (const std::exception& e) {
261  EXPECT_THAT(e.what(), HasSubstr("uncompressed length given is too small"));
262  }
263 }
#define FAIL()
Definition: gtest.h:1822
The non test part of the code is expected to have failures gtest_output_test_ cc
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
#define EXPECT_THAT(value, matcher)
static const std::string tooLargeCompressedCertificate
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferSmaller   
)

Definition at line 247 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, and testing::Return().

247  {
248  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
249 
250  setReadCB(&readCallback_);
251 
252  auto buf = IOBuf::copyBuffer("hello");
253  expectReadBufRequest(3);
254  expectReadData("hel");
255  expectReadBufRequest(3);
256  expectReadData("lo");
257  deliverAppData(std::move(buf));
258 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodedAndDecodeCertificateRequest   
)

Definition at line 249 of file HandshakeTypesTest.cpp.

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

249  {
250  auto cr = decodeHex<CertificateRequest>(encodedCertRequest);
251  EXPECT_TRUE(cr.certificate_request_context->empty());
252  EXPECT_EQ(cr.extensions.size(), 1);
253  EXPECT_TRUE(getExtension<SignatureAlgorithms>(cr.extensions).hasValue());
254  auto reencoded = encodeHex(std::move(cr));
255  EXPECT_EQ(reencoded, encodedCertRequest);
256 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static const std::string encodedCertRequest
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteHandshake   
)

Definition at line 252 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), folly::gen::move, and uint64_t.

252  {
253  TLSMessage msg{ContentType::handshake, getBuf("1234567890")};
254  EXPECT_CALL(*writeAead_, _encrypt(_, _, 0))
255  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
256  expectSame(buf, "123456789016");
257  return getBuf("abcd1234abcd");
258  }));
259  auto buf = write_.write(std::move(msg));
260  expectSame(buf.data, "1703030006abcd1234abcd");
261 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( HandshakeTypesTest  ,
EncodeAndDecodeCompressedCertificate   
)

Definition at line 258 of file HandshakeTypesTest.cpp.

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

258  {
259  auto cc = decodeHex<CompressedCertificate>(encodedCompressedCertificate);
260  EXPECT_EQ(cc.algorithm, CertificateCompressionAlgorithm::zlib);
261  EXPECT_EQ(cc.uncompressed_length, 0x00face);
262  EXPECT_EQ(
263  StringPiece(cc.compressed_certificate_message->coalesce()),
264  StringPiece("foobarbaz"));
265  auto reencoded = encodeHex(std::move(cc));
267 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string encodedCompressedCertificate
The non test part of the code is expected to have failures gtest_output_test_ cc
Range< const char * > StringPiece
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferAsync   
)

Definition at line 260 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, and testing::Return().

260  {
261  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
262 
263  auto buf1 = IOBuf::copyBuffer("buf1");
264  deliverAppData(std::move(buf1));
265  auto buf2 = IOBuf::copyBuffer("buf2");
266  deliverAppData(std::move(buf2));
267 
268  expectReadBufRequest(20);
269  expectReadData("buf1buf2");
270  setReadCB(&readCallback_);
271 
272  auto buf3 = IOBuf::copyBuffer("buf3");
273  expectReadBufRequest(20);
274  expectReadData("buf3");
275  deliverAppData(std::move(buf3));
276 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( FizzBaseTest  ,
TestWriteInCallback   
)

Definition at line 260 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

260  {
261  EXPECT_CALL(
262  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
263  .InSequence(s_)
264  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
265  EXPECT_CALL(testFizz_->visitor_, a1())
266  .InSequence(s_)
267  .WillOnce(Invoke([this]() {
268  testFizz_->appWrite(appWrite("write2"));
269  testFizz_->appWrite(appWrite("write3"));
270  }));
271  EXPECT_CALL(
272  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
273  .InSequence(s_)
274  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
275  EXPECT_CALL(testFizz_->visitor_, a2())
276  .InSequence(s_)
277  .WillOnce(Invoke([this]() { testFizz_->appWrite(appWrite("write4")); }));
278  EXPECT_CALL(
279  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write3")))
280  .InSequence(s_)
281  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
282  EXPECT_CALL(
283  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write4")))
284  .InSequence(s_)
285  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
286  testFizz_->appWrite(appWrite("write1"));
287 }
std::string s_
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteAppData   
)

Definition at line 263 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), folly::gen::move, and uint64_t.

263  {
264  TLSMessage msg{ContentType::application_data, getBuf("1234567890")};
265  EXPECT_CALL(*writeAead_, _encrypt(_, _, 0))
266  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
267  expectSame(buf, "123456789017");
268  return getBuf("abcd1234abcd");
269  }));
270  auto buf = write_.write(std::move(msg));
271  expectSame(buf.data, "1703030006abcd1234abcd");
272 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( ZlibCertificateCompressorTest  ,
TestBadMessages   
)

Definition at line 265 of file ZlibCertificateCompressorTest.cpp.

References exampleCompressedCertificate, EXPECT_THAT, FAIL, and testing::HasSubstr().

265  {
266  auto compressedCert =
267  decodeHex<CompressedCertificate>(exampleCompressedCertificate);
268  auto actual = compressedCert.uncompressed_length;
269 
270  // Lie about having a larger cert.
271  compressedCert.uncompressed_length = actual + 1;
272  try {
273  decompressor_->decompress(compressedCert);
274  FAIL() << "Decompressor decompressed cert erroneously";
275  } catch (const std::exception& e) {
276  EXPECT_THAT(e.what(), HasSubstr("Uncompressed length incorrect"));
277  }
278 
279  // Truncate length
280  compressedCert.uncompressed_length = actual - 1;
281  try {
282  decompressor_->decompress(compressedCert);
283  FAIL() << "Decompressor decompressed cert erroneously";
284  } catch (const std::exception& e) {
285  EXPECT_THAT(e.what(), HasSubstr("uncompressed length given is too small"));
286  }
287 
288  // Bad algorithm value
289  compressedCert.uncompressed_length = actual;
290  compressedCert.algorithm = (CertificateCompressionAlgorithm)0xdead;
291  try {
292  decompressor_->decompress(compressedCert);
293  FAIL() << "Decompressor decompressed cert erroneously";
294  } catch (const std::exception& e) {
295  EXPECT_THAT(e.what(), HasSubstr("non-zlib algorithm"));
296  }
297 }
#define FAIL()
Definition: gtest.h:1822
CertificateCompressionAlgorithm
Definition: Types.h:167
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
#define EXPECT_THAT(value, matcher)
static const std::string exampleCompressedCertificate
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteAppDataInPlace   
)

Definition at line 274 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, testing::Invoke(), folly::IOBuf::isChained(), folly::gen::move, and uint64_t.

274  {
275  TLSMessage msg{ContentType::application_data, getBuf("1234567890", 5, 17)};
276  EXPECT_CALL(*writeAead_, _encrypt(_, _, 0))
277  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
278  // footer should have been written w/o chaining
279  EXPECT_FALSE(buf->isChained());
280  expectSame(buf, "123456789017");
281  // we need to return room for the header
282  return getBuf("abcd1234abcd", 5, 0);
283  }));
284  auto buf = write_.write(std::move(msg));
285  EXPECT_FALSE(buf.data->isChained());
286  expectSame(buf.data, "1703030006abcd1234abcd");
287 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool isChained() const
Definition: IOBuf.h:760
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferZero   
)

Definition at line 278 of file AsyncFizzBaseTest.cpp.

References testing::_, folly::netops::close(), folly::IOBuf::copyBuffer(), EXPECT_CALL, folly::gen::move, testing::Return(), and socket_.

278  {
279  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
280 
281  setReadCB(&readCallback_);
282 
283  auto buf = IOBuf::copyBuffer("hello");
284  expectReadBufRequest(0);
285  EXPECT_CALL(readCallback_, readErr_(_));
287  deliverAppData(std::move(buf));
288 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
AsyncServerSocket::UniquePtr socket_
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
int close(NetworkSocket s)
Definition: NetOps.cpp:90
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestFragmentedWrite   
)

Definition at line 289 of file EncryptedRecordTest.cpp.

References testing::_, folly::IOBuf::create(), EXPECT_CALL, testing::Invoke(), folly::gen::move, s, and uint64_t.

289  {
290  TLSMessage msg{ContentType::application_data, IOBuf::create(0x4a00)};
291  msg.fragment->append(0x4a00);
292  memset(msg.fragment->writableData(), 0x1, msg.fragment->length());
293 
294  Sequence s;
295  EXPECT_CALL(*writeAead_, _encrypt(_, _, 0))
296  .InSequence(s)
297  .WillOnce(
298  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
299  return getBuf("aaaa");
300  }));
301  EXPECT_CALL(*writeAead_, _encrypt(_, _, 1))
302  .InSequence(s)
303  .WillOnce(
304  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
305  return getBuf("bbbb");
306  }));
307  auto outBuf = write_.write(std::move(msg));
308  expectSame(outBuf.data, "1703034001aaaa1703030a01bbbb");
309 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( FizzBaseTest  ,
TestAppCloseInCallback   
)

Definition at line 289 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

289  {
290  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
291  .InSequence(s_)
292  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
293  EXPECT_CALL(testFizz_->visitor_, a1())
294  .InSequence(s_)
295  .WillOnce(Invoke([this]() { testFizz_->appClose(); }));
296  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
297  .InSequence(s_)
298  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
299  EXPECT_CALL(testFizz_->visitor_, a2())
300  .InSequence(s_)
301  .WillOnce(Invoke([this]() { testFizz_->waitForData(); }));
302  EXPECT_CALL(*TestStateMachine::instance, processAppClose(_))
303  .InSequence(s_)
304  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
305  testFizz_->newTransportData();
306 }
std::string s_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestReadBufferPause   
)

Definition at line 290 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_CALL, EXPECT_TRUE, testing::Invoke(), folly::gen::move, readBuf_, and testing::Return().

290  {
291  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(false));
292 
293  setReadCB(&readCallback_);
294 
295  auto buf = IOBuf::copyBuffer("hello");
296  expectReadBufRequest(3);
297  EXPECT_CALL(readCallback_, readDataAvailable_(3))
298  .InSequence(readBufSeq_)
299  .WillOnce(Invoke([this](size_t len) {
300  EXPECT_TRUE(std::memcmp(readBuf_.data(), "hel", len) == 0);
301  this->setReadCB(nullptr);
302  }));
303  deliverAppData(std::move(buf));
304 
305  expectReadBufRequest(20);
306  expectReadData("lo");
307  setReadCB(&readCallback_);
308 }
std::array< char, 8192 > readBuf_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( FizzBaseTest  ,
TestWriteThenCloseInCallback   
)

Definition at line 308 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

308  {
309  EXPECT_CALL(
310  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
311  .InSequence(s_)
312  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
313  EXPECT_CALL(testFizz_->visitor_, a1())
314  .InSequence(s_)
315  .WillOnce(Invoke([this]() {
316  testFizz_->appWrite(appWrite("write2"));
317  testFizz_->appClose();
318  }));
319  EXPECT_CALL(
320  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
321  .InSequence(s_)
322  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
323  EXPECT_CALL(*TestStateMachine::instance, processAppClose(_))
324  .InSequence(s_)
325  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
326  testFizz_->appWrite(appWrite("write1"));
327 }
std::string s_
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadBufMovable   
)

Definition at line 310 of file AsyncFizzBaseTest.cpp.

References EXPECT_TRUE.

310  {
311  expectTransportReadCallback();
312  startTransportReads();
313  EXPECT_TRUE(transportReadCallback_->isBufferMovable());
314 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteSplittingWholeBuf   
)

Definition at line 311 of file EncryptedRecordTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), folly::IOBuf::create(), EXPECT_CALL, testing::Invoke(), folly::gen::move, s, and uint64_t.

311  {
312  TLSMessage msg{ContentType::application_data, IOBuf::create(2000)};
313  msg.fragment->append(2000);
314  memset(msg.fragment->writableData(), 0x1, msg.fragment->length());
315  msg.fragment->prependChain(IOBuf::copyBuffer("moredata"));
316 
317  Sequence s;
318  EXPECT_CALL(*writeAead_, _encrypt(_, _, _))
319  .Times(2)
320  .WillRepeatedly(
321  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
322  return getBuf("aaaa");
323  }));
324  write_.write(std::move(msg));
325 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadBufMove   
)

Definition at line 316 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), folly::eq, EXPECT_CALL, and EXPECT_TRUE.

316  {
318  expectTransportReadCallback();
319  startTransportReads();
320 
321  auto buf = IOBuf::copyBuffer("hello");
322  EXPECT_CALL(*this, transportDataAvailable());
323  transportReadCallback_->readBufferAvailable(buf->clone());
324  EXPECT_TRUE(eq(*buf, *transportReadBuf_.front()));
325 
326  EXPECT_CALL(*this, transportDataAvailable());
327  transportReadCallback_->readBufferAvailable(IOBuf::copyBuffer("world"));
328  EXPECT_TRUE(eq(*IOBuf::copyBuffer("helloworld"), *transportReadBuf_.front()));
329 }
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteSplittingCombineSmall   
)

Definition at line 327 of file EncryptedRecordTest.cpp.

References testing::_, folly::IOBuf::copyBuffer(), folly::IOBuf::create(), EXPECT_CALL, testing::Invoke(), folly::gen::move, s, and uint64_t.

327  {
328  TLSMessage msg{ContentType::application_data, IOBuf::create(500)};
329  msg.fragment->append(500);
330  memset(msg.fragment->writableData(), 0x1, msg.fragment->length());
331  msg.fragment->prependChain(IOBuf::copyBuffer("moredata"));
332 
333  Sequence s;
334  EXPECT_CALL(*writeAead_, _encrypt(_, _, _))
335  .Times(1)
336  .WillRepeatedly(
337  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
338  return getBuf("aaaa");
339  }));
340  write_.write(std::move(msg));
341 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( FizzBaseTest  ,
TestDeleteInCallback   
)

Definition at line 329 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, testing::Invoke(), testing::InvokeWithoutArgs(), ptr, and s_.

329  {
330  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
331  .InSequence(s_)
332  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
333  EXPECT_CALL(testFizz_->visitor_, a1())
334  .InSequence(s_)
335  .WillOnce(Invoke([this]() { testFizz_.reset(); }));
336  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
337  .InSequence(s_)
338  .WillOnce(InvokeWithoutArgs([]() { return Actions{A2()}; }));
339  EXPECT_CALL(testFizz_->visitor_, a2())
340  .InSequence(s_)
341  .WillOnce(Invoke([ptr = testFizz_.get()]() { ptr->waitForData(); }));
342  testFizz_->newTransportData();
343 }
void * ptr
std::string s_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadBufAvail   
)

Definition at line 331 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::copyBuffer(), folly::eq, EXPECT_CALL, EXPECT_GE, EXPECT_LE, and EXPECT_TRUE.

331  {
332  void* buf;
333  size_t len;
335  expectTransportReadCallback();
336  startTransportReads();
337 
338  EXPECT_CALL(*this, transportDataAvailable());
339  transportReadCallback_->getReadBuffer(&buf, &len);
340  // Make sure the buffer is a reasonable size.
341  EXPECT_GE(len, 128);
342  EXPECT_LE(len, 1024 * 64);
343  std::memcpy(buf, "hello", 5);
344  transportReadCallback_->readDataAvailable(5);
345  EXPECT_TRUE(eq(*IOBuf::copyBuffer("hello"), *transportReadBuf_.front()));
346 
347  EXPECT_CALL(*this, transportDataAvailable());
348  transportReadCallback_->getReadBuffer(&buf, &len);
349  std::memcpy(buf, "goodbye", 7);
350  transportReadCallback_->readDataAvailable(7);
351  EXPECT_TRUE(
352  eq(*IOBuf::copyBuffer("hellogoodbye"), *transportReadBuf_.front()));
353 }
#define EXPECT_LE(val1, val2)
Definition: gtest.h:1928
#define EXPECT_GE(val1, val2)
Definition: gtest.h:1932
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteSeqNum   
)

Definition at line 343 of file EncryptedRecordTest.cpp.

References testing::_, EXPECT_CALL, i, testing::Invoke(), folly::gen::move, and uint64_t.

343  {
344  for (int i = 0; i < 10; i++) {
345  TLSMessage msg{ContentType::application_data, getBuf("1234567890")};
346  EXPECT_CALL(*writeAead_, _encrypt(_, _, i))
347  .WillOnce(
348  Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
349  expectSame(buf, "123456789017");
350  return getBuf("abcd1234abcd");
351  }));
352  write_.write(std::move(msg));
353  }
354 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( FizzBaseTest  ,
TestStopOnError   
)

Definition at line 345 of file FizzBaseTest.cpp.

References testing::_, Error, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, testing::Invoke(), testing::InvokeWithoutArgs(), and s_.

345  {
346  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
347  .InSequence(s_)
348  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
349  EXPECT_CALL(testFizz_->visitor_, a1())
350  .InSequence(s_)
351  .WillOnce(
352  Invoke([this]() { testFizz_->state_.state_ = StateEnum::Error; }));
353  EXPECT_FALSE(testFizz_->inErrorState());
354  testFizz_->newTransportData();
355  EXPECT_TRUE(testFizz_->inErrorState());
356 }
std::string s_
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
error_stage Error
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadError   
)

Definition at line 355 of file AsyncFizzBaseTest.cpp.

References testing::_, and EXPECT_CALL.

355  {
356  expectTransportReadCallback();
357  startTransportReads();
358 
359  EXPECT_CALL(*this, transportError(_));
360  transportReadCallback_->readErr(ase_);
361 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteEmpty   
)

Definition at line 356 of file EncryptedRecordTest.cpp.

References folly::IOBuf::create(), EXPECT_TRUE, and folly::gen::move.

356  {
357  TLSMessage msg{ContentType::application_data, folly::IOBuf::create(0)};
358  auto outBuf = write_.write(std::move(msg));
359  EXPECT_TRUE(outBuf.data->empty());
360 }
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( FizzBaseTest  ,
TestAsyncAction   
)

Definition at line 358 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, folly::Promise< T >::getFuture(), testing::InvokeWithoutArgs(), and folly::Promise< T >::setValue().

358  {
360  EXPECT_CALL(
361  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
362  .WillOnce(InvokeWithoutArgs([&p]() { return p.getFuture(); }));
363  testFizz_->appWrite(appWrite("write1"));
364  testFizz_->appWrite(appWrite("write2"));
365  EXPECT_CALL(
366  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
367  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
368  p.setValue(Actions{});
369 }
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
Future< T > getFuture()
Definition: Promise-inl.h:97
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
Definition: Promise.h:326
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteMaxSize   
)

Definition at line 362 of file EncryptedRecordTest.cpp.

References testing::_, folly::IOBuf::create(), EXPECT_CALL, testing::Invoke(), folly::gen::move, s, and uint64_t.

362  {
363  write_.setMaxRecord(1900);
364 
365  TLSMessage msg{ContentType::application_data, IOBuf::create(2000)};
366  msg.fragment->append(2000);
367  memset(msg.fragment->writableData(), 0x1, msg.fragment->length());
368 
369  Sequence s;
370  EXPECT_CALL(*writeAead_, _encrypt(_, _, _))
371  .Times(2)
372  .WillRepeatedly(
373  Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
374  return getBuf("aaaa");
375  }));
376  write_.write(std::move(msg));
377 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadEOF   
)

Definition at line 363 of file AsyncFizzBaseTest.cpp.

References testing::_, folly::AsyncSocketException::END_OF_FILE, EXPECT_CALL, EXPECT_EQ, folly::AsyncSocketException::getType(), and testing::Invoke().

363  {
364  expectTransportReadCallback();
365  startTransportReads();
366 
367  EXPECT_CALL(*this, transportError(_))
368  .WillOnce(Invoke([](const AsyncSocketException& ex) {
369  EXPECT_EQ(ex.getType(), AsyncSocketException::END_OF_FILE);
370  }));
371  transportReadCallback_->readEOF();
372 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
AsyncSocketExceptionType getType() const noexcept
fizz::test::TEST_F ( FizzBaseTest  ,
TestAsyncActionDelete   
)

Definition at line 371 of file FizzBaseTest.cpp.

References testing::_, appWrite(), EXPECT_CALL, folly::Promise< T >::getFuture(), testing::InvokeWithoutArgs(), and folly::Promise< T >::setValue().

371  {
373  EXPECT_CALL(
374  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
375  .WillOnce(InvokeWithoutArgs([&p]() { return p.getFuture(); }));
376  testFizz_->appWrite(appWrite("write1"));
377  testFizz_->appWrite(appWrite("write2"));
378  testFizz_.reset();
379  EXPECT_CALL(
380  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
381  .WillOnce(InvokeWithoutArgs([]() { return Actions{}; }));
382  p.setValue(Actions{});
383 }
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
Future< T > getFuture()
Definition: Promise-inl.h:97
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
Definition: Promise.h:326
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestTransportReadBufPause   
)

Definition at line 374 of file AsyncFizzBaseTest.cpp.

References folly::IOBuf::create(), EXPECT_CALL, EXPECT_EQ, EXPECT_NE, and folly::gen::move.

374  {
375  expectTransportReadCallback();
376  startTransportReads();
377 
378  auto bigBuf = IOBuf::create(1024 * 1024);
379  bigBuf->append(1024 * 1024);
380  expectTransportReadCallback();
381  EXPECT_CALL(*this, transportDataAvailable());
382  transportReadCallback_->readBufferAvailable(std::move(bigBuf));
383  EXPECT_EQ(transportReadCallback_, nullptr);
384 
385  expectTransportReadCallback();
386  setReadCB(&readCallback_);
387  EXPECT_NE(transportReadCallback_, nullptr);
388 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_CALL(obj, call)
fizz::test::TEST_F ( EncryptedRecordTest  ,
TestWriteMinSize   
)

Definition at line 379 of file EncryptedRecordTest.cpp.

References testing::_, folly::IOBuf::computeChainDataLength(), folly::IOBuf::create(), EXPECT_CALL, EXPECT_EQ, testing::Invoke(), folly::gen::move, cpp.ast::next(), s, and uint64_t.

379  {
380  write_.setMinDesiredRecord(1700);
381  TLSMessage msg{ContentType::application_data, IOBuf::create(1000)};
382  msg.fragment->append(1000);
383  memset(msg.fragment->writableData(), 0x1, msg.fragment->length());
384  auto next = IOBuf::create(1000);
385  next->append(1000);
386  memset(next->writableData(), 0x2, next->length());
387  msg.fragment->prependChain(std::move(next));
388 
389  Sequence s;
390  EXPECT_CALL(*writeAead_, _encrypt(_, _, _))
391  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
392  // one byte for footer
393  EXPECT_EQ(buf->computeChainDataLength(), 1701);
394  return getBuf("aaaa");
395  }))
396  .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
397  // one byte for footer
398  EXPECT_EQ(buf->computeChainDataLength(), 301);
399  return getBuf("bbbb");
400  }));
401  write_.write(std::move(msg));
402 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
static set< string > s
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
def next(obj)
Definition: ast.py:58
fizz::test::TEST_F ( FizzBaseTest  ,
TestActionProcessing   
)

Definition at line 385 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, and testing::InvokeWithoutArgs().

385  {
386  EXPECT_CALL(*TestStateMachine::instance, processAppClose(_))
387  .WillOnce(InvokeWithoutArgs([this]() {
388  EXPECT_TRUE(testFizz_->actionProcessing());
389  return Actions{};
390  }));
391  EXPECT_FALSE(testFizz_->actionProcessing());
392  testFizz_->appClose();
393  EXPECT_FALSE(testFizz_->actionProcessing());
394 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestAppReadBufPause   
)

Definition at line 390 of file AsyncFizzBaseTest.cpp.

References testing::_, folly::IOBuf::create(), EXPECT_CALL, EXPECT_EQ, EXPECT_NE, folly::gen::move, and testing::Return().

390  {
391  EXPECT_CALL(readCallback_, isBufferMovable_()).WillRepeatedly(Return(true));
392  expectTransportReadCallback();
393  startTransportReads();
394 
395  auto bigBuf = IOBuf::create(1024 * 1024);
396  bigBuf->append(1024 * 1024);
397  expectTransportReadCallback();
398  deliverAppData(std::move(bigBuf));
399  EXPECT_EQ(transportReadCallback_, nullptr);
400 
401  expectTransportReadCallback();
402  EXPECT_CALL(readCallback_, readBufferAvailable_(_));
403  setReadCB(&readCallback_);
404  EXPECT_NE(transportReadCallback_, nullptr);
405 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTest  ,
BasicHandshake   
)

Definition at line 394 of file HandshakeTest.cpp.

394  {
395  expectSuccess();
396  doHandshake();
397  verifyParameters();
398  sendAppData();
399 }
fizz::test::TEST_F ( FizzBaseTest  ,
TestActionProcessingAsync   
)

Definition at line 396 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, folly::Promise< T >::getFuture(), testing::InvokeWithoutArgs(), and folly::Promise< T >::setValue().

396  {
398  EXPECT_CALL(*TestStateMachine::instance, processAppClose(_))
399  .WillOnce(InvokeWithoutArgs([this, &p]() {
400  EXPECT_TRUE(testFizz_->actionProcessing());
401  return p.getFuture();
402  }));
403  EXPECT_FALSE(testFizz_->actionProcessing());
404  testFizz_->appClose();
405  EXPECT_TRUE(testFizz_->actionProcessing());
406  p.setValue(Actions{});
407  EXPECT_FALSE(testFizz_->actionProcessing());
408 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
Future< T > getFuture()
Definition: Promise-inl.h:97
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
Definition: Promise.h:326
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( HandshakeTest  ,
BasicHandshakeTrickle   
)

Definition at line 401 of file HandshakeTest.cpp.

401  {
402  clientTransport_->setTrickle(true);
403  serverTransport_->setTrickle(true);
404  expectSuccess();
405  doHandshake();
406  verifyParameters();
407  sendAppData();
408 }
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestWriteSuccess   
)

Definition at line 407 of file AsyncFizzBaseTest.cpp.

References folly::AsyncWriter::WriteCallback::writeSuccess().

407  {
408  AsyncTransportWrapper::WriteCallback* writeCallback = this;
409  writeCallback->writeSuccess();
410 }
virtual void writeSuccess() noexcept=0
fizz::test::TEST_F ( FizzBaseTest  ,
TestErrorPendingEvents   
)

Definition at line 410 of file FizzBaseTest.cpp.

References testing::_, appWrite(), fizz::EarlyAppWrite::callback, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, testing::Invoke(), testing::InvokeWithoutArgs(), folly::gen::move, and folly::AsyncSocketException::UNKNOWN.

410  {
411  EXPECT_CALL(
412  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write1")))
413  .WillOnce(InvokeWithoutArgs([]() { return Actions{A1()}; }));
414  EXPECT_CALL(testFizz_->visitor_, a1()).WillOnce(Invoke([this]() {
415  testFizz_->appWrite(appWrite("write2"));
416  EarlyAppWrite earlyWrite;
417  earlyWrite.callback = &earlyWriteCallback_;
418  testFizz_->earlyAppWrite(std::move(earlyWrite));
419  auto w3 = appWrite("write3");
420  w3.callback = &writeCallback_;
421  testFizz_->appWrite(std::move(w3));
422  testFizz_->appWrite(appWrite("write4"));
423  testFizz_->appClose();
424  }));
425  EXPECT_CALL(
426  *TestStateMachine::instance, processAppWrite_(_, WriteMatches("write2")))
427  .WillOnce(InvokeWithoutArgs([this]() {
428  testFizz_->moveToErrorState(
430  return Actions{};
431  }));
432  EXPECT_CALL(earlyWriteCallback_, writeErr_(0, _));
433  EXPECT_CALL(writeCallback_, writeErr_(0, _));
434  EXPECT_FALSE(testFizz_->inErrorState());
435  testFizz_->appWrite(appWrite("write1"));
436  EXPECT_TRUE(testFizz_->inErrorState());
437 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static AppWrite appWrite(const std::string &str)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
string UNKNOWN
Definition: tokenize.py:53
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( HandshakeTest  ,
P256   
)

Definition at line 410 of file HandshakeTest.cpp.

References clientContext_.

410  {
411  clientContext_->setSupportedGroups(
412  {NamedGroup::x25519, NamedGroup::secp256r1});
413  clientContext_->setDefaultShares({NamedGroup::x25519, NamedGroup::secp256r1});
414  serverContext_->setSupportedGroups({NamedGroup::secp256r1});
415  expected_.group = NamedGroup::secp256r1;
416 
417  expectSuccess();
418  doHandshake();
419  verifyParameters();
420  sendAppData();
421 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestWriteError   
)

Definition at line 412 of file AsyncFizzBaseTest.cpp.

References testing::_, EXPECT_CALL, and folly::AsyncWriter::WriteCallback::writeErr().

412  {
413  AsyncTransportWrapper::WriteCallback* writeCallback = this;
414  EXPECT_CALL(*this, transportError(_));
415  writeCallback->writeErr(0, ase_);
416 }
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
virtual void writeErr(size_t bytesWritten, const AsyncSocketException &ex) noexcept=0
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestHandshakeTimeout   
)

Definition at line 418 of file AsyncFizzBaseTest.cpp.

References testing::_, testing::DoAll(), EXPECT_CALL, EXPECT_EQ, folly::AsyncSocketException::getType(), testing::Invoke(), ON_CALL, testing::Return(), folly::AsyncSocketException::TIMED_OUT, folly::detail::timeout, and folly::AsyncTimeout::timeoutExpired().

418  {
419  MockTimeoutManager manager;
420  ON_CALL(manager, isInTimeoutManagerThread()).WillByDefault(Return(true));
421  attachTimeoutManager(&manager);
423 
424  EXPECT_CALL(manager, scheduleTimeout(_, std::chrono::milliseconds(2)))
425  .WillOnce(DoAll(SaveArg<0>(&timeout), Return(true)));
426  startHandshakeTimeout(std::chrono::milliseconds(2));
427 
428  EXPECT_CALL(*this, transportError(_))
429  .WillOnce(Invoke([](const AsyncSocketException& ex) {
430  EXPECT_EQ(ex.getType(), AsyncSocketException::TIMED_OUT);
431  }));
432  timeout->timeoutExpired();
433 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
virtual void timeoutExpired() noexcept=0
#define ON_CALL(obj, call)
internal::DoBothAction< Action1, Action2 > DoAll(Action1 a1, Action2 a2)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
AsyncSocketExceptionType getType() const noexcept
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTest  ,
P384   
)

Definition at line 423 of file HandshakeTest.cpp.

References clientContext_.

423  {
424  clientContext_->setSupportedGroups(
425  {NamedGroup::x25519, NamedGroup::secp384r1});
426  clientContext_->setDefaultShares({NamedGroup::x25519, NamedGroup::secp384r1});
427  serverContext_->setSupportedGroups({NamedGroup::secp384r1});
428  expected_.group = NamedGroup::secp384r1;
429 
430  expectSuccess();
431  doHandshake();
432  verifyParameters();
433  sendAppData();
434 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestAttachEventBase   
)

Definition at line 435 of file AsyncFizzBaseTest.cpp.

References EXPECT_CALL, ON_CALL, testing::Return(), s, and socket_.

435  {
436  EventBase evb;
437  expectTransportReadCallback();
438  startTransportReads();
439  ON_CALL(*socket_, good()).WillByDefault(Return(true));
440  Sequence s;
441 
442  EXPECT_CALL(*socket_, setReadCB(nullptr)).InSequence(s);
443  EXPECT_CALL(*socket_, detachEventBase()).InSequence(s);
444  detachEventBase();
445 
446  EXPECT_CALL(*socket_, attachEventBase(&evb)).InSequence(s);
447  EXPECT_CALL(*socket_, setReadCB(transportReadCallback_)).InSequence(s);
448  attachEventBase(&evb);
449 }
AsyncServerSocket::UniquePtr socket_
#define ON_CALL(obj, call)
static set< string > s
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTest  ,
P521   
)

Definition at line 436 of file HandshakeTest.cpp.

References clientContext_.

436  {
437  clientContext_->setSupportedGroups(
438  {NamedGroup::x25519, NamedGroup::secp521r1});
439  clientContext_->setDefaultShares({NamedGroup::x25519, NamedGroup::secp521r1});
440  serverContext_->setSupportedGroups({NamedGroup::secp521r1});
441  expected_.group = NamedGroup::secp521r1;
442 
443  expectSuccess();
444  doHandshake();
445  verifyParameters();
446  sendAppData();
447 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( FizzBaseTest  ,
EventAfterErrorState   
)

Definition at line 439 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, testing::InvokeWithoutArgs(), and folly::AsyncSocketException::UNKNOWN.

439  {
440  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
441  .WillOnce(InvokeWithoutArgs([this]() {
442  testFizz_->moveToErrorState(
444  return Actions{};
445  }));
446  EXPECT_FALSE(testFizz_->inErrorState());
447  testFizz_->newTransportData();
448  EXPECT_TRUE(testFizz_->inErrorState());
449 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
string UNKNOWN
Definition: tokenize.py:53
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_F ( HandshakeTest  ,
GroupServerPref   
)

Definition at line 449 of file HandshakeTest.cpp.

References clientContext_.

449  {
450  clientContext_->setSupportedGroups(
451  {NamedGroup::secp256r1, NamedGroup::x25519});
452  clientContext_->setDefaultShares({NamedGroup::secp256r1, NamedGroup::x25519});
453  serverContext_->setSupportedGroups(
454  {NamedGroup::x25519, NamedGroup::secp256r1});
455  expected_.group = NamedGroup::x25519;
456 
457  expectSuccess();
458  doHandshake();
459  verifyParameters();
460  sendAppData();
461 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( FizzBaseTest  ,
TestManyActions   
)

Definition at line 451 of file FizzBaseTest.cpp.

References testing::_, EXPECT_CALL, i, and testing::InvokeWithoutArgs().

451  {
452  size_t i = 0;
453  EXPECT_CALL(*TestStateMachine::instance, processSocketData(_, _))
454  .WillRepeatedly(InvokeWithoutArgs([this, &i]() {
455  if (++i == 10000) {
456  testFizz_->waitForData();
457  }
458  return Actions{};
459  }));
460  testFizz_->newTransportData();
461 }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::vector< Action > Actions
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
fizz::test::TEST_F ( AsyncFizzBaseTest  ,
TestAttachEventBaseWithReadCb   
)

Definition at line 451 of file AsyncFizzBaseTest.cpp.

References EXPECT_CALL, ON_CALL, testing::Return(), s, and socket_.

451  {
452  EventBase evb;
453  expectTransportReadCallback();
454  startTransportReads();
455  ON_CALL(*socket_, good()).WillByDefault(Return(false));
456  Sequence s;
457 
458  EXPECT_CALL(*socket_, setReadCB(nullptr)).InSequence(s);
459  EXPECT_CALL(*socket_, detachEventBase()).InSequence(s);
460  detachEventBase();
461 
462  expectTransportReadCallback();
463  setReadCB(&readCallback_);
464  EXPECT_CALL(*socket_, attachEventBase(&evb)).InSequence(s);
465  EXPECT_CALL(*socket_, setReadCB(transportReadCallback_)).InSequence(s);
466  attachEventBase(&evb);
467 }
AsyncServerSocket::UniquePtr socket_
#define ON_CALL(obj, call)
static set< string > s
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
fizz::test::TEST_F ( HandshakeTest  ,
GroupMismatch   
)

Definition at line 463 of file HandshakeTest.cpp.

References clientContext_.

463  {
464  clientContext_->setSupportedGroups({NamedGroup::secp256r1});
465  clientContext_->setDefaultShares({NamedGroup::secp256r1});
466  serverContext_->setSupportedGroups({NamedGroup::x25519});
467 
468  expectError("alert: handshake_failure", "no group match");
469  doHandshake();
470 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
SchemeServerPref   
)

Definition at line 472 of file HandshakeTest.cpp.

References clientContext_.

472  {
473  clientContext_->setSupportedSigSchemes(
474  {SignatureScheme::ecdsa_secp256r1_sha256,
475  SignatureScheme::rsa_pss_sha256});
476  serverContext_->setSupportedSigSchemes(
477  {SignatureScheme::rsa_pss_sha256,
478  SignatureScheme::ecdsa_secp256r1_sha256});
479  expected_.scheme = SignatureScheme::rsa_pss_sha256;
480 
481  expectSuccess();
482  doHandshake();
483  verifyParameters();
484  sendAppData();
485 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
SchemeMismatch   
)

Definition at line 487 of file HandshakeTest.cpp.

References clientContext_.

487  {
488  clientContext_->setSupportedSigSchemes(
489  {SignatureScheme::ecdsa_secp256r1_sha256});
490  serverContext_->setSupportedSigSchemes({SignatureScheme::rsa_pss_sha256});
491 
492  // The server will try using its RSA cert anyway, so it will be the client
493  // that actually rejects that.
494  expectError("unsupported sig scheme", "alert: illegal_parameter");
495  doHandshake();
496 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
HRR   
)

Definition at line 498 of file HandshakeTest.cpp.

References clientContext_.

498  {
499  clientContext_->setDefaultShares({});
500  expected_.clientKexType = expected_.serverKexType =
501  KeyExchangeType::HelloRetryRequest;
502 
503  expectSuccess();
504  doHandshake();
505  verifyParameters();
506  sendAppData();
507 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
PskDheKe   
)

Definition at line 509 of file HandshakeTest.cpp.

509  {
510  setupResume();
511 
512  expectSuccess();
513  doHandshake();
514  verifyParameters();
515  sendAppData();
516 }
fizz::test::TEST_F ( HandshakeTest  ,
HrrPskDheKe   
)

Definition at line 518 of file HandshakeTest.cpp.

References clientContext_.

518  {
519  clientContext_->setDefaultShares({});
520  expected_.clientKexType = expected_.serverKexType =
521  KeyExchangeType::HelloRetryRequest;
522  setupResumeWithHRR();
523  expectSuccess();
524  doHandshake();
525  verifyParameters();
526  sendAppData();
527 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
HrrPskDheKeWithCache   
)

Definition at line 529 of file HandshakeTest.cpp.

References clientContext_.

529  {
530  clientContext_->setDefaultShares({});
531  expected_.clientKexType = expected_.serverKexType =
532  KeyExchangeType::HelloRetryRequest;
533  setupResume();
534 
535  // OneRtt as the first round should have cached the group
536  expected_.clientKexType = expected_.serverKexType = KeyExchangeType::OneRtt;
537  expectSuccess();
538  doHandshake();
539  verifyParameters();
540  sendAppData();
541 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
HrrIncompatiblePsk   
)

Definition at line 543 of file HandshakeTest.cpp.

543  {
544  expectSuccess();
545  doHandshake();
546  verifyParameters();
547  resetTransports();
548 
549  serverContext_->setSupportedGroups({NamedGroup::secp256r1});
550  serverContext_->setSupportedCiphers({{CipherSuite::TLS_AES_256_GCM_SHA384}});
551  expected_.group = NamedGroup::secp256r1;
552  expected_.cipher = CipherSuite::TLS_AES_256_GCM_SHA384;
553  expected_.clientKexType = expected_.serverKexType =
554  KeyExchangeType::HelloRetryRequest;
555 
556  expectSuccess();
557  doHandshake();
558  verifyParameters();
559  sendAppData();
560 }
fizz::test::TEST_F ( HandshakeTest  ,
PskKe   
)

Definition at line 562 of file HandshakeTest.cpp.

References clientContext_, folly::none, and folly::test::TEST_F().

562  {
563  serverContext_->setSupportedPskModes({PskKeyExchangeMode::psk_ke});
564  setupResume();
565 
566  expected_.group = none;
567  expected_.pskMode = PskKeyExchangeMode::psk_ke;
568  expected_.clientKexType = expected_.serverKexType = KeyExchangeType::None;
569 
570  expectSuccess();
571  doHandshake();
572  verifyParameters();
573  sendAppData();
574 }
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTest  ,
TestEkmSame   
)

Definition at line 597 of file HandshakeTest.cpp.

References EXPECT_THROW, and EXPECT_TRUE.

597  {
598  expectSuccess();
599  doHandshake();
600  auto clientEkm = client_->getEkm("EXPORTER-Some-Label", nullptr, 32);
601  auto serverEkm = server_->getEkm("EXPORTER-Some-Label", nullptr, 32);
602  EXPECT_TRUE(IOBufEqualTo()(clientEkm, serverEkm));
603  EXPECT_THROW(
604  client_->getEarlyEkm("EXPORTER-Some-Label", nullptr, 32), std::exception);
605  EXPECT_THROW(
606  server_->getEarlyEkm("EXPORTER-Some-Label", nullptr, 32), std::exception);
607 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( HandshakeTest  ,
TestEarlyEkmSame   
)

Definition at line 609 of file HandshakeTest.cpp.

References clientContext_, and EXPECT_TRUE.

609  {
610  clientContext_->setSendEarlyData(true);
611  setupResume();
612 
613  expectSuccess();
614  doHandshake();
615  auto clientEkm = client_->getEarlyEkm("EXPORTER-Some-Label", nullptr, 32);
616  auto serverEkm = server_->getEarlyEkm("EXPORTER-Some-Label", nullptr, 32);
617  EXPECT_TRUE(IOBufEqualTo()(clientEkm, serverEkm));
618 }
std::shared_ptr< FizzClientContext > clientContext_
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( HandshakeTest  ,
TestExtensions   
)

Definition at line 620 of file HandshakeTest.cpp.

References context, EXPECT_EQ, and EXPECT_TRUE.

620  {
621  auto context = std::make_shared<TokenBindingContext>();
622  auto clientTokBind = std::make_shared<TokenBindingClientExtension>(context);
623  auto serverTokBind = std::make_shared<TokenBindingServerExtension>(context);
624  clientExtensions_ = clientTokBind;
625  serverExtensions_ = serverTokBind;
626  resetTransports();
627  doHandshake();
628  EXPECT_TRUE(clientTokBind->getNegotiatedKeyParam().hasValue());
629  EXPECT_TRUE(clientTokBind->getVersion().hasValue());
630  EXPECT_TRUE(serverTokBind->getNegotiatedKeyParam().hasValue());
631  EXPECT_EQ(
632  *clientTokBind->getNegotiatedKeyParam(),
633  TokenBindingKeyParameters::ecdsap256);
634  EXPECT_EQ(
635  *clientTokBind->getVersion(),
636  TokenBindingProtocolVersion::token_binding_0_14);
637  EXPECT_EQ(
638  *serverTokBind->getNegotiatedKeyParam(),
639  TokenBindingKeyParameters::ecdsap256);
640 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
context
Definition: CMakeCache.txt:563
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TEST_F ( HandshakeTest  ,
BasicCertRequest   
)

Definition at line 642 of file HandshakeTest.cpp.

References getCert(), and kClientAuthClientCert.

642  {
643  expectSuccess();
644  serverContext_->setClientAuthMode(ClientAuthMode::Required);
645  expected_.clientCert = std::make_shared<PeerCertImpl<KeyType::RSA>>(
647  doHandshake();
648  verifyParameters();
649  sendAppData();
650 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
constexpr folly::StringPiece kClientAuthClientCert
Definition: TestUtil.h:216
fizz::test::TEST_F ( HandshakeTest  ,
CertRequestPskPreservesIdentity   
)

Definition at line 664 of file HandshakeTest.cpp.

References getCert(), and kClientAuthClientCert.

664  {
665  serverContext_->setClientAuthMode(ClientAuthMode::Required);
666  expected_.clientCert = std::make_shared<PeerCertImpl<KeyType::RSA>>(
668  setupResume();
669 
670  expectSuccess();
671  doHandshake();
672  verifyParameters();
673  sendAppData();
674 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
constexpr folly::StringPiece kClientAuthClientCert
Definition: TestUtil.h:216
fizz::test::TEST_F ( HandshakeTest  ,
CertRequestNoCert   
)

Definition at line 676 of file HandshakeTest.cpp.

References clientContext_.

676  {
677  serverContext_->setClientAuthMode(ClientAuthMode::Required);
678  clientContext_->setClientCertificate(nullptr);
679  expectServerError(
680  "alert: certificate_required", "certificate requested but none received");
681  doHandshake();
682 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
CertRequestPermitNoCert   
)

Definition at line 684 of file HandshakeTest.cpp.

References clientContext_.

684  {
685  serverContext_->setClientAuthMode(ClientAuthMode::Optional);
686  clientContext_->setClientCertificate(nullptr);
687  expectSuccess();
688  doHandshake();
689  verifyParameters();
690  sendAppData();
691 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
CertRequestBadCert   
)

Definition at line 693 of file HandshakeTest.cpp.

References clientContext_, createCert(), and folly::gen::move.

693  {
694  serverContext_->setClientAuthMode(ClientAuthMode::Required);
695  auto badCert = createCert("foo", false, nullptr);
696  std::vector<folly::ssl::X509UniquePtr> certVec;
697  certVec.emplace_back(std::move(badCert.cert));
698  clientContext_->setClientCertificate(
699  std::make_shared<SelfCertImpl<KeyType::P256>>(
700  std::move(badCert.key), std::move(certVec)));
701  expectServerError("alert: bad_certificate", "client certificate failure");
702  doHandshake();
703 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< FizzClientContext > clientContext_
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
Definition: Utilities.h:35
fizz::test::TEST_F ( HandshakeTest  ,
BasicCertCompression   
)

Definition at line 705 of file HandshakeTest.cpp.

References clientContext_.

705  {
706  expectSuccess();
707  auto decompressor = std::make_shared<ZlibCertificateDecompressor>();
708  auto decompressionMgr = std::make_shared<CertDecompressionManager>();
709  decompressionMgr->setDecompressors(
710  {std::static_pointer_cast<CertificateDecompressor>(decompressor)});
711  clientContext_->setCertDecompressionManager(decompressionMgr);
712  serverContext_->setSupportedCompressionAlgorithms(
713  {CertificateCompressionAlgorithm::zlib});
714  expected_.serverCertCompAlgo = CertificateCompressionAlgorithm::zlib;
715  doHandshake();
716  verifyParameters();
717  sendAppData();
718 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataAccepted   
)

Definition at line 720 of file HandshakeTest.cpp.

References clientContext_.

720  {
721  clientContext_->setSendEarlyData(true);
722  setupResume();
723 
724  expected_.pskType = PskType::Resumption;
725  expected_.earlyDataType = EarlyDataType::Accepted;
726 
727  expectClientSuccess();
728  doClientHandshake();
729  verifyEarlyParameters();
730  clientWrite("early");
731 
732  expectReplaySafety();
733  expectServerSuccess();
734  expectServerRead("early");
735  doServerHandshake();
736  verifyParameters();
737  sendAppData();
738 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataRejected   
)

Definition at line 740 of file HandshakeTest.cpp.

References clientContext_.

740  {
741  clientContext_->setSendEarlyData(true);
742  setupResume();
743 
744  serverContext_->setEarlyDataSettings(false, {}, nullptr);
745  expected_.pskType = PskType::Resumption;
746  expected_.earlyDataType = EarlyDataType::Rejected;
747 
748  expectClientSuccess();
749  doClientHandshake();
750  verifyEarlyParameters();
751  clientWrite("early");
752 
753  expectEarlyDataRejectError();
754  expectServerSuccess();
755  doServerHandshake();
756  verifyParameters();
757 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataRejectedHrr   
)

Definition at line 759 of file HandshakeTest.cpp.

References clientContext_.

759  {
760  clientContext_->setSendEarlyData(true);
761  setupResume();
762 
763  serverContext_->setSupportedGroups({NamedGroup::secp256r1});
764  expected_.pskType = PskType::Resumption;
765  expected_.earlyDataType = EarlyDataType::Rejected;
766  expected_.clientKexType = expected_.serverKexType =
767  KeyExchangeType::HelloRetryRequest;
768  expected_.group = NamedGroup::secp256r1;
769 
770  expectClientSuccess();
771  doClientHandshake();
772  verifyEarlyParameters();
773  clientWrite("early");
774 
775  expectEarlyDataRejectError();
776  expectServerSuccess();
777  doServerHandshake();
778  verifyParameters();
779 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataRejectedResend   
)

Definition at line 781 of file HandshakeTest.cpp.

References clientContext_.

781  {
782  clientContext_->setSendEarlyData(true);
783  setupResume();
784 
785  serverContext_->setEarlyDataSettings(false, {}, nullptr);
786  client_->setEarlyDataRejectionPolicy(
787  EarlyDataRejectionPolicy::AutomaticResend);
788  expected_.pskType = PskType::Resumption;
789  expected_.earlyDataType = EarlyDataType::Rejected;
790 
791  expectClientSuccess();
792  doClientHandshake();
793  verifyEarlyParameters();
794  clientWrite("early");
795 
796  expectReplaySafety();
797  expectServerRead("early");
798  expectServerSuccess();
799  doServerHandshake();
800  verifyParameters();
801  sendAppData();
802 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataRejectedDontResend   
)

Definition at line 804 of file HandshakeTest.cpp.

References clientContext_, and folly::none.

804  {
805  clientContext_->setSendEarlyData(true);
806  clientContext_->setSupportedAlpns({"h2"});
807  serverContext_->setSupportedAlpns({"h2"});
808  expected_.alpn = "h2";
809  setupResume();
810 
811  serverContext_->setSupportedAlpns({});
812  client_->setEarlyDataRejectionPolicy(
813  EarlyDataRejectionPolicy::AutomaticResend);
814 
815  expectClientSuccess();
816  doClientHandshake();
817  verifyEarlyParameters();
818  clientWrite("early");
819 
820  expected_.earlyDataType = EarlyDataType::Rejected;
821  expected_.alpn = none;
822 
823  expectEarlyDataRejectError();
824  expectServerSuccess();
825  doServerHandshake();
826  verifyParameters();
827 
828  expected_.pskType = PskType::NotAttempted;
829  expected_.pskMode = none;
830  expected_.scheme = SignatureScheme::ecdsa_secp256r1_sha256;
831  expected_.earlyDataType = EarlyDataType::NotAttempted;
832 
833  resetTransports();
834  expectSuccess();
835  doHandshake();
836  verifyParameters();
837  sendAppData();
838 }
std::shared_ptr< FizzClientContext > clientContext_
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataTrickleSendAccepted   
)

Definition at line 840 of file HandshakeTest.cpp.

References clientContext_.

840  {
841  clientContext_->setSendEarlyData(true);
842  setupResume();
843 
844  clientTransport_->setTrickle(true, [this]() { clientWrite("e"); });
845  expected_.pskType = PskType::Resumption;
846  expected_.earlyDataType = EarlyDataType::Accepted;
847 
848  expectClientSuccess();
849  doClientHandshake();
850  verifyEarlyParameters();
851 
852  expectReplaySafety();
853  expectServerSuccess();
854  doServerHandshake();
855  verifyParameters();
856 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
EarlyDataTrickleSendRejected   
)

Definition at line 858 of file HandshakeTest.cpp.

References clientContext_, getCert(), kClientAuthClientCert, and folly::none.

858  {
859  clientContext_->setSendEarlyData(true);
860  setupResume();
861 
862  clientTransport_->setTrickle(true, [this]() { clientWrite("e"); });
863  serverContext_->setClientAuthMode(ClientAuthMode::Required);
864  serverContext_->setTicketCipher(nullptr);
865 
866  expectClientSuccess();
867  doClientHandshake();
868  verifyEarlyParameters();
869 
870  expected_.pskType = PskType::Rejected;
871  expected_.pskMode = none;
872  expected_.earlyDataType = EarlyDataType::Rejected;
873  expected_.scheme = SignatureScheme::ecdsa_secp256r1_sha256;
874  expected_.clientCert = std::make_shared<PeerCertImpl<KeyType::RSA>>(
876 
877  expectEarlyDataRejectError();
878  expectServerSuccess();
879  doServerHandshake();
880  verifyParameters();
881 }
folly::ssl::X509UniquePtr getCert(folly::StringPiece cert)
Definition: TestUtil.cpp:48
constexpr folly::StringPiece kClientAuthClientCert
Definition: TestUtil.h:216
std::shared_ptr< FizzClientContext > clientContext_
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTest  ,
Compat   
)

Definition at line 883 of file HandshakeTest.cpp.

References clientContext_.

883  {
884  clientContext_->setCompatibilityMode(true);
885  expectSuccess();
886  doHandshake();
887  verifyParameters();
888  sendAppData();
889 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCompatHRR   
)

Definition at line 891 of file HandshakeTest.cpp.

References clientContext_.

891  {
892  clientContext_->setCompatibilityMode(true);
893  clientContext_->setDefaultShares({});
894  expected_.clientKexType = expected_.serverKexType =
895  KeyExchangeType::HelloRetryRequest;
896 
897  expectSuccess();
898  doHandshake();
899  verifyParameters();
900  sendAppData();
901 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCompatEarly   
)

Definition at line 903 of file HandshakeTest.cpp.

References clientContext_.

903  {
904  clientContext_->setCompatibilityMode(true);
905  clientContext_->setSendEarlyData(true);
906  setupResume();
907 
908  expected_.pskType = PskType::Resumption;
909  expected_.earlyDataType = EarlyDataType::Accepted;
910 
911  expectClientSuccess();
912  doClientHandshake();
913  verifyEarlyParameters();
914 
915  expectReplaySafety();
916  expectServerSuccess();
917  doServerHandshake();
918  verifyParameters();
919  sendAppData();
920 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCompatEarlyRejected   
)

Definition at line 922 of file HandshakeTest.cpp.

References clientContext_.

922  {
923  clientContext_->setCompatibilityMode(true);
924  clientContext_->setSendEarlyData(true);
925  setupResume();
926 
927  serverContext_->setEarlyDataSettings(false, {}, nullptr);
928  expected_.pskType = PskType::Resumption;
929  expected_.earlyDataType = EarlyDataType::Rejected;
930 
931  expectClientSuccess();
932  doClientHandshake();
933  verifyEarlyParameters();
934  clientWrite("early");
935 
936  expectEarlyDataRejectError();
937  expectServerSuccess();
938  doServerHandshake();
939  verifyParameters();
940 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCompatEarlyRejectedHRR   
)

Definition at line 942 of file HandshakeTest.cpp.

References clientContext_.

942  {
943  clientContext_->setCompatibilityMode(true);
944  clientContext_->setSendEarlyData(true);
945  setupResume();
946 
947  serverContext_->setSupportedGroups({NamedGroup::secp256r1});
948  expected_.pskType = PskType::Resumption;
949  expected_.earlyDataType = EarlyDataType::Rejected;
950  expected_.clientKexType = expected_.serverKexType =
951  KeyExchangeType::HelloRetryRequest;
952  expected_.group = NamedGroup::secp256r1;
953 
954  expectClientSuccess();
955  doClientHandshake();
956  verifyEarlyParameters();
957  clientWrite("early");
958 
959  expectEarlyDataRejectError();
960  expectServerSuccess();
961  doServerHandshake();
962  verifyParameters();
963 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCookie   
)

Definition at line 965 of file HandshakeTest.cpp.

965  {
966  expected_.clientKexType = KeyExchangeType::HelloRetryRequest;
967 
968  expectSuccess();
969  resetTransportsAndDoCookieHandshake();
970  verifyParameters();
971  sendAppData();
972 }
fizz::test::TEST_F ( HandshakeTest  ,
TestCookieGroupNegotiate   
)

Definition at line 974 of file HandshakeTest.cpp.

References clientContext_.

974  {
975  clientContext_->setDefaultShares({});
976  expected_.clientKexType = KeyExchangeType::HelloRetryRequest;
977 
978  expectSuccess();
979  resetTransportsAndDoCookieHandshake();
980  verifyParameters();
981  sendAppData();
982 }
std::shared_ptr< FizzClientContext > clientContext_
fizz::test::TEST_F ( HandshakeTest  ,
TestCookieResume   
)

Definition at line 984 of file HandshakeTest.cpp.

984  {
985  setupResume();
986 
987  expected_.clientKexType = KeyExchangeType::HelloRetryRequest;
988 
989  expectSuccess();
990  resetTransportsAndDoCookieHandshake();
991  verifyParameters();
992  sendAppData();
993 }
fizz::test::TEST_F ( HandshakeTest  ,
TestCookieIncompatiblePsk   
)

Definition at line 995 of file HandshakeTest.cpp.

995  {
996  expectSuccess();
997  doHandshake();
998  verifyParameters();
999 
1000  serverContext_->setSupportedCiphers({{CipherSuite::TLS_AES_256_GCM_SHA384}});
1001  expected_.cipher = CipherSuite::TLS_AES_256_GCM_SHA384;
1002  expected_.clientKexType = KeyExchangeType::HelloRetryRequest;
1003 
1004  expectSuccess();
1005  resetTransportsAndDoCookieHandshake();
1006  verifyParameters();
1007  sendAppData();
1008 }
fizz::test::TEST_F ( HandshakeTest  ,
TestCookiePskKe   
)

Definition at line 1010 of file HandshakeTest.cpp.

References folly::none.

1010  {
1011  serverContext_->setSupportedPskModes({PskKeyExchangeMode::psk_ke});
1012  setupResume();
1013 
1014  expected_.group = none;
1015  expected_.pskMode = PskKeyExchangeMode::psk_ke;
1016  expected_.clientKexType = KeyExchangeType::None;
1017  expected_.serverKexType = KeyExchangeType::None;
1018 
1019  expectSuccess();
1020  resetTransportsAndDoCookieHandshake();
1021  verifyParameters();
1022  sendAppData();
1023 }
constexpr None none
Definition: Optional.h:87
fizz::test::TEST_F ( HandshakeTest  ,
TestBadCookie   
)

Definition at line 1025 of file HandshakeTest.cpp.

References INSTANTIATE_TEST_CASE_P(), and folly::range().

1025  {
1026  expectError("decrypt_error", "could not decrypt cookie");
1027  resetTransportsAndStartCookieHandshake();
1028 
1029  auto cookieSeed = RandomGenerator<32>().generateRandom();
1030  cookieCipher_->setCookieSecrets({{range(cookieSeed)}});
1031 
1032  doServerHandshake();
1033 }
Gen range(Value begin, Value end)
Definition: Base.h:467
fizz::test::TEST_P ( HkdfTest  ,
TestHkdfSha256Expand   
)

Definition at line 31 of file HkdfTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, deadlock::info(), testing::INSTANTIATE_TEST_CASE_P(), and toIOBuf().

31  {
32  auto ikm = toIOBuf(GetParam().ikm);
33  auto salt = toIOBuf(GetParam().salt);
34  auto info = toIOBuf(GetParam().info);
35  size_t outputBytes = GetParam().outputBytes;
36  auto expectedOkm = toIOBuf(GetParam().okm);
37  CHECK_EQ(outputBytes, expectedOkm->length());
38 
39  auto actualOkm = HkdfImpl<Sha256>().hkdf(
40  ikm->coalesce(), salt->coalesce(), *info, outputBytes);
41  EXPECT_FALSE(actualOkm->isChained());
42  EXPECT_EQ(outputBytes, actualOkm->length());
43  EXPECT_FALSE(memcmp(actualOkm->data(), expectedOkm->data(), outputBytes));
44 }
def info()
Definition: deadlock.py:447
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncrypt   
)

Definition at line 129 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), cipher, EXPECT_EQ, and getCipher().

129  {
130  auto cipher = getCipher(GetParam());
131  auto out = callEncrypt(cipher, GetParam());
132  EXPECT_EQ(out->headroom(), 0);
133 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptWithTagRoom   
)

Definition at line 135 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), cipher, EXPECT_FALSE, getCipher(), folly::gen::move, and toIOBuf().

135  {
136  auto cipher = getCipher(GetParam());
137  auto input = toIOBuf(GetParam().plaintext, 0, cipher->getCipherOverhead());
138  auto out = callEncrypt(cipher, GetParam(), std::move(input));
139  EXPECT_FALSE(out->isChained());
140 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptReusedCipher   
)

Definition at line 142 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), cipher, getCipher(), and params.

142  {
143  auto cipher = getCipher(GetParam());
144  auto params = GetParam();
146  callEncrypt(cipher, GetParam());
147 }
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
constexpr Params params[]
std::unique_ptr< Aead > getCipher(const CipherParams &params)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptChunkedInput   
)

Definition at line 149 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, and toIOBuf().

149  {
150  auto cipher = getCipher(GetParam());
151  auto input = toIOBuf(GetParam().plaintext);
152  auto chunkedInput = chunkIOBuf(std::move(input), 3);
153  callEncrypt(cipher, GetParam(), std::move(chunkedInput));
154 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptChunkedInputWithTagRoomHead   
)

Definition at line 156 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), chunkIOBuf(), cipher, folly::IOBuf::create(), EXPECT_GE, getCipher(), folly::gen::move, and toIOBuf().

156  {
157  auto cipher = getCipher(GetParam());
158  auto input = toIOBuf(GetParam().plaintext);
159  auto overhead = cipher->getCipherOverhead();
160  auto creator = [overhead](size_t len, size_t num) {
161  if (num == 0) {
162  // create a buffer w/ room for the tag
163  auto result = IOBuf::create(len + overhead);
164  result->reserve(0, overhead);
165  return result;
166  }
167  return IOBuf::create(len);
168  };
169  auto chunkedInput = chunkIOBuf(std::move(input), 3, creator);
170  auto out = callEncrypt(cipher, GetParam(), std::move(chunkedInput));
171  // even though the head element has tailroom, we don't use it since it's
172  // the last element that needs to have it for copying tag in directly
173  EXPECT_GE(out->tailroom(), overhead);
174 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
#define EXPECT_GE(val1, val2)
Definition: gtest.h:1932
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptChunkedInputWithTagRoomLast   
)

Definition at line 176 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), chunkIOBuf(), chunks, cipher, folly::IOBuf::create(), EXPECT_EQ, getCipher(), folly::gen::move, and toIOBuf().

176  {
177  auto cipher = getCipher(GetParam());
178  auto input = toIOBuf(GetParam().plaintext);
179  auto overhead = cipher->getCipherOverhead();
180  size_t chunks = 3;
181  auto creator = [=](size_t len, size_t num) {
182  if (num == chunks - 1) {
183  // create a buffer w/ room for the tag
184  auto result = IOBuf::create(len + overhead);
185  result->reserve(0, overhead);
186  return result;
187  }
188  return IOBuf::create(len);
189  };
190  auto chunkedInput = chunkIOBuf(std::move(input), chunks, creator);
191  auto lastTailRoom = chunkedInput->prev()->tailroom();
192  auto numElements = chunkedInput->countChainElements();
193  auto out = callEncrypt(cipher, GetParam(), std::move(chunkedInput));
194  // we expect the last element in the chain to have tailroom - overhead
195  // left
196  EXPECT_EQ(out->prev()->tailroom(), lastTailRoom - overhead);
197  EXPECT_EQ(out->countChainElements(), numElements);
198 }
auto chunks
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptChunkedSharedInput   
)

Definition at line 200 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), chunkIOBuf(), cipher, EXPECT_EQ, EXPECT_FALSE, getCipher(), kHeadroom, folly::gen::move, and toIOBuf().

200  {
201  auto cipher = getCipher(GetParam());
202  auto input = toIOBuf(GetParam().plaintext);
203  auto chunkedInput = chunkIOBuf(std::move(input), 3);
204  auto out = callEncrypt(cipher, GetParam(), chunkedInput->clone());
205  // we expect headroom of record size and a single buffer in the
206  // the chain
207  EXPECT_EQ(out->headroom(), kHeadroom);
208  EXPECT_FALSE(out->isChained());
209 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr size_t kHeadroom
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestEncryptChunkedAad   
)

Definition at line 211 of file OpenSSLEVPCipherTest.cpp.

References callEncrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, and toIOBuf().

211  {
212  auto cipher = getCipher(GetParam());
213  auto aad = toIOBuf(GetParam().aad);
214  auto chunkedAad = chunkIOBuf(std::move(aad), 3);
215  callEncrypt(cipher, GetParam(), nullptr, std::move(chunkedAad));
216 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > callEncrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > plaintext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( ECDHTest  ,
TestKeyAgreement   
)

Definition at line 216 of file ECKeyExchangeTest.cpp.

References ASSERT_EQ, ASSERT_TRUE, EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, fizz::detail::OpenSSLECKeyExchange< T >::generateSharedSecret(), getKey(), getNid(), folly::hexlify(), INSTANTIATE_TEST_CASE_P(), folly::gen::move, folly::IOBuf::moveToFbString(), setPoint(), fizz::detail::OpenSSLECKeyExchange< T >::setPrivateKey(), and folly::detail::success.

216  {
217  try {
218  auto privateKey = getKey(GetParam());
219  ASSERT_TRUE(privateKey);
220  // Create the peer key
221  EcKeyUniquePtr peerKey(EC_KEY_new_by_curve_name(getNid(GetParam())));
222  setPoint(peerKey, GetParam().peerX, GetParam().peerY);
223 
224  EvpPkeyUniquePtr pkeyPeerKey(EVP_PKEY_new());
225  ASSERT_EQ(1, EVP_PKEY_set1_EC_KEY(pkeyPeerKey.get(), peerKey.get()));
226  std::unique_ptr<folly::IOBuf> shared;
227  switch (GetParam().key) {
228  case KeyType::P256: {
229  P256KeyExchange kex;
230  kex.setPrivateKey(std::move(privateKey));
231  shared = kex.generateSharedSecret(pkeyPeerKey);
232  break;
233  }
234  case KeyType::P384: {
235  P384KeyExchange kex;
236  kex.setPrivateKey(std::move(privateKey));
237  shared = kex.generateSharedSecret(pkeyPeerKey);
238  break;
239  }
240  case KeyType::P521: {
241  P521KeyExchange kex;
242  kex.setPrivateKey(std::move(privateKey));
243  shared = kex.generateSharedSecret(pkeyPeerKey);
244  break;
245  }
246  default:
247  throw std::runtime_error("unknown key type");
248  }
249 
250  ASSERT_TRUE(shared);
251  auto sharedString = shared->moveToFbString();
252  auto hexShared = hexlify(sharedString);
253  if (GetParam().success) {
254  EXPECT_EQ(GetParam().shared, hexShared);
255  } else {
256  EXPECT_NE(GetParam().shared, hexShared);
257  }
258  } catch (const std::runtime_error& ex) {
259  EXPECT_FALSE(GetParam().success) << ex.what();
260  }
261 }
detail::OpenSSLECKeyExchange< P256 > P256KeyExchange
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fbstring moveToFbString()
Definition: IOBuf.cpp:968
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
int getNid(const Params &param)
detail::OpenSSLECKeyExchange< P384 > P384KeyExchange
TrafficKey getKey()
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
detail::OpenSSLECKeyExchange< P521 > P521KeyExchange
bool hexlify(const InputString &input, OutputString &output, bool append_output)
Definition: String-inl.h:596
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
void setPoint(EcKeyUniquePtr &key, std::string x, std::string y)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecrypt   
)

Definition at line 218 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), cipher, and getCipher().

218  {
219  auto cipher = getCipher(GetParam());
220  callDecrypt(cipher, GetParam());
221 }
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptReusedCipher   
)

Definition at line 223 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), cipher, getCipher(), and params.

223  {
224  auto cipher = getCipher(GetParam());
225  auto params = GetParam();
227  callDecrypt(cipher, GetParam());
228 }
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
constexpr Params params[]
std::unique_ptr< Aead > getCipher(const CipherParams &params)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptInputTooSmall   
)

Definition at line 230 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), cipher, folly::IOBuf::copyBuffer(), getCipher(), and folly::gen::move.

230  {
231  auto cipher = getCipher(GetParam());
232  auto in = IOBuf::copyBuffer("in");
233  auto paramsCopy = GetParam();
234  paramsCopy.valid = false;
235  callDecrypt(cipher, paramsCopy, std::move(in));
236 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
std::unique_ptr< Aead > getCipher(const CipherParams &params)
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptWithChunkedInput   
)

Definition at line 238 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, gmock_output_test::output, and toIOBuf().

238  {
239  auto cipher = getCipher(GetParam());
240  auto output = toIOBuf(GetParam().ciphertext);
241  auto chunkedOutput = chunkIOBuf(std::move(output), 3);
242  callDecrypt(cipher, GetParam(), std::move(chunkedOutput));
243 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptWithChunkedSharedInput   
)

Definition at line 245 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, gmock_output_test::output, and toIOBuf().

245  {
246  auto cipher = getCipher(GetParam());
247  auto output = toIOBuf(GetParam().ciphertext);
248  auto chunkedOutput = chunkIOBuf(std::move(output), 3);
249  callDecrypt(cipher, GetParam(), chunkedOutput->clone());
250 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptWithVeryChunkedInput   
)

Definition at line 252 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, gmock_output_test::output, and toIOBuf().

252  {
253  auto cipher = getCipher(GetParam());
254  auto output = toIOBuf(GetParam().ciphertext);
255  auto chunkedOutput = chunkIOBuf(std::move(output), 30);
256  callDecrypt(cipher, GetParam(), std::move(chunkedOutput));
257 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestDecryptWithChunkedAad   
)

Definition at line 259 of file OpenSSLEVPCipherTest.cpp.

References callDecrypt(), chunkIOBuf(), cipher, getCipher(), folly::gen::move, and toIOBuf().

259  {
260  auto cipher = getCipher(GetParam());
261  auto aad = toIOBuf(GetParam().aad);
262  auto chunkedAad = chunkIOBuf(std::move(aad), 3);
263  callDecrypt(cipher, GetParam(), nullptr, std::move(chunkedAad));
264 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void callDecrypt(std::unique_ptr< Aead > &cipher, const CipherParams &params, std::unique_ptr< IOBuf > ciphertext=nullptr, std::unique_ptr< IOBuf > aad=nullptr)
CipherSuite cipher
std::unique_ptr< Aead > getCipher(const CipherParams &params)
std::unique_ptr< IOBuf > chunkIOBuf(std::unique_ptr< IOBuf > input, size_t chunks, BufCreator creator)
Definition: TestUtil.cpp:31
fizz::test::TEST_P ( OpenSSLEVPCipherTest  ,
TestTryDecrypt   
)

Definition at line 266 of file OpenSSLEVPCipherTest.cpp.

References cipher, EXPECT_FALSE, EXPECT_TRUE, getCipher(), INSTANTIATE_TEST_CASE_P(), and toIOBuf().

266  {
267  auto cipher = getCipher(GetParam());
268  auto out = cipher->tryDecrypt(
269  toIOBuf(GetParam().ciphertext),
270  toIOBuf(GetParam().aad).get(),
271  GetParam().seqNum);
272  if (out) {
273  EXPECT_TRUE(GetParam().valid);
274  EXPECT_TRUE(IOBufEqualTo()(toIOBuf(GetParam().plaintext), *out));
275  } else {
276  EXPECT_FALSE(GetParam().valid);
277  }
278 }
std::unique_ptr< folly::IOBuf > toIOBuf(std::string hexData)
CipherSuite cipher
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::unique_ptr< Aead > getCipher(const CipherParams &params)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fizz::test::TEST_P ( SigSchemeTest  ,
Schemes   
)

Definition at line 652 of file HandshakeTest.cpp.

References clientContext_.

652  {
653  SignatureScheme scheme = GetParam();
654  clientContext_->setSupportedSigSchemes({scheme});
655  serverContext_->setSupportedSigSchemes({scheme});
656  expected_.scheme = scheme;
657 
658  expectSuccess();
659  doHandshake();
660  verifyParameters();
661  sendAppData();
662 }
SignatureScheme
Definition: Types.h:257
std::shared_ptr< FizzClientContext > clientContext_
template<typename A , typename B >
void fizz::test::throwIfNeq ( const A a,
const B b,
const std::string msg 
)

Definition at line 22 of file Utilities.h.

Referenced by createCert().

22  {
23  if (a != b) {
24  throw std::runtime_error(msg);
25  }
26 }
char b
char a
template<typename A >
void fizz::test::throwIfNull ( const A a,
const std::string msg 
)

Definition at line 29 of file Utilities.h.

Referenced by createCert().

29  {
30  if (a == nullptr) {
31  throw std::runtime_error(msg);
32  }
33 }
char a
std::unique_ptr< folly::IOBuf > fizz::test::toIOBuf ( std::string  hexData,
size_t  headroom,
size_t  tailroom 
)

Definition at line 24 of file TestUtil.cpp.

References folly::IOBuf::copyBuffer(), string, and folly::unhexlify().

Referenced by fizz::server::test::AeadTicketCipherTest::setTicketSecrets(), fizz::server::test::AeadCookieCipherTest::SetUp(), fizz::server::test::TEST(), and fizz::server::test::TEST_F().

24  {
25  std::string out;
26  CHECK(folly::unhexlify(hexData, out));
27  return folly::IOBuf::copyBuffer(out, headroom, tailroom);
28 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
const char * string
Definition: Conv.cpp:212
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
std::unique_ptr< folly::IOBuf > fizz::test::toIOBuf ( folly::StringPiece  hexData)

Definition at line 42 of file TestUtil.cpp.

References folly::IOBuf::copyBuffer(), string, and folly::unhexlify().

42  {
43  std::string out;
44  CHECK(folly::unhexlify(hexData, out));
45  return folly::IOBuf::copyBuffer(out);
46 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
const char * string
Definition: Conv.cpp:212
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
fizz::test::TYPED_TEST ( Key  ,
GenerateKey   
)

Definition at line 109 of file ECKeyExchangeTest.cpp.

109  {
110  typename TestFixture::KeyExch kex;
111  kex.generateKeyPair();
112 }
fizz::test::TYPED_TEST ( Key  ,
SharedSecret   
)

Definition at line 114 of file ECKeyExchangeTest.cpp.

References EXPECT_TRUE.

114  {
115  typename TestFixture::KeyExch kex;
116  kex.generateKeyPair();
117  auto shared = kex.generateSharedSecret(kex.getKey());
118  EXPECT_TRUE(shared);
119 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TYPED_TEST ( Key  ,
ReadFromKey   
)

Definition at line 121 of file ECKeyExchangeTest.cpp.

References EXPECT_TRUE, getPrivateKey(), and folly::gen::move.

121  {
122  typename TestFixture::KeyExch kex;
123  auto pkey = getPrivateKey(this->getKeyParams().privateKey);
124  kex.setPrivateKey(std::move(pkey));
125 
126  auto pkey2 = getPrivateKey(this->getKeyParams().privateKey);
127  typename TestFixture::KeyExch kex2;
128  kex2.setPrivateKey(std::move(pkey2));
129  auto shared = kex.generateSharedSecret(kex2.getKey());
130  EXPECT_TRUE(shared);
131 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
fizz::test::TYPED_TEST ( Key  ,
ReadWrongGroup   
)

Definition at line 133 of file ECKeyExchangeTest.cpp.

References EXPECT_THROW, getPrivateKey(), and folly::gen::move.

133  {
134  auto pkey = getPrivateKey(this->getKeyParams().invalidPrivateKey);
135  typename TestFixture::KeyExch kex;
136  EXPECT_THROW(kex.setPrivateKey(std::move(pkey)), std::runtime_error);
137 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
fizz::test::TYPED_TEST ( Key  ,
Decode   
)

Definition at line 139 of file ECKeyExchangeTest.cpp.

References fizz::decode(), EXPECT_TRUE, folly::range(), string, and folly::unhexlify().

139  {
140  std::string out = unhexlify(this->getKeyParams().encodedShare);
142  EXPECT_TRUE(pub);
143 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
Gen range(Value begin, Value end)
Definition: Base.h:467
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
fizz::test::TYPED_TEST ( Key  ,
Encode   
)

Definition at line 145 of file ECKeyExchangeTest.cpp.

References fizz::decode(), encode(), EXPECT_EQ, EXPECT_TRUE, folly::range(), string, and folly::unhexlify().

145  {
146  std::string out = unhexlify(this->getKeyParams().encodedShare);
148  EXPECT_TRUE(pub);
149  auto encoded = detail::OpenSSLECKeyEncoder::encode(pub);
150 
151  auto encodedStr = encoded->moveToFbString();
152  EXPECT_EQ(encodedStr, out);
153 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
Gen range(Value begin, Value end)
Definition: Base.h:467
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
fizz::test::TYPED_TEST ( Key  ,
DecodeInvalid   
)

Definition at line 155 of file ECKeyExchangeTest.cpp.

References EXPECT_THROW, folly::range(), string, and folly::unhexlify().

155  {
156  std::string out = unhexlify(this->getKeyParams().invalidEncodedShare);
157  EXPECT_THROW(
159  std::runtime_error);
160 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
Gen range(Value begin, Value end)
Definition: Base.h:467
const char * string
Definition: Conv.cpp:212
fizz::test::TYPED_TEST ( Key  ,
DecodeInvalidSmallLength   
)

Definition at line 162 of file ECKeyExchangeTest.cpp.

References EXPECT_THROW, folly::range(), string, and folly::unhexlify().

162  {
163  std::string out = unhexlify(this->getKeyParams().tooSmallEncodedShare);
164  EXPECT_THROW(
166  std::runtime_error);
167 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
Gen range(Value begin, Value end)
Definition: Base.h:467
const char * string
Definition: Conv.cpp:212
fizz::test::TYPED_TEST ( CertTestTyped  ,
MatchingCert   
)

Definition at line 187 of file CertTest.cpp.

References fizz::certificate, and folly::gen::move.

187  {
188  std::vector<folly::ssl::X509UniquePtr> certs;
189  certs.push_back(getCert<TypeParam>());
190  SelfCertImpl<TypeParam::Type> certificate(
191  getKey<TypeParam>(), std::move(certs));
192 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TYPED_TEST ( CertTestTyped  ,
MismatchedCert   
)

Definition at line 194 of file CertTest.cpp.

References fizz::certificate, EXPECT_THROW, and folly::gen::move.

194  {
195  std::vector<folly::ssl::X509UniquePtr> certs;
196  certs.push_back(getCert<TypeParam>());
197  EXPECT_THROW(
198  SelfCertImpl<TypeParam::Type> certificate(
199  getKey<typename TypeParam::Invalid>(), std::move(certs)),
200  std::runtime_error);
201 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TYPED_TEST ( CertTestTyped  ,
SigSchemes   
)

Definition at line 203 of file CertTest.cpp.

References fizz::certificate, EXPECT_EQ, fizz::SelfCertImpl< T >::getSigSchemes(), and folly::gen::move.

203  {
204  std::vector<folly::ssl::X509UniquePtr> certs;
205  certs.push_back(getCert<TypeParam>());
206  SelfCertImpl<TypeParam::Type> certificate(
207  getKey<TypeParam>(), std::move(certs));
208 
209  std::vector<SignatureScheme> expected{TypeParam::Scheme};
210  EXPECT_EQ(certificate.getSigSchemes(), expected);
211 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
fizz::test::TYPED_TEST ( CertTestTyped  ,
TestSignVerify   
)

Definition at line 213 of file CertTest.cpp.

References folly::gen::move, folly::sig, fizz::SelfCertImpl< T >::sign(), and fizz::PeerCertImpl< T >::verify().

213  {
214  PeerCertImpl<TypeParam::Type> peerCert(getCert<TypeParam>());
215  std::vector<folly::ssl::X509UniquePtr> certs;
216  certs.push_back(getCert<TypeParam>());
217  SelfCertImpl<TypeParam::Type> selfCert(getKey<TypeParam>(), std::move(certs));
218 
219  StringPiece tbs{"ToBeSigned"};
220  auto sig =
221  selfCert.sign(TypeParam::Scheme, CertificateVerifyContext::Server, tbs);
222  peerCert.verify(
223  TypeParam::Scheme,
224  CertificateVerifyContext::Server,
225  tbs,
226  sig->coalesce());
227 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
fizz::test::TYPED_TEST ( CertTestTyped  ,
TestSignVerifyBitFlip   
)

Definition at line 229 of file CertTest.cpp.

References EXPECT_THROW, folly::gen::move, folly::sig, fizz::SelfCertImpl< T >::sign(), and fizz::PeerCertImpl< T >::verify().

229  {
230  PeerCertImpl<TypeParam::Type> peerCert(getCert<TypeParam>());
231  std::vector<folly::ssl::X509UniquePtr> certs;
232  certs.push_back(getCert<TypeParam>());
233  SelfCertImpl<TypeParam::Type> selfCert(getKey<TypeParam>(), std::move(certs));
234 
235  StringPiece tbs{"ToBeSigned"};
236  auto sig =
237  selfCert.sign(TypeParam::Scheme, CertificateVerifyContext::Server, tbs);
238  sig->writableData()[1] ^= 0x20;
239  EXPECT_THROW(
240  peerCert.verify(
241  TypeParam::Scheme,
242  CertificateVerifyContext::Server,
243  tbs,
244  sig->coalesce()),
245  std::runtime_error);
246 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
fizz::test::TYPED_TEST ( CertTestTyped  ,
TestSignVerifyWrongSize   
)

Definition at line 248 of file CertTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_THROW, folly::gen::move, folly::sig, fizz::SelfCertImpl< T >::sign(), and fizz::PeerCertImpl< T >::verify().

248  {
249  PeerCertImpl<TypeParam::Type> peerCert(getCert<TypeParam>());
250  std::vector<folly::ssl::X509UniquePtr> certs;
251  certs.push_back(getCert<TypeParam>());
252  SelfCertImpl<TypeParam::Type> selfCert(getKey<TypeParam>(), std::move(certs));
253 
254  StringPiece tbs{"ToBeSigned"};
255  auto sig =
256  selfCert.sign(TypeParam::Scheme, CertificateVerifyContext::Server, tbs);
257  sig->prependChain(IOBuf::copyBuffer("x"));
258  EXPECT_THROW(
259  peerCert.verify(
260  TypeParam::Scheme,
261  CertificateVerifyContext::Server,
262  tbs,
263  sig->coalesce()),
264  std::runtime_error);
265 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
fizz::test::TYPED_TEST ( CertTestTyped  ,
TestVerifyWrongScheme   
)

Definition at line 267 of file CertTest.cpp.

References EXPECT_THROW, folly::gen::move, folly::sig, fizz::SelfCertImpl< T >::sign(), and fizz::PeerCertImpl< T >::verify().

267  {
268  PeerCertImpl<TypeParam::Type> peerCert(getCert<TypeParam>());
269  std::vector<folly::ssl::X509UniquePtr> certs;
270  certs.push_back(getCert<TypeParam>());
271  SelfCertImpl<TypeParam::Type> selfCert(getKey<TypeParam>(), std::move(certs));
272 
273  StringPiece tbs{"ToBeSigned"};
274  auto sig =
275  selfCert.sign(TypeParam::Scheme, CertificateVerifyContext::Server, tbs);
276  EXPECT_THROW(
277  peerCert.verify(
278  TypeParam::Invalid::Scheme,
279  CertificateVerifyContext::Server,
280  tbs,
281  sig->coalesce()),
282  std::runtime_error);
283 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
fizz::test::TYPED_TEST ( CertTestTyped  ,
TestVerifyDecodedCert   
)

Definition at line 285 of file CertTest.cpp.

References folly::gen::move, folly::sig, and fizz::SelfCertImpl< T >::sign().

285  {
286  std::vector<folly::ssl::X509UniquePtr> certs;
287  certs.push_back(getCert<TypeParam>());
288  auto msg = CertUtils::getCertMessage(certs, nullptr);
289  SelfCertImpl<TypeParam::Type> selfCert(getKey<TypeParam>(), std::move(certs));
290 
291  auto peerCert = CertUtils::makePeerCert(
292  std::move(msg.certificate_list.front().cert_data));
293 
294  StringPiece tbs{"ToBeSigned"};
295  auto sig =
296  selfCert.sign(TypeParam::Scheme, CertificateVerifyContext::Server, tbs);
297  peerCert->verify(
298  TypeParam::Scheme,
299  CertificateVerifyContext::Server,
300  tbs,
301  sig->coalesce());
302 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr detail::Sig< Sig > const sig
Definition: Poly.h:1165
fizz::test::TYPED_TEST_CASE ( Key  ,
KeyTypes   
)
fizz::test::TYPED_TEST_CASE ( CertTestTyped  ,
KeyTypes   
)
void fizz::test::useMockRandom ( )

Definition at line 69 of file TestUtil.cpp.

Referenced by TEST(), and fizz::server::test::TEST_F().

69  {
70  randombytes_set_implementation(&mockRandom);
71 }
static struct randombytes_implementation mockRandom
Definition: TestUtil.cpp:61
static WriteNewSessionTicket fizz::test::writeNewSessionTicket ( const std::string str)
static

Definition at line 24 of file FizzBaseTest.cpp.

References fizz::WriteNewSessionTicket::appToken, folly::IOBuf::copyBuffer(), and fizz::detail::write().

Referenced by TEST_F(), and fizz::server::test::TEST_F().

24  {
26  write.appToken = IOBuf::copyBuffer(str);
27  return write;
28 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)

Variable Documentation

StringPiece fizz::test::basic_expected_ekm
Initial value:
= {
"55549d2d280d8507823a80c2ee69530e5dcc6a04e86f1bae1ef23a86337341a8"}

Definition at line 21 of file ExporterTest.cpp.

const std::string fizz::test::exampleCompressedCertificate
static

Definition at line 23 of file ZlibCertificateCompressorTest.cpp.

Referenced by TEST_F().

StringPiece fizz::test::expected_auth_request
Initial value:
= {
"14303132333435363738396162636465666768696a000a000d0006000404030804"}

Definition at line 29 of file ExportedAuthenticatorTest.cpp.

StringPiece fizz::test::expected_authenticator
Initial value:
= {
"0b000004000000000f00000d040300097369676e617475726514000020b523548c421b05f7f3c33276fbdd5266ba2df103796d7d483368259860a648f2"}

Definition at line 31 of file ExportedAuthenticatorTest.cpp.

StringPiece fizz::test::expected_cert
Initial value:
= {
"308201ee30820195a003020102020900c569eec901ce86d9300a06082a8648ce3d0403023054310b3009060355040613025553310b300906035504080c024e59310b300906035504070c024e59310d300b060355040a0c0446697a7a310d300b060355040b0c0446697a7a310d300b06035504030c0446697a7a301e170d3137303430343138323930395a170d3431313132343138323930395a3054310b3009060355040613025553310b300906035504080c024e59310b300906035504070c024e59310d300b060355040a0c0446697a7a310d300b060355040b0c0446697a7a310d300b06035504030c0446697a7a3059301306072a8648ce3d020106082a8648ce3d030107034200049d87bcaddb65d8dcf6df8b148a9679b5b710db19c95a9badfff13468cb358b4e21d24a5c826112658ebb96d64e2985dfb41c1948334391a4aa81b67837e2dbf0a350304e301d0603551d0e041604143c5b8ba954d9752faf3c8ad6d1a62449dccaa850301f0603551d230418301680143c5b8ba954d9752faf3c8ad6d1a62449dccaa850300c0603551d13040530030101ff300a06082a8648ce3d04030203470030440220349b7d34d7132fb2756576e0bfa36cbe1723337a7a6f5ef9c8d3bf1aa7efa4a5022025c50a91e0aa4272f1f52c3d5583a7d7cee14b178835273a0bd814303e62d714"}

Definition at line 34 of file ExportedAuthenticatorTest.cpp.

StringPiece fizz::test::expected_cr_context = {"303132333435363738396162636465666768696a"}

Definition at line 33 of file ExportedAuthenticatorTest.cpp.

StringPiece fizz::test::expected_empty_authenticator
Initial value:
= {
"1400002011fae4bcdf4673b6dfb276d886c4cd1c5b0920da961643f062d1d4a6062115b1"}

Definition at line 36 of file ExportedAuthenticatorTest.cpp.

StringPiece fizz::test::exporter_master = {"12345678901234567890123456789012"}

Definition at line 19 of file ExporterTest.cpp.

constexpr folly::StringPiece fizz::test::kClientAuthCACert

Definition at line 183 of file TestUtil.h.

Referenced by fizz::test::HandshakeTest::SetUp().

constexpr folly::StringPiece fizz::test::kClientAuthClientCert
Initial value:
= R"(
-----BEGIN CERTIFICATE-----
MIIErzCCApegAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwGjELMAkGA1UEBhMCVVMx
CzAJBgNVBAgMAkNBMCAXDTE3MDkwMTIxMDU1MloYDzIxMTcwODA4MjEwNTUyWjBj
MQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAsMBEZpenoxFDASBgNV
BAMMC0ZpenogQ2xpZW50MSIwIAYJKoZIhvcNAQkBFhNmaXp6Y2xpZW50QGZpenou
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzU4RuUU3QjX9rMeC
aVYPX1G8ITkGkvRW1Fbo5P9Irmw/uOeXnTKFtJ3h+r+omA607aqymHfjk1uDtxwH
2GI1VEIYce1u+qYSiLdfWUOQ1za5abeGhT/PJSONVg02maaMZmxSi5L7f/9x5B5B
fIecgurN+7W381ENyp06akg3CSAtNITL1+Au8wOh4woAJ1qKcgrhHeSG5qOqe2cw
vkcfy1Pahmp5sQtebI+1VaLXSW2XS4i/59oM7jfWAs2ZZW2EYrT3z0q3bEiL9OVz
Qjumv5fi9kJR7Pol/Q3p0MD4/8TPA6eEFf9FYPoguF6f2RKvN7uqCjIhH9r679Na
UBQcZQIDAQABo4GzMIGwMAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgWgMCEG
CWCGSAGG+EIBDQQUFhJDbGllbnQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFE/TN4DI
NrYzGanBqw9MD+gmmkkDMB8GA1UdIwQYMBaAFB8apflC6AhWupoL10Q0yzKxfl4Z
MA4GA1UdDwEB/wQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQw
DQYJKoZIhvcNAQELBQADggIBAHBGcdKXTFQoZOWdt/XR3B3tLJDPoo9anFc+w+/C
tNMUCOT1/ILdDtjkXQ9+U6czkgOQbcUzUkUF9sfPJ2aBf95azvU51xXH19CPyLc2
H59CHdUUGD1CiJ8H/EH1kjb6sBIX17OvYYYj47qT1us2ZM45w86zhLZkmDkIcdMy
A9ZhNtQDk/oWGE1Q6YV2CT78RSNke8RqNe7XrDIJh9ZOGyfYqXuDsdGE8md0nCAC
kqWje0HeHkWTJTkdNLSp6DNpXmMyUg8wjcOvj3dTNOEtqqTAHx8wzL9YlCsUTLot
HGXpVhMv2X+GMKQsXTBVUVrWaFj6x4owXmRK8le315AgpsIGhTqFlGLpbs7dCm6T
upufJ6ZoY4gLxcwPD691PQznjqC45j4Zi+KxY8ptsIVJbcK9kbcBIb/T7HnQHCOI
vTUQFPPhST0fRhpsiOGaJxPOn6Ht8lSf3A1vS+TfD4E5cyojZzXe2H7ao3sCB4a4
X8tTiQTUHQVFNQqiPsErBOX1ybr1uwRFcX+uIwiVtcxRi5otMZNIFpulvmwb517R
NprWAWb0X4RYqPoTNW/OGk421nI0Bc5Rhi4+6RO93BrkPY0HHDnge7LB5A7WynbG
8gdVGTDuTniJ7Z4xIz6/YMxEM8F+BCQzq1f/2dnlSfEgIk2AdsW1verYIfc6xwqr
V1Xd
-----END CERTIFICATE-----
)"

Definition at line 216 of file TestUtil.h.

Referenced by fizz::test::HandshakeTest::SetUp(), and TEST_F().

constexpr folly::StringPiece fizz::test::kClientAuthClientKey
Initial value:
= R"(
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAzU4RuUU3QjX9rMeCaVYPX1G8ITkGkvRW1Fbo5P9Irmw/uOeX
nTKFtJ3h+r+omA607aqymHfjk1uDtxwH2GI1VEIYce1u+qYSiLdfWUOQ1za5abeG
hT/PJSONVg02maaMZmxSi5L7f/9x5B5BfIecgurN+7W381ENyp06akg3CSAtNITL
1+Au8wOh4woAJ1qKcgrhHeSG5qOqe2cwvkcfy1Pahmp5sQtebI+1VaLXSW2XS4i/
59oM7jfWAs2ZZW2EYrT3z0q3bEiL9OVzQjumv5fi9kJR7Pol/Q3p0MD4/8TPA6eE
Ff9FYPoguF6f2RKvN7uqCjIhH9r679NaUBQcZQIDAQABAoIBABJURPrQdiWAIny5
dygmWcr9xhkFOVQHYnUkqThAnmGMIohEjOGo8Az3B4TWdZvVvEt3sOgx0+yFABZp
9z1XT0GNgRcyxnS0PPVdwbJ7eMPuC9GnY+gjkT/Uk7q6BUTkfKZsR1ZUsgV0bdua
4+fVR6Dci7VMPPcJJn0PWnbAqcEzqBUI3+HqUpx1LACqbMYtlTpFxHO811ycbTkB
SJMlEvzH5Ry5gptJur7kepyA4o6hz9C/KPjuCcjXUwjGDggqQJkj6ulUdQIZek8R
9ckeHETrQiuSnUngJbgG83kHVGISdX9kgqVfo+t2cIsEGO9KJOQ4HNL9iXvh+Coj
Hsc1ZKECgYEA/Ian9dD27mkgYz5z1oO4R2t0Hjr18tI5WUd4Smc6sDAX0xjBsVui
sBm0apE+QvgHrD+JWxrBDTB1SZmfgd9OjjCveILo8eUTk91jYgOov9+GLpL+k2rY
dsBdsLu+x9+w6d+N+ySVRJU4MfweEYrah13IV+nr+gLd7/uxpsP2owkCgYEA0CEc
SCUBHkoa4O4/jkn3yBXnGq1SSaLA9LCQXhLlfWUd7nZAX3dNjXAS7JE5QtOt1C7p
7Fg7fS/dEYD6VyGmscq9yJL7xKD0zx1nKlr5ZhCGTZM6QXvmSRDRf06Ne+z7Gxhf
oDmM8vclHu5z7J7aYnb7BPwTBz4W/IKqyKptuX0CgYEAvEBGBeJ5stF764ArKseX
IObh8YdSwmolhoDZE95QyfeQSzYxbt45Mb532Nnd6F6umaHj657OO97cELoNRuwJ
y8ZPiS9OKMX1Ck4IQJEpw6AGj8HVNmB4bk6Jia7sUmRXpoGZfpePD0mOUvT4FWvF
7RPkvmUMHZz1hmnDzeZYfsECgYBFrD/eetzD+gTDdZ47ENHs3kAuMwVP9zbm8tBx
XZwLfTUm5dko3DRO+8yp+veTQm93j3jpkKPhhYtY17d2QaKe9ALSSToVGdi6GNq3
WBsTKsb64yVmVIbDwOiQ2IgOi0eIS4F/jqR7lXaMw0B1Xrw2qCPiCEyKaSOixk9L
u5ndtQKBgQC0CLFhehVr4AOx65l9VGNW9lx8XlUXTMaElv6DKqQhTOGIe48pzHkQ
VxjmpoOD8HC2xqb+HfofiwVTR5Q1khz/BqcjdrT8TRxFD4bKjVePOxyrIcTiGJzx
V0495bcyl/ghl1VyoKOzjcc1pMQCLUaj4MmbSmW0A9wxP1eVPTOhEg==
-----END RSA PRIVATE KEY-----
)"

Definition at line 247 of file TestUtil.h.

Referenced by fizz::test::HandshakeTest::SetUp().

constexpr size_t fizz::test::kHeadroom = 10

Definition at line 38 of file OpenSSLEVPCipherTest.cpp.

Referenced by TEST_P().

constexpr folly::StringPiece fizz::test::kP256Certificate
Initial value:
= R"(
-----BEGIN CERTIFICATE-----
MIIB7jCCAZWgAwIBAgIJAMVp7skBzobZMAoGCCqGSM49BAMCMFQxCzAJBgNVBAYT
AlVTMQswCQYDVQQIDAJOWTELMAkGA1UEBwwCTlkxDTALBgNVBAoMBEZpenoxDTAL
BgNVBAsMBEZpenoxDTALBgNVBAMMBEZpenowHhcNMTcwNDA0MTgyOTA5WhcNNDEx
MTI0MTgyOTA5WjBUMQswCQYDVQQGEwJVUzELMAkGA1UECAwCTlkxCzAJBgNVBAcM
Ak5ZMQ0wCwYDVQQKDARGaXp6MQ0wCwYDVQQLDARGaXp6MQ0wCwYDVQQDDARGaXp6
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnYe8rdtl2Nz234sUipZ5tbcQ2xnJ
Wput//E0aMs1i04h0kpcgmESZY67ltZOKYXftBwZSDNDkaSqgbZ4N+Lb8KNQME4w
HQYDVR0OBBYEFDxbi6lU2XUvrzyK1tGmJEncyqhQMB8GA1UdIwQYMBaAFDxbi6lU
2XUvrzyK1tGmJEncyqhQMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIg
NJt9NNcTL7J1ZXbgv6NsvhcjM3p6b175yNO/GqfvpKUCICXFCpHgqkJy8fUsPVWD
p9fO4UsXiDUnOgvYFDA+YtcU
-----END CERTIFICATE-----
)"

Definition at line 41 of file TestUtil.h.

Referenced by getCert< P256Test >(), fizz::test::HandshakeTest::SetUp(), TEST(), TEST(), and TEST_F().

constexpr folly::StringPiece fizz::test::kP256K1Key
Initial value:
= R"(
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIO/faBJKYzuLCTg58AIyWbeu2c6VVuPToCrINFj4y8wToAcGBSuBBAAK
oUQDQgAEW5bWEQR9xaAT0Zaev8QmA/lzz1a9+z1cphweKH8ynBYmWiWivaqGcVAU
Lt/SKc3HlcKGQhblkaGHEt3pCQeZUA==
-----END EC PRIVATE KEY-----
)"

Definition at line 33 of file TestUtil.h.

Referenced by fizz::test::Key< T >::getKeyParams().

constexpr folly::StringPiece fizz::test::kP256Key
Initial value:
= R"(
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIHMPeLV/nP/gkcgU2weiXl198mEX8RbFjPRoXuGcpxMXoAoGCCqGSM49
AwEHoUQDQgAEnYe8rdtl2Nz234sUipZ5tbcQ2xnJWput//E0aMs1i04h0kpcgmES
ZY67ltZOKYXftBwZSDNDkaSqgbZ4N+Lb8A==
-----END EC PRIVATE KEY-----
)"

Definition at line 18 of file TestUtil.h.

Referenced by getKey< P256Test >(), fizz::test::Key< T >::getKeyParams(), fizz::test::HandshakeTest::SetUp(), TEST(), TEST(), and TEST_F().

constexpr folly::StringPiece fizz::test::kP256PublicKey
Initial value:
= R"(
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnYe8rdtl2Nz234sUipZ5tbcQ2xnJ
Wput//E0aMs1i04h0kpcgmESZY67ltZOKYXftBwZSDNDkaSqgbZ4N+Lb8A==
-----END PUBLIC KEY-----
)"

Definition at line 26 of file TestUtil.h.

Referenced by TEST().

constexpr folly::StringPiece fizz::test::kP384Certificate
Initial value:
= R"(
-----BEGIN CERTIFICATE-----
MIICJzCCAaygAwIBAgIJAOzjkDsjaGgLMAoGCCqGSM49BAMCMFExCzAJBgNVBAYT
AlVTMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQgQ29t
cGFueSBMdGQxDTALBgNVBAMMBGZpenowHhcNMTgwNzI3MjIwNTE2WhcNMTgwODI2
MjIwNTE2WjBRMQswCQYDVQQGEwJVUzEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRww
GgYDVQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMQ0wCwYDVQQDDARmaXp6MHYwEAYH
KoZIzj0CAQYFK4EEACIDYgAEgRBBliu6yYWesqoZpHUuVzlJ0/HriryxMcFnTnUG
H14XtqJHJO63Mmjtgv09K/yT24jKu/jJ2p5MFHn/25pUtSKZCu9AHBqwBKof3w4m
qoaSylhgrW9s+Oo7uV2+y4Kjo1AwTjAdBgNVHQ4EFgQUn8WNTodJ81ytFl+3BWKI
I9X784wwHwYDVR0jBBgwFoAUn8WNTodJ81ytFl+3BWKII9X784wwDAYDVR0TBAUw
AwEB/zAKBggqhkjOPQQDAgNpADBmAjEA6S4jXP5fruwrmszizG854snSHl5LVEuQ
8F6RIEsOnWSbKBBoteaSXwA6Tv+jYZnmAjEA8YU0LnO+eA75Aku0mPDQsVJOjCvX
OMc6lsBbEEu0yLF89FcMYbxH2JCRxa528qd+
-----END CERTIFICATE-----
)"

Definition at line 74 of file TestUtil.h.

Referenced by getCert< P384Test >(), and fizz::test::HandshakeTest::SetUp().

constexpr folly::StringPiece fizz::test::kP384Key
Initial value:
= R"(
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDCq2Al9+ZmWvvKXeKF4x+P0D3BvbFD9uxxgixjp2pVrGiQeybNLsmgz
aCjz+ETbBEKgBwYFK4EEACKhZANiAASBEEGWK7rJhZ6yqhmkdS5XOUnT8euKvLEx
wWdOdQYfXhe2okck7rcyaO2C/T0r/JPbiMq7+MnankwUef/bmlS1IpkK70AcGrAE
qh/fDiaqhpLKWGCtb2z46ju5Xb7LgqM=
-----END EC PRIVATE KEY-----
)"

Definition at line 57 of file TestUtil.h.

Referenced by getKey< P384Test >(), fizz::test::Key< T >::getKeyParams(), fizz::test::HandshakeTest::SetUp(), and TEST().

constexpr folly::StringPiece fizz::test::kP384PublicKey
Initial value:
= R"(
-----BEGIN PUBLIC KEY-----
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEgRBBliu6yYWesqoZpHUuVzlJ0/Hriryx
McFnTnUGH14XtqJHJO63Mmjtgv09K/yT24jKu/jJ2p5MFHn/25pUtSKZCu9AHBqw
BKof3w4mqoaSylhgrW9s+Oo7uV2+y4Kj
-----END PUBLIC KEY-----
)"

Definition at line 66 of file TestUtil.h.

constexpr folly::StringPiece fizz::test::kP521Certificate
Initial value:
= R"(
-----BEGIN CERTIFICATE-----
MIICcTCCAdKgAwIBAgIJAMaW6GnzHQdaMAoGCCqGSM49BAMCMFExCzAJBgNVBAYT
AlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQgQ29t
cGFueSBMdGQxDTALBgNVBAMMBGZpenowHhcNMTgwNzI3MjIwNjI2WhcNMTgwODI2
MjIwNjI2WjBRMQswCQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRww
GgYDVQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMQ0wCwYDVQQDDARmaXp6MIGbMBAG
ByqGSM49AgEGBSuBBAAjA4GGAAQBp21bDEL1V+QYv5grNW6QP5N7nVMMyoJQ4HyY
ygMpOViy+o2iD5xOn3aE3z6HK0cNrFNoaXtmTOTGdz/riGJwe18BQ0GC65YqOqin
B8hoyqbt7mLdhFYXLvC9c4+sOrsE6HvT6eqcG9CfhyCplMYWLLQlRvhuMo3pMDh+
jswsaOxBvPKjUDBOMB0GA1UdDgQWBBRqn91E64NUNowqgdlYhJCerng6bTAfBgNV
HSMEGDAWgBRqn91E64NUNowqgdlYhJCerng6bTAMBgNVHRMEBTADAQH/MAoGCCqG
SM49BAMCA4GMADCBiAJCAaCZdl3sxO15gKzpODf/y591WTtaXWEz5MdlHP2y3m1X
4ae1xJMdmB6Qw5/bYHAus9GCwLx37WxaMxYcSG2mfIaGAkIBnIE2i1fX3LZCfkKx
SR7JD8cautCXMGtmivUW8TItC72Gt8DWD1hVfR9OnjnuKFotlVZ1FF/HbG2Hwa4/
Skcvpq0=
-----END CERTIFICATE-----
)"

Definition at line 110 of file TestUtil.h.

Referenced by getCert< P521Test >(), and fizz::test::HandshakeTest::SetUp().

constexpr folly::StringPiece fizz::test::kP521Key
Initial value:
= R"(
-----BEGIN EC PRIVATE KEY-----
MIHcAgEBBEIBPYFDNkfM6VuyQKVaQigvLTeKXcPWr4qMLHtN4V81QZLIE9HJvL29
hbqwRG/kw2XM8ZQSnsqd1XTevQSfEPK45+CgBwYFK4EEACOhgYkDgYYABAGnbVsM
QvVX5Bi/mCs1bpA/k3udUwzKglDgfJjKAyk5WLL6jaIPnE6fdoTfPocrRw2sU2hp
e2ZM5MZ3P+uIYnB7XwFDQYLrlio6qKcHyGjKpu3uYt2EVhcu8L1zj6w6uwToe9Pp
6pwb0J+HIKmUxhYstCVG+G4yjekwOH6OzCxo7EG88g==
-----END EC PRIVATE KEY-----
)"

Definition at line 91 of file TestUtil.h.

Referenced by getKey< P521Test >(), fizz::test::Key< T >::getKeyParams(), and fizz::test::HandshakeTest::SetUp().

constexpr folly::StringPiece fizz::test::kP521PublicKey
Initial value:
= R"(
-----BEGIN PUBLIC KEY-----
MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBp21bDEL1V+QYv5grNW6QP5N7nVMM
yoJQ4HyYygMpOViy+o2iD5xOn3aE3z6HK0cNrFNoaXtmTOTGdz/riGJwe18BQ0GC
65YqOqinB8hoyqbt7mLdhFYXLvC9c4+sOrsE6HvT6eqcG9CfhyCplMYWLLQlRvhu
Mo3pMDh+jswsaOxBvPI=
-----END PUBLIC KEY-----
)"

Definition at line 101 of file TestUtil.h.

constexpr folly::StringPiece fizz::test::kRSACertificate
Initial value:
= R"(
-----BEGIN CERTIFICATE-----
MIIDYTCCAkmgAwIBAgIJAMNCCDasHKJvMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV
BAYTAlVTMQswCQYDVQQIDAJOWTERMA8GA1UEBwwITmV3IFlvcmsxDTALBgNVBAsM
BEZpenoxDTALBgNVBAMMBEZpenowHhcNMTYxMjI5MDYyNDE4WhcNNDEwODIwMDYy
NDE4WjBLMQswCQYDVQQGEwJVUzELMAkGA1UECAwCTlkxETAPBgNVBAcMCE5ldyBZ
b3JrMQ0wCwYDVQQLDARGaXp6MQ0wCwYDVQQDDARGaXp6MIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEAxWSZkGZoflV+hnNKZVuCUr0eOedYtFIEU16mARPP
3KPqHFrcEXudA5/46hoogfSb2WYqEaCeltY3GiPG+WPdhhDEi5h4hImvL+g/iTU7
LLmIhmkx4hKzAYx012012Hxy7pvEJJy6S7wEcJj0AxNsWFo8SysIfO5Rw57CTHol
xwcbuCsfq6Cca3PE0gc9UXZ2KaTJNuph8gWPDdio8Au5YnYpvIYy0QXt6eUFAH8h
uNRBOUK+XHng+/zAIXQAtGJEW/rx/vKDUWm0nzZKlIUXPIdCSMCTO6qj+UFvypd0
SN4PXW/6DUJeGi3bXFql9XF8ysy6ZgheHKsvgPDlSkOO5QIDAQABo0gwRjAJBgNV
HRMEAjAAMAsGA1UdDwQEAwIF4DAsBgNVHREEJTAjggoqLmZpenouY29tgghmaXp6
LmNvbYILZXhhbXBsZS5uZXQwDQYJKoZIhvcNAQELBQADggEBAIpIvwxxSJrLGW8I
rz4PpKLoeKetLCW3HYVrrMF8nGLKwlzeWLa0BpQN638DuDLOsaGZX0OshsOsPCc9
FWub8Vdu5pA1zuDLS03aL2F4DBMyvKvDmqa0+Jsj+SuIk054oF1Q4jvx9VE0JBmx
1FfHZ5Ug+f8DLWYvLMN6G9P6YYzoENn589oa//JHYWDoJimt2IB80R1k47gIvGde
W4CnlNH1jYO1/mr1yVHNrpdkOab2ItdEycdTw8zi/QOGRhFevjcR+p6c+NKr2/OS
iv9+LfvbaFlvdxkkKGr3mrsb2EgzB1LiSHTllA+yS88QzxcSRhzSeSg/bvL+xsWT
xcGg1w0=
-----END CERTIFICATE-----
)"

Definition at line 159 of file TestUtil.h.

Referenced by getCert< RSATest >(), fizz::test::HandshakeTest::SetUp(), fizz::server::test::TEST(), and TEST().

constexpr folly::StringPiece fizz::test::kRSAKey
Initial value:
= R"(
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAxWSZkGZoflV+hnNKZVuCUr0eOedYtFIEU16mARPP3KPqHFrc
EXudA5/46hoogfSb2WYqEaCeltY3GiPG+WPdhhDEi5h4hImvL+g/iTU7LLmIhmkx
4hKzAYx012012Hxy7pvEJJy6S7wEcJj0AxNsWFo8SysIfO5Rw57CTHolxwcbuCsf
q6Cca3PE0gc9UXZ2KaTJNuph8gWPDdio8Au5YnYpvIYy0QXt6eUFAH8huNRBOUK+
XHng+/zAIXQAtGJEW/rx/vKDUWm0nzZKlIUXPIdCSMCTO6qj+UFvypd0SN4PXW/6
DUJeGi3bXFql9XF8ysy6ZgheHKsvgPDlSkOO5QIDAQABAoIBAH36IE+aLCJEqgVg
2yAo8NmhPQMzdNdQaNZUV5nkbQqhyi3ihwTZYXIIzLGLlEKsPDLZEwxA+DXH7U7P
epN7esuvM+DrpC7iOF5Y2QPWZze6CTnPNTjVOk1IuOEsH+tUMX27B8leBT+EdUjv
NPwpj0IsBMLsafRhnOk+Dz8Dzcxgyee6r0bGy4f7LZ4/e/mQzR2y5IrePmpRJH/8
NF6OfLpAxrVb57VVDaKEGjR0i0xOR8/nuNKgUVeAzkFNytJl5oxzHR3qHBg/mYmQ
Y4eu0tCZcczennWm06jt6P3qCD7xGtlj8RwFZeQ7UAwaHAPDd60LDb2Kt7WO87OY
wWYz2ZkCgYEA/hKBLyJsgvsGL25jTrcqdChJURiBl+KGQj3giSNy+WgHnQuSpX/G
6s46tgvuLpWzS3E4eX/ymdjWPe0S0N8ZVUAzr5Ne4/EdDTPmaZsLXEsJ+19YRfLY
/E9v0ao4Rliwk0lC4ieeNY79PKZ4XBP5eNg9c7T2dHFEadJHvB13P2sCgYEAxuQB
LShZzOPoN967I9VOkwYLrf5k0LdgKmuDgzFo7Y9WMiqy0GdcfsiPunde+HHXmRDE
k1Am14w3NQLQlLYs9QTUBHYVllPmpkLqozFauGNw5hHcq7YZtfZqIZLL0aueZhDt
aV/nNDMYTqgclJbpMEtQ6itLonLX1htJS0LGju8CgYAUIdE8s+SXSF7IGV4jGZ5y
j9Kna2Kxb1CmJRMKqtVsb9LSnd0j4gkYB/lc/XsFE/WeD72i2wGVMTpgs81e4Z63
Q5wU2H+XXj6oEim6yn9O8985nOd4u3J4I68/lNZatKJhOVfkZbFCmy7zxFkbKrYE
3lWYOomg1mzOWcw3WrpdOwKBgBzQtdbsDK6hqmhFzckwQ1ULwC9yNvsCRl1+/CvK
wdABP1S/WO7WutDnj+NNHiZSoBDeHAzXxPjfqLP2d2/EQRkynOEUlqYT+8vE0Cfa
o7EpPxcmKVl7ZZg2XkQE96CmA6n3892bdmzapj/nHVTt1FUZ5Fw475lWmCy+AU11
HD1jAoGBAOIA6kfwN6Z3mWRuivfruzk50NeqV2Xsmaa+Sk18n0Cz2cOynUWNl7qX
/8ZTeGj9UFARNbQ5aM+gRzgEPigpAiWK3qoedBfEUjKUyDZlfWlDu8Ds8T+HvZ0i
h8YfdM73KnIU0O8s+bvCkg/sFvqDmQ9ocdTSo1aVkNY4avhSgstK
-----END RSA PRIVATE KEY-----
)"

Definition at line 129 of file TestUtil.h.

Referenced by getKey< RSATest >(), fizz::test::HandshakeTest::SetUp(), and TEST().

struct randombytes_implementation fizz::test::mockRandom
static
Initial value:
= {
[]() { return "test"; },
[]() { return (uint32_t)0x44444444; },
nullptr,
nullptr,
[](void* const buf, const size_t size) { memset(buf, 0x44, size); },
nullptr}
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45

Definition at line 61 of file TestUtil.cpp.

const std::string fizz::test::tooLargeCompressedCertificate
static

Definition at line 57 of file ZlibCertificateCompressorTest.cpp.

Referenced by TEST_F().