-
Notifications
You must be signed in to change notification settings - Fork 156
/
Types.h
58 lines (47 loc) · 1.35 KB
/
Types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 2018-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <fizz/record/Types.h>
#include <folly/Range.h>
namespace fizz {
enum class HashFunction { Sha256, Sha384, Sha512 };
enum class PskType {
NotSupported,
NotAttempted,
Rejected,
External,
Resumption
};
/**
* `isPskAccepted` returning true implies that the handshake negotiated a PSK to
* be used.
*/
inline bool isPskAccepted(PskType t) {
switch (t) {
case PskType::NotSupported:
case PskType::NotAttempted:
case PskType::Rejected:
return false;
case PskType::External:
case PskType::Resumption:
return true;
}
}
/**
* Encryption level for the TLS layer.
*/
enum class EncryptionLevel { Plaintext, Handshake, EarlyData, AppTraffic };
enum class KeyExchangeType { None, OneRtt, HelloRetryRequest };
enum class EarlyDataType { NotAttempted, Attempted, Rejected, Accepted };
HashFunction getHashFunction(CipherSuite cipher);
size_t getHashSize(HashFunction hash);
folly::StringPiece toString(HashFunction hash);
folly::StringPiece toString(PskType pskType);
folly::StringPiece toString(KeyExchangeType kexType);
folly::StringPiece toString(EarlyDataType earlyDataType);
} // namespace fizz