|
20 | 20 | #ifndef RIPPLE_UNORDERED_CONTAINERS_H
|
21 | 21 | #define RIPPLE_UNORDERED_CONTAINERS_H
|
22 | 22 |
|
| 23 | +#include <beast/container/hardened_hash.h> |
23 | 24 | #include <beast/container/hash_append.h>
|
24 | 25 |
|
25 | 26 | #include <unordered_map>
|
26 | 27 | #include <unordered_set>
|
27 | 28 |
|
| 29 | +/** |
| 30 | +* Use hash_* containers for keys that do not need a cryptographically secure |
| 31 | +* hashing algorithm. |
| 32 | +* |
| 33 | +* Use hardened_hash_* containers for keys that do need a secure hashing algorithm. |
| 34 | +* |
| 35 | +* The cryptographic security of containers where a hash function is used as a |
| 36 | +* template parameter depends entirely on that hash function and not at all on |
| 37 | +* what container it is. |
| 38 | +*/ |
| 39 | + |
28 | 40 | namespace ripple
|
29 | 41 | {
|
30 | 42 |
|
| 43 | +// hash containers |
| 44 | + |
| 45 | +template <class Key, class Value, class Hash = beast::uhash<>, |
| 46 | + class Pred = std::equal_to<Key>, |
| 47 | + class Allocator = std::allocator<std::pair<Key const, Value>>> |
| 48 | +using hash_map = std::unordered_map <Key, Value, Hash, Pred, Allocator>; |
| 49 | + |
31 | 50 | template <class Key, class Value, class Hash = beast::uhash<>,
|
32 | 51 | class Pred = std::equal_to<Key>,
|
33 | 52 | class Allocator = std::allocator<std::pair<Key const, Value>>>
|
34 |
| -using unordered_map = std::unordered_map <Key, Value, Hash, Pred, Allocator>; |
| 53 | +using hash_multimap = std::unordered_multimap <Key, Value, Hash, Pred, Allocator>; |
| 54 | + |
| 55 | +template <class Value, class Hash = beast::uhash<>, |
| 56 | + class Pred = std::equal_to<Value>, |
| 57 | + class Allocator = std::allocator<Value>> |
| 58 | +using hash_set = std::unordered_set <Value, Hash, Pred, Allocator>; |
35 | 59 |
|
36 | 60 | template <class Value, class Hash = beast::uhash<>,
|
37 | 61 | class Pred = std::equal_to<Value>,
|
38 | 62 | class Allocator = std::allocator<Value>>
|
39 |
| -using unordered_set = std::unordered_set <Value, Hash, Pred, Allocator>; |
| 63 | +using hash_multiset = std::unordered_multiset <Value, Hash, Pred, Allocator>; |
| 64 | + |
| 65 | +// hardened_hash containers |
| 66 | + |
| 67 | +template <class Key, class Value, class Hash = beast::hardened_hash<>, |
| 68 | + class Pred = std::equal_to<Key>, |
| 69 | + class Allocator = std::allocator<std::pair<Key const, Value>>> |
| 70 | +using hardened_hash_map = std::unordered_map <Key, Value, Hash, Pred, Allocator>; |
| 71 | + |
| 72 | +template <class Key, class Value, class Hash = beast::hardened_hash<>, |
| 73 | + class Pred = std::equal_to<Key>, |
| 74 | + class Allocator = std::allocator<std::pair<Key const, Value>>> |
| 75 | +using hardened_hash_multimap = std::unordered_multimap <Key, Value, Hash, Pred, Allocator>; |
| 76 | + |
| 77 | +template <class Value, class Hash = beast::hardened_hash<>, |
| 78 | + class Pred = std::equal_to<Value>, |
| 79 | + class Allocator = std::allocator<Value>> |
| 80 | +using hardened_hash_set = std::unordered_set <Value, Hash, Pred, Allocator>; |
| 81 | + |
| 82 | +template <class Value, class Hash = beast::hardened_hash<>, |
| 83 | + class Pred = std::equal_to<Value>, |
| 84 | + class Allocator = std::allocator<Value>> |
| 85 | +using hardened_hash_multiset = std::unordered_multiset <Value, Hash, Pred, Allocator>; |
40 | 86 |
|
41 | 87 | } // ripple
|
42 | 88 |
|
|
0 commit comments