| #include <cstring> |
| 6 | #include <string> |
| 7 | #include <vector> |
| 8 | #include <openssl/rand.h> |
| 9 |
| 10 | // NOTE: MAX_GREASE and the key-generation helpers below were not part of |
| 11 | // TLSHello.cpp as uploaded — they must already exist somewhere in the |
| 12 | // project (the original file relied on them via #include "TLSHello.h"). |
| 13 | // Adjust/remove these declarations to match the real ones. |
| 14 | #ifndef MAX_GREASE |
| 15 | #define MAX_GREASE 8 |
| 16 | #endif |
| 17 |
| 18 | class TLSHello { |
| 19 | public: |
| 20 | TLSHello(); |
| 21 |
| 22 | struct Op { |
| 23 | enum class Type { |
| 24 | String, Random, K, M, P, E, Zero, Domain, Grease, BeginScope, EndScope, Permutation |
| 25 | }; |
| 26 | Type type; |
| 27 | size_t length = 0; |
| 28 | int seed = 0; |
| 29 | std::string data; |
| 30 | std::vector<std::vector<Op>> entities; |
| 31 |
| 32 | static Op string(const char str[], size_t len); |
| 33 | static Op random(size_t length); |
| 34 | static Op K(); |
| 35 | static Op E(); |
| 36 | static Op M(); |
| 37 | static Op P(); |
| 38 | static Op zero(size_t length); |
| 39 | static Op domain(); |
| 40 | static Op grease(int seed); |
| 41 | static Op begin_scope(); |
| 42 | static Op end_scope(); |
| 43 | static Op permutation(std::vector<std::vector<Op>> entities); |
| 44 | }; |
| 45 |
| 46 | static const TLSHello &getDefault(); |
| 47 |
| 48 | uint32_t writeToBuffer(uint8_t *data); |
| 49 |
| 50 | void setDomain(std::string value); |
| 51 |
| 52 | private: |
| 53 | std::vector<Op> ops; |
| 54 | uint8_t grease[MAX_GREASE]; |
| 55 | std::vector<size_t> scopeOffset; |
| 56 | std::string domain; |
| 57 |
| 58 | void writeOp(const Op &op, uint8_t *data, uint32_t &offset); |
| 59 | }; |
| 60 |
| 61 | #endif // TLSHELLO_H |