Line | Count | Source (jump to first uncovered line) |
1 | | // secblock.h - originally written and placed in the public domain by Wei Dai |
2 | | |
3 | | /// \file secblock.h |
4 | | /// \brief Classes and functions for secure memory allocations. |
5 | | |
6 | | #ifndef CRYPTOPP_SECBLOCK_H |
7 | | #define CRYPTOPP_SECBLOCK_H |
8 | | |
9 | | #include "config.h" |
10 | | #include "allocate.h" |
11 | | #include "misc.h" |
12 | | #include "stdcpp.h" |
13 | | |
14 | | #if defined(CRYPTOPP_MSC_VERSION) |
15 | | # pragma warning(push) |
16 | | # pragma warning(disable: 4231 4275 4700) |
17 | | # if (CRYPTOPP_MSC_VERSION >= 1400) |
18 | | # pragma warning(disable: 6011 6386 28193) |
19 | | # endif |
20 | | #endif |
21 | | |
22 | | NAMESPACE_BEGIN(CryptoPP) |
23 | | |
24 | | // ************** secure memory allocation *************** |
25 | | |
26 | | /// \brief Base class for all allocators used by SecBlock |
27 | | /// \tparam T the class or type |
28 | | template<class T> |
29 | | class AllocatorBase |
30 | | { |
31 | | public: |
32 | | typedef T value_type; |
33 | | typedef size_t size_type; |
34 | | typedef std::ptrdiff_t difference_type; |
35 | | typedef T * pointer; |
36 | | typedef const T * const_pointer; |
37 | | typedef T & reference; |
38 | | typedef const T & const_reference; |
39 | | |
40 | | pointer address(reference r) const {return (&r);} |
41 | | const_pointer address(const_reference r) const {return (&r); } |
42 | 0 | void construct(pointer p, const T& val) {new (p) T(val);} |
43 | 0 | void destroy(pointer p) {CRYPTOPP_UNUSED(p); p->~T();} |
44 | | |
45 | | /// \brief Returns the maximum number of elements the allocator can provide |
46 | | /// \details <tt>ELEMS_MAX</tt> is the maximum number of elements the |
47 | | /// <tt>Allocator</tt> can provide. The value of <tt>ELEMS_MAX</tt> is |
48 | | /// <tt>SIZE_MAX/sizeof(T)</tt>. <tt>std::numeric_limits</tt> was avoided |
49 | | /// due to lack of <tt>constexpr</tt>-ness in C++03 and below. |
50 | | /// \note In C++03 and below <tt>ELEMS_MAX</tt> is a static data member of type |
51 | | /// <tt>size_type</tt>. In C++11 and above <tt>ELEMS_MAX</tt> is an <tt>enum</tt> |
52 | | /// inheriting from <tt>size_type</tt>. In both cases <tt>ELEMS_MAX</tt> can be |
53 | | /// used before objects are fully constructed, and it does not suffer the |
54 | | /// limitations of class methods like <tt>max_size</tt>. |
55 | | /// \sa <A HREF="http://github.com/weidai11/cryptopp/issues/346">Issue 346/CVE-2016-9939</A> |
56 | | /// \since Crypto++ 6.0 |
57 | | #if defined(CRYPTOPP_DOXYGEN_PROCESSING) |
58 | | static const size_type ELEMS_MAX = ...; |
59 | | #elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION <= 1400) |
60 | | static const size_type ELEMS_MAX = (~(size_type)0)/sizeof(T); |
61 | | #elif defined(CRYPTOPP_CXX11_STRONG_ENUM) |
62 | | enum : size_type {ELEMS_MAX = SIZE_MAX/sizeof(T)}; |
63 | | #else |
64 | | static const size_type ELEMS_MAX = SIZE_MAX/sizeof(T); |
65 | | #endif |
66 | | |
67 | | /// \brief Returns the maximum number of elements the allocator can provide |
68 | | /// \return the maximum number of elements the allocator can provide |
69 | | /// \details Internally, preprocessor macros are used rather than std::numeric_limits |
70 | | /// because the latter is not a constexpr. Some compilers, like Clang, do not |
71 | | /// optimize it well under all circumstances. Compilers like GCC, ICC and MSVC appear |
72 | | /// to optimize it well in either form. |
73 | 0 | CRYPTOPP_CONSTEXPR size_type max_size() const {return ELEMS_MAX;} |
74 | | |
75 | | #if defined(__SUNPRO_CC) |
76 | | // https://github.com/weidai11/cryptopp/issues/770 |
77 | | // and https://stackoverflow.com/q/53999461/608639 |
78 | | CRYPTOPP_CONSTEXPR size_type max_size(size_type n) const {return SIZE_MAX/n;} |
79 | | #endif |
80 | | |
81 | | #if defined(CRYPTOPP_CXX11_VARIADIC_TEMPLATES) || defined(CRYPTOPP_DOXYGEN_PROCESSING) |
82 | | |
83 | | /// \brief Constructs a new V using variadic arguments |
84 | | /// \tparam V the type to be forwarded |
85 | | /// \tparam Args the arguments to be forwarded |
86 | | /// \param ptr pointer to type V |
87 | | /// \param args variadic arguments |
88 | | /// \details This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES |
89 | | /// is defined. The define is controlled by compiler versions detected in config.h. |
90 | | template<typename V, typename... Args> |
91 | 0 | void construct(V* ptr, Args&&... args) {::new ((void*)ptr) V(std::forward<Args>(args)...);} Unexecuted instantiation: void CryptoPP::AllocatorBase<unsigned char>::construct<unsigned char, unsigned char>(unsigned char*, unsigned char&&) Unexecuted instantiation: void CryptoPP::AllocatorBase<unsigned char>::construct<unsigned char>(unsigned char*) |
92 | | |
93 | | /// \brief Destroys an V constructed with variadic arguments |
94 | | /// \tparam V the type to be forwarded |
95 | | /// \details This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES |
96 | | /// is defined. The define is controlled by compiler versions detected in config.h. |
97 | | template<typename V> |
98 | | void destroy(V* ptr) {if (ptr) ptr->~V();} |
99 | | |
100 | | #endif |
101 | | |
102 | | protected: |
103 | | |
104 | | /// \brief Verifies the allocator can satisfy a request based on size |
105 | | /// \param size the size of the allocation, in elements |
106 | | /// \throw InvalidArgument |
107 | | /// \details CheckSize verifies the number of elements requested is valid. |
108 | | /// \details If size is greater than max_size(), then InvalidArgument is thrown. |
109 | | /// The library throws InvalidArgument if the size is too large to satisfy. |
110 | | /// \details Internally, preprocessor macros are used rather than std::numeric_limits |
111 | | /// because the latter is not a constexpr. Some compilers, like Clang, do not |
112 | | /// optimize it well under all circumstances. Compilers like GCC, ICC and MSVC appear |
113 | | /// to optimize it well in either form. |
114 | | /// \details The <tt>sizeof(T) != 1</tt> in the condition attempts to help the |
115 | | /// compiler optimize the check for byte types. Coverity findings for |
116 | | /// CONSTANT_EXPRESSION_RESULT were generated without it. For byte types, |
117 | | /// size never exceeded ELEMS_MAX but the code was not removed. |
118 | | /// \note size is the count of elements, and not the number of bytes |
119 | | static void CheckSize(size_t size) |
120 | 115M | { |
121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. |
122 | 115M | CRYPTOPP_UNUSED(size); |
123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. |
124 | 115M | if (sizeof(T) != 1 && size > ELEMS_MAX) |
125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); |
126 | 115M | } CryptoPP::AllocatorBase<unsigned char>::CheckSize(unsigned long) Line | Count | Source | 120 | 15.7M | { | 121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. | 122 | 15.7M | CRYPTOPP_UNUSED(size); | 123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. | 124 | 15.7M | if (sizeof(T) != 1 && size > ELEMS_MAX) | 125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); | 126 | 15.7M | } |
CryptoPP::AllocatorBase<unsigned int>::CheckSize(unsigned long) Line | Count | Source | 120 | 1.84k | { | 121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. | 122 | 1.84k | CRYPTOPP_UNUSED(size); | 123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. | 124 | 1.84k | if (sizeof(T) != 1 && size > ELEMS_MAX) | 125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); | 126 | 1.84k | } |
CryptoPP::AllocatorBase<unsigned long>::CheckSize(unsigned long) Line | Count | Source | 120 | 99.4M | { | 121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. | 122 | 99.4M | CRYPTOPP_UNUSED(size); | 123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. | 124 | 99.4M | if (sizeof(T) != 1 && size > ELEMS_MAX) | 125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); | 126 | 99.4M | } |
CryptoPP::AllocatorBase<unsigned short>::CheckSize(unsigned long) Line | Count | Source | 120 | 50 | { | 121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. | 122 | 50 | CRYPTOPP_UNUSED(size); | 123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. | 124 | 50 | if (sizeof(T) != 1 && size > ELEMS_MAX) | 125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); | 126 | 50 | } |
Unexecuted instantiation: CryptoPP::AllocatorBase<unsigned __int128>::CheckSize(unsigned long) CryptoPP::AllocatorBase<char>::CheckSize(unsigned long) Line | Count | Source | 120 | 7.68k | { | 121 | | // Squash MSC C4100 warning for size. Also see commit 42b7c4ea5673. | 122 | 7.68k | CRYPTOPP_UNUSED(size); | 123 | | // C++ throws std::bad_alloc (C++03) or std::bad_array_new_length (C++11) here. | 124 | 7.68k | if (sizeof(T) != 1 && size > ELEMS_MAX) | 125 | 0 | throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); | 126 | 7.68k | } |
|
127 | | }; |
128 | | |
129 | | #define CRYPTOPP_INHERIT_ALLOCATOR_TYPES(T_type) \ |
130 | | typedef typename AllocatorBase<T_type>::value_type value_type;\ |
131 | | typedef typename AllocatorBase<T_type>::size_type size_type;\ |
132 | | typedef typename AllocatorBase<T_type>::difference_type difference_type;\ |
133 | | typedef typename AllocatorBase<T_type>::pointer pointer;\ |
134 | | typedef typename AllocatorBase<T_type>::const_pointer const_pointer;\ |
135 | | typedef typename AllocatorBase<T_type>::reference reference;\ |
136 | | typedef typename AllocatorBase<T_type>::const_reference const_reference; |
137 | | |
138 | | /// \brief Reallocation function |
139 | | /// \tparam T the class or type |
140 | | /// \tparam A the class or type's allocator |
141 | | /// \param alloc the allocator |
142 | | /// \param oldPtr the previous allocation |
143 | | /// \param oldSize the size of the previous allocation |
144 | | /// \param newSize the new, requested size |
145 | | /// \param preserve flag that indicates if the old allocation should be preserved |
146 | | /// \note oldSize and newSize are the count of elements, and not the |
147 | | /// number of bytes. |
148 | | template <class T, class A> |
149 | | typename A::pointer StandardReallocate(A& alloc, T *oldPtr, typename A::size_type oldSize, typename A::size_type newSize, bool preserve) |
150 | 49.1M | { |
151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL |
152 | | // pointers rather returning non-NULL 0-sized pointers. |
153 | 49.1M | if (oldSize == newSize) |
154 | 23.6M | return oldPtr; |
155 | | |
156 | 25.4M | if (preserve) |
157 | 2.35M | { |
158 | 2.35M | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); |
159 | 2.35M | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); |
160 | | |
161 | 2.35M | if (oldPtr && newPtr) |
162 | 2.35M | memcpy_s(newPtr, copySize, oldPtr, copySize); |
163 | | |
164 | 2.35M | if (oldPtr) |
165 | 2.35M | alloc.deallocate(oldPtr, oldSize); |
166 | | |
167 | 2.35M | return newPtr; |
168 | 2.35M | } |
169 | 23.1M | else |
170 | 23.1M | { |
171 | 23.1M | if (oldPtr) |
172 | 18.0M | alloc.deallocate(oldPtr, oldSize); |
173 | | |
174 | 23.1M | return alloc.allocate(newSize, NULLPTR); |
175 | 23.1M | } |
176 | 25.4M | } CryptoPP::AllocatorWithCleanup<unsigned char, false>::pointer CryptoPP::StandardReallocate<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >(CryptoPP::AllocatorWithCleanup<unsigned char, false>&, unsigned char*, CryptoPP::AllocatorWithCleanup<unsigned char, false>::size_type, CryptoPP::AllocatorWithCleanup<unsigned char, false>::size_type, bool) Line | Count | Source | 150 | 5.24M | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 5.24M | if (oldSize == newSize) | 154 | 5.09M | return oldPtr; | 155 | | | 156 | 146k | if (preserve) | 157 | 4.53k | { | 158 | 4.53k | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 4.53k | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | | | 161 | 4.53k | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | | | 164 | 4.53k | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | | | 167 | 4.53k | return newPtr; | 168 | 4.53k | } | 169 | 142k | else | 170 | 142k | { | 171 | 142k | if (oldPtr) | 172 | 416 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 142k | return alloc.allocate(newSize, NULLPTR); | 175 | 142k | } | 176 | 146k | } |
CryptoPP::AllocatorWithCleanup<unsigned long, true>::pointer CryptoPP::StandardReallocate<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >(CryptoPP::AllocatorWithCleanup<unsigned long, true>&, unsigned long*, CryptoPP::AllocatorWithCleanup<unsigned long, true>::size_type, CryptoPP::AllocatorWithCleanup<unsigned long, true>::size_type, bool) Line | Count | Source | 150 | 43.9M | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 43.9M | if (oldSize == newSize) | 154 | 18.5M | return oldPtr; | 155 | | | 156 | 25.3M | if (preserve) | 157 | 2.35M | { | 158 | 2.35M | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 2.35M | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | | | 161 | 2.35M | if (oldPtr && newPtr) | 162 | 2.35M | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | | | 164 | 2.35M | if (oldPtr) | 165 | 2.35M | alloc.deallocate(oldPtr, oldSize); | 166 | | | 167 | 2.35M | return newPtr; | 168 | 2.35M | } | 169 | 22.9M | else | 170 | 22.9M | { | 171 | 22.9M | if (oldPtr) | 172 | 18.0M | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 22.9M | return alloc.allocate(newSize, NULLPTR); | 175 | 22.9M | } | 176 | 25.3M | } |
CryptoPP::AllocatorWithCleanup<unsigned int, true>::pointer CryptoPP::StandardReallocate<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >(CryptoPP::AllocatorWithCleanup<unsigned int, true>&, unsigned int*, CryptoPP::AllocatorWithCleanup<unsigned int, true>::size_type, CryptoPP::AllocatorWithCleanup<unsigned int, true>::size_type, bool) Line | Count | Source | 150 | 243 | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 243 | if (oldSize == newSize) | 154 | 0 | return oldPtr; | 155 | | | 156 | 243 | if (preserve) | 157 | 0 | { | 158 | 0 | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 0 | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | |
| 161 | 0 | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | |
| 164 | 0 | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | |
| 167 | 0 | return newPtr; | 168 | 0 | } | 169 | 243 | else | 170 | 243 | { | 171 | 243 | if (oldPtr) | 172 | 0 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 243 | return alloc.allocate(newSize, NULLPTR); | 175 | 243 | } | 176 | 243 | } |
CryptoPP::AllocatorWithCleanup<unsigned char, true>::pointer CryptoPP::StandardReallocate<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >(CryptoPP::AllocatorWithCleanup<unsigned char, true>&, unsigned char*, CryptoPP::AllocatorWithCleanup<unsigned char, true>::size_type, CryptoPP::AllocatorWithCleanup<unsigned char, true>::size_type, bool) Line | Count | Source | 150 | 1.06k | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 1.06k | if (oldSize == newSize) | 154 | 778 | return oldPtr; | 155 | | | 156 | 286 | if (preserve) | 157 | 84 | { | 158 | 84 | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 84 | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | | | 161 | 84 | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | | | 164 | 84 | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | | | 167 | 84 | return newPtr; | 168 | 84 | } | 169 | 202 | else | 170 | 202 | { | 171 | 202 | if (oldPtr) | 172 | 0 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 202 | return alloc.allocate(newSize, NULLPTR); | 175 | 202 | } | 176 | 286 | } |
CryptoPP::AllocatorWithCleanup<unsigned int, false>::pointer CryptoPP::StandardReallocate<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >(CryptoPP::AllocatorWithCleanup<unsigned int, false>&, unsigned int*, CryptoPP::AllocatorWithCleanup<unsigned int, false>::size_type, CryptoPP::AllocatorWithCleanup<unsigned int, false>::size_type, bool) Line | Count | Source | 150 | 191 | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 191 | if (oldSize == newSize) | 154 | 0 | return oldPtr; | 155 | | | 156 | 191 | if (preserve) | 157 | 0 | { | 158 | 0 | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 0 | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | |
| 161 | 0 | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | |
| 164 | 0 | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | |
| 167 | 0 | return newPtr; | 168 | 0 | } | 169 | 191 | else | 170 | 191 | { | 171 | 191 | if (oldPtr) | 172 | 0 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 191 | return alloc.allocate(newSize, NULLPTR); | 175 | 191 | } | 176 | 191 | } |
CryptoPP::AllocatorWithCleanup<unsigned short, false>::pointer CryptoPP::StandardReallocate<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >(CryptoPP::AllocatorWithCleanup<unsigned short, false>&, unsigned short*, CryptoPP::AllocatorWithCleanup<unsigned short, false>::size_type, CryptoPP::AllocatorWithCleanup<unsigned short, false>::size_type, bool) Line | Count | Source | 150 | 1 | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 1 | if (oldSize == newSize) | 154 | 0 | return oldPtr; | 155 | | | 156 | 1 | if (preserve) | 157 | 0 | { | 158 | 0 | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 0 | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | |
| 161 | 0 | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | |
| 164 | 0 | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | |
| 167 | 0 | return newPtr; | 168 | 0 | } | 169 | 1 | else | 170 | 1 | { | 171 | 1 | if (oldPtr) | 172 | 0 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 1 | return alloc.allocate(newSize, NULLPTR); | 175 | 1 | } | 176 | 1 | } |
CryptoPP::AllocatorWithCleanup<unsigned long, false>::pointer CryptoPP::StandardReallocate<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >(CryptoPP::AllocatorWithCleanup<unsigned long, false>&, unsigned long*, CryptoPP::AllocatorWithCleanup<unsigned long, false>::size_type, CryptoPP::AllocatorWithCleanup<unsigned long, false>::size_type, bool) Line | Count | Source | 150 | 300 | { | 151 | | // Avoid assert on pointer in reallocate. SecBlock regularly uses NULL | 152 | | // pointers rather returning non-NULL 0-sized pointers. | 153 | 300 | if (oldSize == newSize) | 154 | 0 | return oldPtr; | 155 | | | 156 | 300 | if (preserve) | 157 | 0 | { | 158 | 0 | typename A::pointer newPtr = alloc.allocate(newSize, NULLPTR); | 159 | 0 | const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); | 160 | |
| 161 | 0 | if (oldPtr && newPtr) | 162 | 0 | memcpy_s(newPtr, copySize, oldPtr, copySize); | 163 | |
| 164 | 0 | if (oldPtr) | 165 | 0 | alloc.deallocate(oldPtr, oldSize); | 166 | |
| 167 | 0 | return newPtr; | 168 | 0 | } | 169 | 300 | else | 170 | 300 | { | 171 | 300 | if (oldPtr) | 172 | 0 | alloc.deallocate(oldPtr, oldSize); | 173 | | | 174 | 300 | return alloc.allocate(newSize, NULLPTR); | 175 | 300 | } | 176 | 300 | } |
Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::pointer CryptoPP::StandardReallocate<unsigned __int128, CryptoPP::AllocatorWithCleanup<unsigned __int128, true> >(CryptoPP::AllocatorWithCleanup<unsigned __int128, true>&, unsigned __int128*, CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::size_type, CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::size_type, bool) Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<char, false>::pointer CryptoPP::StandardReallocate<char, CryptoPP::AllocatorWithCleanup<char, false> >(CryptoPP::AllocatorWithCleanup<char, false>&, char*, CryptoPP::AllocatorWithCleanup<char, false>::size_type, CryptoPP::AllocatorWithCleanup<char, false>::size_type, bool) |
177 | | |
178 | | /// \brief Allocates a block of memory with cleanup |
179 | | /// \tparam T class or type |
180 | | /// \tparam T_Align16 boolean that determines whether allocations should be aligned on a 16-byte boundary |
181 | | /// \details If T_Align16 is true, then AllocatorWithCleanup calls AlignedAllocate() |
182 | | /// for memory allocations. If T_Align16 is false, then AllocatorWithCleanup() calls |
183 | | /// UnalignedAllocate() for memory allocations. |
184 | | /// \details Template parameter T_Align16 is effectively controlled by cryptlib.h and mirrors |
185 | | /// CRYPTOPP_BOOL_ALIGN16. CRYPTOPP_BOOL_ALIGN16 is often used as the template parameter. |
186 | | template <class T, bool T_Align16 = false> |
187 | | class AllocatorWithCleanup : public AllocatorBase<T> |
188 | | { |
189 | | public: |
190 | | CRYPTOPP_INHERIT_ALLOCATOR_TYPES(T) |
191 | | |
192 | | /// \brief Allocates a block of memory |
193 | | /// \param ptr the size of the allocation |
194 | | /// \param size the size of the allocation, in elements |
195 | | /// \return a memory block |
196 | | /// \throw InvalidArgument |
197 | | /// \details allocate() first checks the size of the request. If it is non-0 |
198 | | /// and less than max_size(), then an attempt is made to fulfill the request |
199 | | /// using either AlignedAllocate() or UnalignedAllocate(). AlignedAllocate() is |
200 | | /// used if T_Align16 is true. UnalignedAllocate() used if T_Align16 is false. |
201 | | /// \details This is the C++ *Placement New* operator. ptr is not used, and the |
202 | | /// function asserts in Debug builds if ptr is non-NULL. |
203 | | /// \sa CallNewHandler() for the methods used to recover from a failed |
204 | | /// allocation attempt. |
205 | | /// \note size is the count of elements, and not the number of bytes |
206 | | pointer allocate(size_type size, const void *ptr = NULLPTR) |
207 | 115M | { |
208 | 115M | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); |
209 | 115M | this->CheckSize(size); |
210 | 115M | if (size == 0) |
211 | 20.3M | return NULLPTR; |
212 | | |
213 | 94.8M | #if CRYPTOPP_BOOL_ALIGN16 |
214 | 94.8M | if (T_Align16) |
215 | 94.4M | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); |
216 | 302k | #endif |
217 | | |
218 | 302k | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); |
219 | 94.8M | } CryptoPP::AllocatorWithCleanup<unsigned char, true>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 3.17k | { | 208 | 3.17k | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 3.17k | this->CheckSize(size); | 210 | 3.17k | if (size == 0) | 211 | 1.60k | return NULLPTR; | 212 | | | 213 | 1.57k | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 1.57k | if (T_Align16) | 215 | 1.57k | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 0 | #endif | 217 | | | 218 | 0 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 1.57k | } |
CryptoPP::AllocatorWithCleanup<unsigned int, true>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 889 | { | 208 | 889 | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 889 | this->CheckSize(size); | 210 | 889 | if (size == 0) | 211 | 646 | return NULLPTR; | 212 | | | 213 | 243 | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 243 | if (T_Align16) | 215 | 243 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 0 | #endif | 217 | | | 218 | 0 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 243 | } |
CryptoPP::AllocatorWithCleanup<unsigned char, false>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 15.7M | { | 208 | 15.7M | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 15.7M | this->CheckSize(size); | 210 | 15.7M | if (size == 0) | 211 | 15.4M | return NULLPTR; | 212 | | | 213 | 294k | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 294k | if (T_Align16) | 215 | 0 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 294k | #endif | 217 | | | 218 | 294k | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 294k | } |
CryptoPP::AllocatorWithCleanup<unsigned long, true>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 99.4M | { | 208 | 99.4M | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 99.4M | this->CheckSize(size); | 210 | 99.4M | if (size == 0) | 211 | 4.90M | return NULLPTR; | 212 | | | 213 | 94.4M | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 94.4M | if (T_Align16) | 215 | 94.4M | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 0 | #endif | 217 | | | 218 | 0 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 94.4M | } |
CryptoPP::AllocatorWithCleanup<unsigned int, false>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 953 | { | 208 | 953 | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 953 | this->CheckSize(size); | 210 | 953 | if (size == 0) | 211 | 752 | return NULLPTR; | 212 | | | 213 | 201 | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 201 | if (T_Align16) | 215 | 0 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 201 | #endif | 217 | | | 218 | 201 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 201 | } |
CryptoPP::AllocatorWithCleanup<unsigned short, false>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 50 | { | 208 | 50 | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 50 | this->CheckSize(size); | 210 | 50 | if (size == 0) | 211 | 49 | return NULLPTR; | 212 | | | 213 | 1 | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 1 | if (T_Align16) | 215 | 0 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 1 | #endif | 217 | | | 218 | 1 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 1 | } |
CryptoPP::AllocatorWithCleanup<unsigned long, false>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 836 | { | 208 | 836 | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 836 | this->CheckSize(size); | 210 | 836 | if (size == 0) | 211 | 526 | return NULLPTR; | 212 | | | 213 | 310 | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 310 | if (T_Align16) | 215 | 0 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 310 | #endif | 217 | | | 218 | 310 | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 310 | } |
Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::allocate(unsigned long, void const*) CryptoPP::AllocatorWithCleanup<char, false>::allocate(unsigned long, void const*) Line | Count | Source | 207 | 7.68k | { | 208 | 7.68k | CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); | 209 | 7.68k | this->CheckSize(size); | 210 | 7.68k | if (size == 0) | 211 | 0 | return NULLPTR; | 212 | | | 213 | 7.68k | #if CRYPTOPP_BOOL_ALIGN16 | 214 | 7.68k | if (T_Align16) | 215 | 0 | return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); | 216 | 7.68k | #endif | 217 | | | 218 | 7.68k | return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); | 219 | 7.68k | } |
|
220 | | |
221 | | /// \brief Deallocates a block of memory |
222 | | /// \param ptr the pointer for the allocation |
223 | | /// \param size the size of the allocation, in elements |
224 | | /// \details Internally, SecureWipeArray() is called before deallocating the |
225 | | /// memory. Once the memory block is wiped or zeroized, AlignedDeallocate() |
226 | | /// or UnalignedDeallocate() is called. |
227 | | /// \details AlignedDeallocate() is used if T_Align16 is true. |
228 | | /// UnalignedDeallocate() used if T_Align16 is false. |
229 | | void deallocate(void *ptr, size_type size) |
230 | 110M | { |
231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL |
232 | | // pointers rather returning non-NULL 0-sized pointers. |
233 | 110M | if (ptr) |
234 | 94.8M | { |
235 | 94.8M | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); |
236 | | |
237 | 94.8M | #if CRYPTOPP_BOOL_ALIGN16 |
238 | 94.8M | if (T_Align16) |
239 | 94.4M | return AlignedDeallocate(ptr); |
240 | 302k | #endif |
241 | | |
242 | 302k | UnalignedDeallocate(ptr); |
243 | 302k | } |
244 | 110M | } CryptoPP::AllocatorWithCleanup<unsigned char, true>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 2.89k | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 2.89k | if (ptr) | 234 | 1.57k | { | 235 | 1.57k | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 1.57k | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 1.57k | if (T_Align16) | 239 | 1.57k | return AlignedDeallocate(ptr); | 240 | 0 | #endif | 241 | | | 242 | 0 | UnalignedDeallocate(ptr); | 243 | 0 | } | 244 | 2.89k | } |
CryptoPP::AllocatorWithCleanup<unsigned int, true>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 646 | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 646 | if (ptr) | 234 | 243 | { | 235 | 243 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 243 | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 243 | if (T_Align16) | 239 | 243 | return AlignedDeallocate(ptr); | 240 | 0 | #endif | 241 | | | 242 | 0 | UnalignedDeallocate(ptr); | 243 | 0 | } | 244 | 646 | } |
CryptoPP::AllocatorWithCleanup<unsigned long, true>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 94.4M | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 94.4M | if (ptr) | 234 | 94.4M | { | 235 | 94.4M | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 94.4M | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 94.4M | if (T_Align16) | 239 | 94.4M | return AlignedDeallocate(ptr); | 240 | 0 | #endif | 241 | | | 242 | 0 | UnalignedDeallocate(ptr); | 243 | 0 | } | 244 | 94.4M | } |
CryptoPP::AllocatorWithCleanup<unsigned char, false>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 15.5M | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 15.5M | if (ptr) | 234 | 294k | { | 235 | 294k | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 294k | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 294k | if (T_Align16) | 239 | 0 | return AlignedDeallocate(ptr); | 240 | 294k | #endif | 241 | | | 242 | 294k | UnalignedDeallocate(ptr); | 243 | 294k | } | 244 | 15.5M | } |
CryptoPP::AllocatorWithCleanup<unsigned int, false>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 762 | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 762 | if (ptr) | 234 | 201 | { | 235 | 201 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 201 | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 201 | if (T_Align16) | 239 | 0 | return AlignedDeallocate(ptr); | 240 | 201 | #endif | 241 | | | 242 | 201 | UnalignedDeallocate(ptr); | 243 | 201 | } | 244 | 762 | } |
CryptoPP::AllocatorWithCleanup<unsigned short, false>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 49 | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 49 | if (ptr) | 234 | 1 | { | 235 | 1 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 1 | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 1 | if (T_Align16) | 239 | 0 | return AlignedDeallocate(ptr); | 240 | 1 | #endif | 241 | | | 242 | 1 | UnalignedDeallocate(ptr); | 243 | 1 | } | 244 | 49 | } |
CryptoPP::AllocatorWithCleanup<unsigned long, false>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 496 | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 496 | if (ptr) | 234 | 300 | { | 235 | 300 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 300 | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 300 | if (T_Align16) | 239 | 0 | return AlignedDeallocate(ptr); | 240 | 300 | #endif | 241 | | | 242 | 300 | UnalignedDeallocate(ptr); | 243 | 300 | } | 244 | 496 | } |
Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::deallocate(void*, unsigned long) CryptoPP::AllocatorWithCleanup<char, false>::deallocate(void*, unsigned long) Line | Count | Source | 230 | 7.68k | { | 231 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 232 | | // pointers rather returning non-NULL 0-sized pointers. | 233 | 7.68k | if (ptr) | 234 | 7.68k | { | 235 | 7.68k | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 236 | | | 237 | 7.68k | #if CRYPTOPP_BOOL_ALIGN16 | 238 | 7.68k | if (T_Align16) | 239 | 0 | return AlignedDeallocate(ptr); | 240 | 7.68k | #endif | 241 | | | 242 | 7.68k | UnalignedDeallocate(ptr); | 243 | 7.68k | } | 244 | 7.68k | } |
|
245 | | |
246 | | /// \brief Reallocates a block of memory |
247 | | /// \param oldPtr the previous allocation |
248 | | /// \param oldSize the size of the previous allocation |
249 | | /// \param newSize the new, requested size |
250 | | /// \param preserve flag that indicates if the old allocation should be preserved |
251 | | /// \return pointer to the new memory block |
252 | | /// \details Internally, reallocate() calls StandardReallocate(). |
253 | | /// \details If preserve is true, then index 0 is used to begin copying the |
254 | | /// old memory block to the new one. If the block grows, then the old array |
255 | | /// is copied in its entirety. If the block shrinks, then only newSize |
256 | | /// elements are copied from the old block to the new one. |
257 | | /// \note oldSize and newSize are the count of elements, and not the |
258 | | /// number of bytes. |
259 | | pointer reallocate(T *oldPtr, size_type oldSize, size_type newSize, bool preserve) |
260 | 49.1M | { |
261 | 49.1M | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); |
262 | 49.1M | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); |
263 | 49.1M | } CryptoPP::AllocatorWithCleanup<unsigned char, false>::reallocate(unsigned char*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 5.24M | { | 261 | 5.24M | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 5.24M | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 5.24M | } |
CryptoPP::AllocatorWithCleanup<unsigned long, true>::reallocate(unsigned long*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 43.9M | { | 261 | 43.9M | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 43.9M | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 43.9M | } |
CryptoPP::AllocatorWithCleanup<unsigned int, true>::reallocate(unsigned int*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 243 | { | 261 | 243 | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 243 | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 243 | } |
CryptoPP::AllocatorWithCleanup<unsigned char, true>::reallocate(unsigned char*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 1.06k | { | 261 | 1.06k | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 1.06k | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 1.06k | } |
CryptoPP::AllocatorWithCleanup<unsigned int, false>::reallocate(unsigned int*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 191 | { | 261 | 191 | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 191 | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 191 | } |
CryptoPP::AllocatorWithCleanup<unsigned short, false>::reallocate(unsigned short*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 1 | { | 261 | 1 | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 1 | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 1 | } |
CryptoPP::AllocatorWithCleanup<unsigned long, false>::reallocate(unsigned long*, unsigned long, unsigned long, bool) Line | Count | Source | 260 | 300 | { | 261 | 300 | CRYPTOPP_ASSERT((oldPtr && oldSize) || !(oldPtr || oldSize)); | 262 | 300 | return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); | 263 | 300 | } |
Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<unsigned __int128, true>::reallocate(unsigned __int128*, unsigned long, unsigned long, bool) Unexecuted instantiation: CryptoPP::AllocatorWithCleanup<char, false>::reallocate(char*, unsigned long, unsigned long, bool) |
264 | | |
265 | | /// \brief Template class member Rebind |
266 | | /// \tparam V bound class or type |
267 | | /// \details Rebind allows a container class to allocate a different type of object |
268 | | /// to store elements. For example, a std::list will allocate std::list_node to |
269 | | /// store elements in the list. |
270 | | /// \details VS.NET STL enforces the policy of "All STL-compliant allocators |
271 | | /// have to provide a template class member called rebind". |
272 | | template <class V> struct rebind { typedef AllocatorWithCleanup<V, T_Align16> other; }; |
273 | | #if (CRYPTOPP_MSC_VERSION >= 1500) |
274 | | AllocatorWithCleanup() {} |
275 | | template <class V, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<V, A> &) {} |
276 | | #endif |
277 | | }; |
278 | | |
279 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<byte>; |
280 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word16>; |
281 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word32>; |
282 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word64>; |
283 | | #if defined(CRYPTOPP_WORD128_AVAILABLE) |
284 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word128, true>; // for Integer |
285 | | #endif |
286 | | #if CRYPTOPP_BOOL_X86 |
287 | | CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word, true>; // for Integer |
288 | | #endif |
289 | | |
290 | | /// \brief NULL allocator |
291 | | /// \tparam T class or type |
292 | | /// \details A NullAllocator is useful for fixed-size, stack based allocations |
293 | | /// (i.e., static arrays used by FixedSizeAllocatorWithCleanup). |
294 | | /// \details A NullAllocator always returns 0 for max_size(), and always returns |
295 | | /// NULL for allocation requests. Though the allocator does not allocate at |
296 | | /// runtime, it does perform a secure wipe or zeroization during cleanup. |
297 | | template <class T> |
298 | | class NullAllocator : public AllocatorBase<T> |
299 | | { |
300 | | public: |
301 | | //LCOV_EXCL_START |
302 | | CRYPTOPP_INHERIT_ALLOCATOR_TYPES(T) |
303 | | |
304 | | // TODO: should this return NULL or throw bad_alloc? Non-Windows C++ standard |
305 | | // libraries always throw. And late mode Windows throws. Early model Windows |
306 | | // (circa VC++ 6.0) returned NULL. |
307 | | pointer allocate(size_type n, const void* unused = NULLPTR) |
308 | 0 | { |
309 | 0 | CRYPTOPP_UNUSED(n); CRYPTOPP_UNUSED(unused); |
310 | 0 | CRYPTOPP_ASSERT(false); return NULLPTR; |
311 | 0 | } Unexecuted instantiation: CryptoPP::NullAllocator<unsigned char>::allocate(unsigned long, void const*) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned int>::allocate(unsigned long, void const*) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned long>::allocate(unsigned long, void const*) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned short>::allocate(unsigned long, void const*) |
312 | | |
313 | | void deallocate(void *p, size_type n) |
314 | 0 | { |
315 | 0 | CRYPTOPP_UNUSED(p); CRYPTOPP_UNUSED(n); |
316 | 0 | CRYPTOPP_ASSERT(false); |
317 | 0 | } Unexecuted instantiation: CryptoPP::NullAllocator<unsigned char>::deallocate(void*, unsigned long) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned int>::deallocate(void*, unsigned long) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned long>::deallocate(void*, unsigned long) Unexecuted instantiation: CryptoPP::NullAllocator<unsigned short>::deallocate(void*, unsigned long) |
318 | | |
319 | | CRYPTOPP_CONSTEXPR size_type max_size() const {return 0;} |
320 | | //LCOV_EXCL_STOP |
321 | | }; |
322 | | |
323 | | /// \brief Static secure memory block with cleanup |
324 | | /// \tparam T class or type |
325 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
326 | | /// \tparam T_Align16 boolean that determines whether allocations should |
327 | | /// be aligned on a 16-byte boundary |
328 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
329 | | /// based allocation at compile time. The class can grow its memory |
330 | | /// block at runtime if a suitable allocator is available. If size |
331 | | /// grows beyond S and a suitable allocator is available, then the |
332 | | /// statically allocated array is obsoleted. |
333 | | /// \note This allocator can't be used with standard collections because |
334 | | /// they require that all objects of the same allocator type are equivalent. |
335 | | template <class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false> |
336 | | class FixedSizeAllocatorWithCleanup : public AllocatorBase<T> |
337 | | { |
338 | | // The body of FixedSizeAllocatorWithCleanup is provided in the two |
339 | | // partial specializations that follow. The two specializations |
340 | | // pivot on the boolean template parameter T_Align16. |
341 | | }; |
342 | | |
343 | | /// \brief Static secure memory block with cleanup |
344 | | /// \tparam T class or type |
345 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
346 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
347 | | /// based allocation at compile time. The class can grow its memory |
348 | | /// block at runtime if a suitable allocator is available. If size |
349 | | /// grows beyond S and a suitable allocator is available, then the |
350 | | /// statically allocated array is obsoleted. |
351 | | /// \note This allocator can't be used with standard collections because |
352 | | /// they require that all objects of the same allocator type are equivalent. |
353 | | template <class T, size_t S, class A> |
354 | | class FixedSizeAllocatorWithCleanup<T, S, A, true> : public AllocatorBase<T> |
355 | | { |
356 | | public: |
357 | | CRYPTOPP_INHERIT_ALLOCATOR_TYPES(T) |
358 | | |
359 | | /// \brief Constructs a FixedSizeAllocatorWithCleanup |
360 | 4.70k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 1.51k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 757 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 40 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 40 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 80 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 73 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 383 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 724 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 355 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 369 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 360 | 369 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
|
361 | | |
362 | | /// \brief Allocates a block of memory |
363 | | /// \param size the count elements in the memory block |
364 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack-based |
365 | | /// allocation at compile time. If size is less than or equal to |
366 | | /// <tt>S</tt>, then a pointer to the static array is returned. |
367 | | /// \details The class can grow its memory block at runtime if a suitable |
368 | | /// allocator is available. If size grows beyond S and a suitable |
369 | | /// allocator is available, then the statically allocated array is |
370 | | /// obsoleted. If a suitable allocator is not available, as with a |
371 | | /// NullAllocator, then the function returns NULL and a runtime error |
372 | | /// eventually occurs. |
373 | | /// \sa reallocate(), SecBlockWithHint |
374 | | pointer allocate(size_type size) |
375 | | { |
376 | | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); |
377 | | |
378 | | if (size <= S && !m_allocated) |
379 | | { |
380 | | m_allocated = true; |
381 | | return GetAlignedArray(); |
382 | | } |
383 | | else |
384 | | return m_fallbackAllocator.allocate(size); |
385 | | } |
386 | | |
387 | | /// \brief Allocates a block of memory |
388 | | /// \param size the count elements in the memory block |
389 | | /// \param hint an unused hint |
390 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
391 | | /// based allocation at compile time. If size is less than or equal to |
392 | | /// S, then a pointer to the static array is returned. |
393 | | /// \details The class can grow its memory block at runtime if a suitable |
394 | | /// allocator is available. If size grows beyond S and a suitable |
395 | | /// allocator is available, then the statically allocated array is |
396 | | /// obsoleted. If a suitable allocator is not available, as with a |
397 | | /// NullAllocator, then the function returns NULL and a runtime error |
398 | | /// eventually occurs. |
399 | | /// \sa reallocate(), SecBlockWithHint |
400 | | pointer allocate(size_type size, const void *hint) |
401 | 4.70k | { |
402 | 4.70k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); |
403 | | |
404 | 4.70k | if (size <= S && !m_allocated) |
405 | 4.70k | { |
406 | 4.70k | m_allocated = true; |
407 | 4.70k | return GetAlignedArray(); |
408 | 4.70k | } |
409 | 0 | else |
410 | 0 | return m_fallbackAllocator.allocate(size, hint); |
411 | 4.70k | } CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 1.51k | { | 402 | 1.51k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 1.51k | if (size <= S && !m_allocated) | 405 | 1.51k | { | 406 | 1.51k | m_allocated = true; | 407 | 1.51k | return GetAlignedArray(); | 408 | 1.51k | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 1.51k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 757 | { | 402 | 757 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 757 | if (size <= S && !m_allocated) | 405 | 757 | { | 406 | 757 | m_allocated = true; | 407 | 757 | return GetAlignedArray(); | 408 | 757 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 757 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 40 | { | 402 | 40 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 40 | if (size <= S && !m_allocated) | 405 | 40 | { | 406 | 40 | m_allocated = true; | 407 | 40 | return GetAlignedArray(); | 408 | 40 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 40 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 40 | { | 402 | 40 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 40 | if (size <= S && !m_allocated) | 405 | 40 | { | 406 | 40 | m_allocated = true; | 407 | 40 | return GetAlignedArray(); | 408 | 40 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 40 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 80 | { | 402 | 80 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 80 | if (size <= S && !m_allocated) | 405 | 80 | { | 406 | 80 | m_allocated = true; | 407 | 80 | return GetAlignedArray(); | 408 | 80 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 80 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 73 | { | 402 | 73 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 73 | if (size <= S && !m_allocated) | 405 | 73 | { | 406 | 73 | m_allocated = true; | 407 | 73 | return GetAlignedArray(); | 408 | 73 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 383 | { | 402 | 383 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 383 | if (size <= S && !m_allocated) | 405 | 383 | { | 406 | 383 | m_allocated = true; | 407 | 383 | return GetAlignedArray(); | 408 | 383 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 383 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 724 | { | 402 | 724 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 724 | if (size <= S && !m_allocated) | 405 | 724 | { | 406 | 724 | m_allocated = true; | 407 | 724 | return GetAlignedArray(); | 408 | 724 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 724 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 355 | { | 402 | 355 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 355 | if (size <= S && !m_allocated) | 405 | 355 | { | 406 | 355 | m_allocated = true; | 407 | 355 | return GetAlignedArray(); | 408 | 355 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 355 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 369 | { | 402 | 369 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 369 | if (size <= S && !m_allocated) | 405 | 369 | { | 406 | 369 | m_allocated = true; | 407 | 369 | return GetAlignedArray(); | 408 | 369 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 369 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true>::allocate(unsigned long, void const*) Line | Count | Source | 401 | 369 | { | 402 | 369 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 403 | | | 404 | 369 | if (size <= S && !m_allocated) | 405 | 369 | { | 406 | 369 | m_allocated = true; | 407 | 369 | return GetAlignedArray(); | 408 | 369 | } | 409 | 0 | else | 410 | 0 | return m_fallbackAllocator.allocate(size, hint); | 411 | 369 | } |
|
412 | | |
413 | | /// \brief Deallocates a block of memory |
414 | | /// \param ptr a pointer to the memory block to deallocate |
415 | | /// \param size the count elements in the memory block |
416 | | /// \details The memory block is wiped or zeroized before deallocation. |
417 | | /// If the statically allocated memory block is active, then no |
418 | | /// additional actions are taken after the wipe. |
419 | | /// \details If a dynamic memory block is active, then the pointer and |
420 | | /// size are passed to the allocator for deallocation. |
421 | | void deallocate(void *ptr, size_type size) |
422 | 4.70k | { |
423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL |
424 | | // pointers rather returning non-NULL 0-sized pointers. |
425 | 4.70k | if (ptr == GetAlignedArray()) |
426 | 4.70k | { |
427 | | // If the m_allocated assert fires then the bit twiddling for |
428 | | // GetAlignedArray() is probably incorrect for the platform. |
429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may |
430 | | // not have a way to declaratively align data to 8. |
431 | 4.70k | CRYPTOPP_ASSERT(size <= S); |
432 | 4.70k | CRYPTOPP_ASSERT(m_allocated); |
433 | 4.70k | m_allocated = false; |
434 | 4.70k | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); |
435 | 4.70k | } |
436 | 0 | else |
437 | 0 | { |
438 | 0 | if (ptr) |
439 | 0 | m_fallbackAllocator.deallocate(ptr, size); |
440 | 0 | } |
441 | 4.70k | } CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 383 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 383 | if (ptr == GetAlignedArray()) | 426 | 383 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 383 | CRYPTOPP_ASSERT(size <= S); | 432 | 383 | CRYPTOPP_ASSERT(m_allocated); | 433 | 383 | m_allocated = false; | 434 | 383 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 383 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 383 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 73 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 73 | if (ptr == GetAlignedArray()) | 426 | 73 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 73 | CRYPTOPP_ASSERT(size <= S); | 432 | 73 | CRYPTOPP_ASSERT(m_allocated); | 433 | 73 | m_allocated = false; | 434 | 73 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 73 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 1.51k | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 1.51k | if (ptr == GetAlignedArray()) | 426 | 1.51k | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 1.51k | CRYPTOPP_ASSERT(size <= S); | 432 | 1.51k | CRYPTOPP_ASSERT(m_allocated); | 433 | 1.51k | m_allocated = false; | 434 | 1.51k | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 1.51k | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 1.51k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 757 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 757 | if (ptr == GetAlignedArray()) | 426 | 757 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 757 | CRYPTOPP_ASSERT(size <= S); | 432 | 757 | CRYPTOPP_ASSERT(m_allocated); | 433 | 757 | m_allocated = false; | 434 | 757 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 757 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 757 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 724 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 724 | if (ptr == GetAlignedArray()) | 426 | 724 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 724 | CRYPTOPP_ASSERT(size <= S); | 432 | 724 | CRYPTOPP_ASSERT(m_allocated); | 433 | 724 | m_allocated = false; | 434 | 724 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 724 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 724 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 369 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 369 | if (ptr == GetAlignedArray()) | 426 | 369 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 369 | CRYPTOPP_ASSERT(size <= S); | 432 | 369 | CRYPTOPP_ASSERT(m_allocated); | 433 | 369 | m_allocated = false; | 434 | 369 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 369 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 369 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 369 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 369 | if (ptr == GetAlignedArray()) | 426 | 369 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 369 | CRYPTOPP_ASSERT(size <= S); | 432 | 369 | CRYPTOPP_ASSERT(m_allocated); | 433 | 369 | m_allocated = false; | 434 | 369 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 369 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 369 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 355 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 355 | if (ptr == GetAlignedArray()) | 426 | 355 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 355 | CRYPTOPP_ASSERT(size <= S); | 432 | 355 | CRYPTOPP_ASSERT(m_allocated); | 433 | 355 | m_allocated = false; | 434 | 355 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 355 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 355 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 40 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 40 | if (ptr == GetAlignedArray()) | 426 | 40 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 40 | CRYPTOPP_ASSERT(size <= S); | 432 | 40 | CRYPTOPP_ASSERT(m_allocated); | 433 | 40 | m_allocated = false; | 434 | 40 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 40 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 40 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 80 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 80 | if (ptr == GetAlignedArray()) | 426 | 80 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 80 | CRYPTOPP_ASSERT(size <= S); | 432 | 80 | CRYPTOPP_ASSERT(m_allocated); | 433 | 80 | m_allocated = false; | 434 | 80 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 80 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 80 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true>::deallocate(void*, unsigned long) Line | Count | Source | 422 | 40 | { | 423 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 424 | | // pointers rather returning non-NULL 0-sized pointers. | 425 | 40 | if (ptr == GetAlignedArray()) | 426 | 40 | { | 427 | | // If the m_allocated assert fires then the bit twiddling for | 428 | | // GetAlignedArray() is probably incorrect for the platform. | 429 | | // Be sure to check CRYPTOPP_ALIGN_DATA(8). The platform may | 430 | | // not have a way to declaratively align data to 8. | 431 | 40 | CRYPTOPP_ASSERT(size <= S); | 432 | 40 | CRYPTOPP_ASSERT(m_allocated); | 433 | 40 | m_allocated = false; | 434 | 40 | SecureWipeArray(reinterpret_cast<pointer>(ptr), size); | 435 | 40 | } | 436 | 0 | else | 437 | 0 | { | 438 | 0 | if (ptr) | 439 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 440 | 0 | } | 441 | 40 | } |
|
442 | | |
443 | | /// \brief Reallocates a block of memory |
444 | | /// \param oldPtr the previous allocation |
445 | | /// \param oldSize the size of the previous allocation |
446 | | /// \param newSize the new, requested size |
447 | | /// \param preserve flag that indicates if the old allocation should |
448 | | /// be preserved |
449 | | /// \return pointer to the new memory block |
450 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
451 | | /// based allocation at compile time. If size is less than or equal to |
452 | | /// S, then a pointer to the static array is returned. |
453 | | /// \details The class can grow its memory block at runtime if a suitable |
454 | | /// allocator is available. If size grows beyond S and a suitable |
455 | | /// allocator is available, then the statically allocated array is |
456 | | /// obsoleted. If a suitable allocator is not available, as with a |
457 | | /// NullAllocator, then the function returns NULL and a runtime error |
458 | | /// eventually occurs. |
459 | | /// \note size is the count of elements, and not the number of bytes. |
460 | | /// \sa reallocate(), SecBlockWithHint |
461 | | pointer reallocate(pointer oldPtr, size_type oldSize, size_type newSize, bool preserve) |
462 | | { |
463 | | if (oldPtr == GetAlignedArray() && newSize <= S) |
464 | | { |
465 | | CRYPTOPP_ASSERT(oldSize <= S); |
466 | | if (oldSize > newSize) |
467 | | SecureWipeArray(oldPtr+newSize, oldSize-newSize); |
468 | | return oldPtr; |
469 | | } |
470 | | |
471 | | pointer newPtr = allocate(newSize, NULLPTR); |
472 | | if (preserve && newSize) |
473 | | { |
474 | | const size_type copySize = STDMIN(oldSize, newSize); |
475 | | if (newPtr && oldPtr) // GCC analyzer warning |
476 | | memcpy_s(newPtr, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize); |
477 | | } |
478 | | deallocate(oldPtr, oldSize); |
479 | | return newPtr; |
480 | | } |
481 | | |
482 | | CRYPTOPP_CONSTEXPR size_type max_size() const |
483 | | { |
484 | | return STDMAX(m_fallbackAllocator.max_size(), S); |
485 | | } |
486 | | |
487 | | private: |
488 | | |
489 | | #if CRYPTOPP_BOOL_ALIGN16 |
490 | | |
491 | | // There be demons here... We cannot use CRYPTOPP_ALIGN_DATA(16) |
492 | | // because linkers on 32-bit machines and some 64-bit machines |
493 | | // align the stack to 8-bytes or less, and not 16-bytes as |
494 | | // requested. We can only count on a smaller alignment. All |
495 | | // toolchains tested appear to honor CRYPTOPP_ALIGN_DATA(8). Also |
496 | | // see http://stackoverflow.com/a/1468656/608639. |
497 | | // |
498 | | // The 16-byte alignment is achieved by padding the requested |
499 | | // size with extra elements so we have at least 8-bytes of slack |
500 | | // to work with. Then the array pointer is moved to achieve a |
501 | | // 16-byte alignment. |
502 | | // |
503 | | // The additional 8-bytes introduces a small secondary issue. |
504 | | // The secondary issue is, a large T results in 0 = 8/sizeof(T). |
505 | | // The library is OK but users may hit it. So we need to guard |
506 | | // for a large T, and that is what the enum and PAD achieves. |
507 | 9.40k | T* GetAlignedArray() { |
508 | | |
509 | | // m_array is aligned on 8 byte boundaries due to |
510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer |
511 | | // is 16-byte aligned and nothing needs to be done. if |
512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and |
513 | | // we need to add 8. 8 has that nice symmetric property. |
514 | | // |
515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain |
516 | | // limitations, then the calculation would be slightly more |
517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; |
518 | 9.40k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); |
519 | 9.40k | int off = reinterpret_cast<uintptr_t>(m_array) % 16; |
520 | 9.40k | byte* ptr = reinterpret_cast<byte*>(m_array) + off; |
521 | | |
522 | | // Verify the 16-byte alignment. This is the point |
523 | | // of these extra gyrations. |
524 | 9.40k | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); |
525 | | // Verify the lower bound. This is Issue 982/988. |
526 | 9.40k | CRYPTOPP_ASSERT( |
527 | 9.40k | reinterpret_cast<uintptr_t>(ptr) >= |
528 | 9.40k | reinterpret_cast<uintptr_t>(m_array) |
529 | 9.40k | ); |
530 | | // Verify the upper bound. Allocated array with |
531 | | // pad is large enough. |
532 | 9.40k | CRYPTOPP_ASSERT( |
533 | 9.40k | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= |
534 | 9.40k | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) |
535 | 9.40k | ); |
536 | | |
537 | | // void* to silence Clang warnings |
538 | 9.40k | return reinterpret_cast<T*>( |
539 | 9.40k | static_cast<void*>(ptr) |
540 | 9.40k | ); |
541 | 9.40k | } CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true>::GetAlignedArray() Line | Count | Source | 507 | 766 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 766 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 766 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 766 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 766 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 766 | CRYPTOPP_ASSERT( | 527 | 766 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 766 | reinterpret_cast<uintptr_t>(m_array) | 529 | 766 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 766 | CRYPTOPP_ASSERT( | 533 | 766 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 766 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 766 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 766 | return reinterpret_cast<T*>( | 539 | 766 | static_cast<void*>(ptr) | 540 | 766 | ); | 541 | 766 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true>::GetAlignedArray() Line | Count | Source | 507 | 146 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 146 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 146 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 146 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 146 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 146 | CRYPTOPP_ASSERT( | 527 | 146 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 146 | reinterpret_cast<uintptr_t>(m_array) | 529 | 146 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 146 | CRYPTOPP_ASSERT( | 533 | 146 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 146 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 146 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 146 | return reinterpret_cast<T*>( | 539 | 146 | static_cast<void*>(ptr) | 540 | 146 | ); | 541 | 146 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true>::GetAlignedArray() Line | Count | Source | 507 | 3.02k | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 3.02k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 3.02k | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 3.02k | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 3.02k | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 3.02k | CRYPTOPP_ASSERT( | 527 | 3.02k | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 3.02k | reinterpret_cast<uintptr_t>(m_array) | 529 | 3.02k | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 3.02k | CRYPTOPP_ASSERT( | 533 | 3.02k | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 3.02k | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 3.02k | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 3.02k | return reinterpret_cast<T*>( | 539 | 3.02k | static_cast<void*>(ptr) | 540 | 3.02k | ); | 541 | 3.02k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true>::GetAlignedArray() Line | Count | Source | 507 | 1.51k | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 1.51k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 1.51k | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 1.51k | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 1.51k | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 1.51k | CRYPTOPP_ASSERT( | 527 | 1.51k | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 1.51k | reinterpret_cast<uintptr_t>(m_array) | 529 | 1.51k | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 1.51k | CRYPTOPP_ASSERT( | 533 | 1.51k | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 1.51k | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 1.51k | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 1.51k | return reinterpret_cast<T*>( | 539 | 1.51k | static_cast<void*>(ptr) | 540 | 1.51k | ); | 541 | 1.51k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true>::GetAlignedArray() Line | Count | Source | 507 | 1.44k | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 1.44k | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 1.44k | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 1.44k | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 1.44k | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 1.44k | CRYPTOPP_ASSERT( | 527 | 1.44k | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 1.44k | reinterpret_cast<uintptr_t>(m_array) | 529 | 1.44k | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 1.44k | CRYPTOPP_ASSERT( | 533 | 1.44k | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 1.44k | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 1.44k | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 1.44k | return reinterpret_cast<T*>( | 539 | 1.44k | static_cast<void*>(ptr) | 540 | 1.44k | ); | 541 | 1.44k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true>::GetAlignedArray() Line | Count | Source | 507 | 738 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 738 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 738 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 738 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 738 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 738 | CRYPTOPP_ASSERT( | 527 | 738 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 738 | reinterpret_cast<uintptr_t>(m_array) | 529 | 738 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 738 | CRYPTOPP_ASSERT( | 533 | 738 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 738 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 738 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 738 | return reinterpret_cast<T*>( | 539 | 738 | static_cast<void*>(ptr) | 540 | 738 | ); | 541 | 738 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true>::GetAlignedArray() Line | Count | Source | 507 | 738 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 738 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 738 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 738 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 738 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 738 | CRYPTOPP_ASSERT( | 527 | 738 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 738 | reinterpret_cast<uintptr_t>(m_array) | 529 | 738 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 738 | CRYPTOPP_ASSERT( | 533 | 738 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 738 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 738 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 738 | return reinterpret_cast<T*>( | 539 | 738 | static_cast<void*>(ptr) | 540 | 738 | ); | 541 | 738 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true>::GetAlignedArray() Line | Count | Source | 507 | 710 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 710 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 710 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 710 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 710 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 710 | CRYPTOPP_ASSERT( | 527 | 710 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 710 | reinterpret_cast<uintptr_t>(m_array) | 529 | 710 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 710 | CRYPTOPP_ASSERT( | 533 | 710 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 710 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 710 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 710 | return reinterpret_cast<T*>( | 539 | 710 | static_cast<void*>(ptr) | 540 | 710 | ); | 541 | 710 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true>::GetAlignedArray() Line | Count | Source | 507 | 80 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 80 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 80 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 80 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 80 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 80 | CRYPTOPP_ASSERT( | 527 | 80 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 80 | reinterpret_cast<uintptr_t>(m_array) | 529 | 80 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 80 | CRYPTOPP_ASSERT( | 533 | 80 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 80 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 80 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 80 | return reinterpret_cast<T*>( | 539 | 80 | static_cast<void*>(ptr) | 540 | 80 | ); | 541 | 80 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true>::GetAlignedArray() Line | Count | Source | 507 | 80 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 80 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 80 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 80 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 80 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 80 | CRYPTOPP_ASSERT( | 527 | 80 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 80 | reinterpret_cast<uintptr_t>(m_array) | 529 | 80 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 80 | CRYPTOPP_ASSERT( | 533 | 80 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 80 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 80 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 80 | return reinterpret_cast<T*>( | 539 | 80 | static_cast<void*>(ptr) | 540 | 80 | ); | 541 | 80 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true>::GetAlignedArray() Line | Count | Source | 507 | 160 | T* GetAlignedArray() { | 508 | | | 509 | | // m_array is aligned on 8 byte boundaries due to | 510 | | // CRYPTOPP_ALIGN_DATA(8). If m_array%16 is 0, then the buffer | 511 | | // is 16-byte aligned and nothing needs to be done. if | 512 | | // m_array%16 is 8, then the buffer is not 16-byte aligned and | 513 | | // we need to add 8. 8 has that nice symmetric property. | 514 | | // | 515 | | // If we needed to use CRYPTOPP_ALIGN_DATA(4) due to toolchain | 516 | | // limitations, then the calculation would be slightly more | 517 | | // costly: ptr = m_array + (16 - (m_array % 16)) % 16; | 518 | 160 | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); | 519 | 160 | int off = reinterpret_cast<uintptr_t>(m_array) % 16; | 520 | 160 | byte* ptr = reinterpret_cast<byte*>(m_array) + off; | 521 | | | 522 | | // Verify the 16-byte alignment. This is the point | 523 | | // of these extra gyrations. | 524 | 160 | CRYPTOPP_ASSERT(IsAlignedOn(ptr, 16)); | 525 | | // Verify the lower bound. This is Issue 982/988. | 526 | 160 | CRYPTOPP_ASSERT( | 527 | 160 | reinterpret_cast<uintptr_t>(ptr) >= | 528 | 160 | reinterpret_cast<uintptr_t>(m_array) | 529 | 160 | ); | 530 | | // Verify the upper bound. Allocated array with | 531 | | // pad is large enough. | 532 | 160 | CRYPTOPP_ASSERT( | 533 | 160 | reinterpret_cast<uintptr_t>(ptr+S*sizeof(T)) <= | 534 | 160 | reinterpret_cast<uintptr_t>(m_array+(S+PAD)) | 535 | 160 | ); | 536 | | | 537 | | // void* to silence Clang warnings | 538 | 160 | return reinterpret_cast<T*>( | 539 | 160 | static_cast<void*>(ptr) | 540 | 160 | ); | 541 | 160 | } |
|
542 | | |
543 | | // PAD is elements, not bytes, and rounded up to ensure no overflow. |
544 | | enum { Q = sizeof(T), PAD = (Q >= 8) ? 1 : (Q >= 4) ? 2 : (Q >= 2) ? 4 : 8 }; |
545 | | // enum { Q = sizeof(T), PAD = (Q >= 16) ? 1 : (Q >= 8) ? 2 : (Q >= 4) ? 4 : (Q >= 2) ? 8 : 16 }; |
546 | | CRYPTOPP_ALIGN_DATA(8) T m_array[S+PAD]; |
547 | | |
548 | | #else |
549 | | |
550 | | // CRYPTOPP_BOOL_ALIGN16 is 0. If we are here then the user |
551 | | // probably compiled with CRYPTOPP_DISABLE_ASM. Normally we |
552 | | // would use the natural alignment of T. The problem we are |
553 | | // having is, some toolchains are changing the boundary for |
554 | | // 64-bit arrays. 64-bit elements require 8-byte alignment, |
555 | | // but the toolchain is laying the array out on a 4 byte |
556 | | // boundary. See GH #992 for mystery alignment, |
557 | | // https://github.com/weidai11/cryptopp/issues/992 |
558 | | T* GetAlignedArray() {return m_array;} |
559 | | CRYPTOPP_ALIGN_DATA(8) T m_array[S]; |
560 | | |
561 | | #endif |
562 | | |
563 | | A m_fallbackAllocator; |
564 | | bool m_allocated; |
565 | | }; |
566 | | |
567 | | /// \brief Static secure memory block with cleanup |
568 | | /// \tparam T class or type |
569 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
570 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
571 | | /// based allocation at compile time. The class can grow its memory |
572 | | /// block at runtime if a suitable allocator is available. If size |
573 | | /// grows beyond S and a suitable allocator is available, then the |
574 | | /// statically allocated array is obsoleted. |
575 | | /// \note This allocator can't be used with standard collections because |
576 | | /// they require that all objects of the same allocator type are equivalent. |
577 | | template <class T, size_t S, class A> |
578 | | class FixedSizeAllocatorWithCleanup<T, S, A, false> : public AllocatorBase<T> |
579 | | { |
580 | | public: |
581 | | CRYPTOPP_INHERIT_ALLOCATOR_TYPES(T) |
582 | | |
583 | | /// \brief Constructs a FixedSizeAllocatorWithCleanup |
584 | 11.6k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 84 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 5.47k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 757 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 1.27k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 1.16k | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 339 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 467 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 35 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 70 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 69 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 807 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 74 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 73 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 73 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 139 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 49 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 49 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 144 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 43 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 43 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 53 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 53 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 178 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false>::FixedSizeAllocatorWithCleanup() Line | Count | Source | 584 | 187 | FixedSizeAllocatorWithCleanup() : m_allocated(false) {} |
Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false>::FixedSizeAllocatorWithCleanup() |
585 | | |
586 | | /// \brief Allocates a block of memory |
587 | | /// \param size the count elements in the memory block |
588 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack-based |
589 | | /// allocation at compile time. If size is less than or equal to |
590 | | /// <tt>S</tt>, then a pointer to the static array is returned. |
591 | | /// \details The class can grow its memory block at runtime if a suitable |
592 | | /// allocator is available. If size grows beyond S and a suitable |
593 | | /// allocator is available, then the statically allocated array is |
594 | | /// obsoleted. If a suitable allocator is not available, as with a |
595 | | /// NullAllocator, then the function returns NULL and a runtime error |
596 | | /// eventually occurs. |
597 | | /// \sa reallocate(), SecBlockWithHint |
598 | | pointer allocate(size_type size) |
599 | | { |
600 | | CRYPTOPP_ASSERT(IsAlignedOn(m_array, 8)); |
601 | | |
602 | | if (size <= S && !m_allocated) |
603 | | { |
604 | | m_allocated = true; |
605 | | return GetAlignedArray(); |
606 | | } |
607 | | else |
608 | | return m_fallbackAllocator.allocate(size); |
609 | | } |
610 | | |
611 | | /// \brief Allocates a block of memory |
612 | | /// \param size the count elements in the memory block |
613 | | /// \param hint an unused hint |
614 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
615 | | /// based allocation at compile time. If size is less than or equal to |
616 | | /// S, then a pointer to the static array is returned. |
617 | | /// \details The class can grow its memory block at runtime if a suitable |
618 | | /// allocator is available. If size grows beyond S and a suitable |
619 | | /// allocator is available, then the statically allocated array is |
620 | | /// obsoleted. If a suitable allocator is not available, as with a |
621 | | /// NullAllocator, then the function returns NULL and a runtime error |
622 | | /// eventually occurs. |
623 | | /// \sa reallocate(), SecBlockWithHint |
624 | | pointer allocate(size_type size, const void *hint) |
625 | 11.6k | { |
626 | 11.6k | if (size <= S && !m_allocated) |
627 | 11.6k | { |
628 | 11.6k | m_allocated = true; |
629 | 11.6k | return GetAlignedArray(); |
630 | 11.6k | } |
631 | 0 | else |
632 | 0 | return m_fallbackAllocator.allocate(size, hint); |
633 | 11.6k | } CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 84 | { | 626 | 84 | if (size <= S && !m_allocated) | 627 | 84 | { | 628 | 84 | m_allocated = true; | 629 | 84 | return GetAlignedArray(); | 630 | 84 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 84 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 5.47k | { | 626 | 5.47k | if (size <= S && !m_allocated) | 627 | 5.47k | { | 628 | 5.47k | m_allocated = true; | 629 | 5.47k | return GetAlignedArray(); | 630 | 5.47k | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 5.47k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 757 | { | 626 | 757 | if (size <= S && !m_allocated) | 627 | 757 | { | 628 | 757 | m_allocated = true; | 629 | 757 | return GetAlignedArray(); | 630 | 757 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 757 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 1.27k | { | 626 | 1.27k | if (size <= S && !m_allocated) | 627 | 1.27k | { | 628 | 1.27k | m_allocated = true; | 629 | 1.27k | return GetAlignedArray(); | 630 | 1.27k | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 1.27k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 1.16k | { | 626 | 1.16k | if (size <= S && !m_allocated) | 627 | 1.16k | { | 628 | 1.16k | m_allocated = true; | 629 | 1.16k | return GetAlignedArray(); | 630 | 1.16k | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 1.16k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 339 | { | 626 | 339 | if (size <= S && !m_allocated) | 627 | 339 | { | 628 | 339 | m_allocated = true; | 629 | 339 | return GetAlignedArray(); | 630 | 339 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 339 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 467 | { | 626 | 467 | if (size <= S && !m_allocated) | 627 | 467 | { | 628 | 467 | m_allocated = true; | 629 | 467 | return GetAlignedArray(); | 630 | 467 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 467 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 35 | { | 626 | 35 | if (size <= S && !m_allocated) | 627 | 35 | { | 628 | 35 | m_allocated = true; | 629 | 35 | return GetAlignedArray(); | 630 | 35 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 35 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 70 | { | 626 | 70 | if (size <= S && !m_allocated) | 627 | 70 | { | 628 | 70 | m_allocated = true; | 629 | 70 | return GetAlignedArray(); | 630 | 70 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 70 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 69 | { | 626 | 69 | if (size <= S && !m_allocated) | 627 | 69 | { | 628 | 69 | m_allocated = true; | 629 | 69 | return GetAlignedArray(); | 630 | 69 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 69 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 807 | { | 626 | 807 | if (size <= S && !m_allocated) | 627 | 807 | { | 628 | 807 | m_allocated = true; | 629 | 807 | return GetAlignedArray(); | 630 | 807 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 807 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 74 | { | 626 | 74 | if (size <= S && !m_allocated) | 627 | 74 | { | 628 | 74 | m_allocated = true; | 629 | 74 | return GetAlignedArray(); | 630 | 74 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 74 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 73 | { | 626 | 73 | if (size <= S && !m_allocated) | 627 | 73 | { | 628 | 73 | m_allocated = true; | 629 | 73 | return GetAlignedArray(); | 630 | 73 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 73 | { | 626 | 73 | if (size <= S && !m_allocated) | 627 | 73 | { | 628 | 73 | m_allocated = true; | 629 | 73 | return GetAlignedArray(); | 630 | 73 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 139 | { | 626 | 139 | if (size <= S && !m_allocated) | 627 | 139 | { | 628 | 139 | m_allocated = true; | 629 | 139 | return GetAlignedArray(); | 630 | 139 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 139 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 49 | { | 626 | 49 | if (size <= S && !m_allocated) | 627 | 49 | { | 628 | 49 | m_allocated = true; | 629 | 49 | return GetAlignedArray(); | 630 | 49 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 49 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 49 | { | 626 | 49 | if (size <= S && !m_allocated) | 627 | 49 | { | 628 | 49 | m_allocated = true; | 629 | 49 | return GetAlignedArray(); | 630 | 49 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 49 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 144 | { | 626 | 144 | if (size <= S && !m_allocated) | 627 | 144 | { | 628 | 144 | m_allocated = true; | 629 | 144 | return GetAlignedArray(); | 630 | 144 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 144 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 43 | { | 626 | 43 | if (size <= S && !m_allocated) | 627 | 43 | { | 628 | 43 | m_allocated = true; | 629 | 43 | return GetAlignedArray(); | 630 | 43 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 43 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 43 | { | 626 | 43 | if (size <= S && !m_allocated) | 627 | 43 | { | 628 | 43 | m_allocated = true; | 629 | 43 | return GetAlignedArray(); | 630 | 43 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 43 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 53 | { | 626 | 53 | if (size <= S && !m_allocated) | 627 | 53 | { | 628 | 53 | m_allocated = true; | 629 | 53 | return GetAlignedArray(); | 630 | 53 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 53 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 53 | { | 626 | 53 | if (size <= S && !m_allocated) | 627 | 53 | { | 628 | 53 | m_allocated = true; | 629 | 53 | return GetAlignedArray(); | 630 | 53 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 53 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 178 | { | 626 | 178 | if (size <= S && !m_allocated) | 627 | 178 | { | 628 | 178 | m_allocated = true; | 629 | 178 | return GetAlignedArray(); | 630 | 178 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 178 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false>::allocate(unsigned long, void const*) Line | Count | Source | 625 | 187 | { | 626 | 187 | if (size <= S && !m_allocated) | 627 | 187 | { | 628 | 187 | m_allocated = true; | 629 | 187 | return GetAlignedArray(); | 630 | 187 | } | 631 | 0 | else | 632 | 0 | return m_fallbackAllocator.allocate(size, hint); | 633 | 187 | } |
Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 64ul, CryptoPP::NullAllocator<unsigned short>, false>::allocate(unsigned long, void const*) Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false>::allocate(unsigned long, void const*) |
634 | | |
635 | | /// \brief Deallocates a block of memory |
636 | | /// \param ptr a pointer to the memory block to deallocate |
637 | | /// \param size the count elements in the memory block |
638 | | /// \details The memory block is wiped or zeroized before deallocation. |
639 | | /// If the statically allocated memory block is active, then no |
640 | | /// additional actions are taken after the wipe. |
641 | | /// \details If a dynamic memory block is active, then the pointer and |
642 | | /// size are passed to the allocator for deallocation. |
643 | | void deallocate(void *ptr, size_type size) |
644 | 11.6k | { |
645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL |
646 | | // pointers rather returning non-NULL 0-sized pointers. |
647 | 11.6k | if (ptr == GetAlignedArray()) |
648 | 11.6k | { |
649 | | // If the m_allocated assert fires then |
650 | | // something overwrote the flag. |
651 | 11.6k | CRYPTOPP_ASSERT(size <= S); |
652 | 11.6k | CRYPTOPP_ASSERT(m_allocated); |
653 | 11.6k | m_allocated = false; |
654 | 11.6k | SecureWipeArray((pointer)ptr, size); |
655 | 11.6k | } |
656 | 0 | else |
657 | 0 | { |
658 | 0 | if (ptr) |
659 | 0 | m_fallbackAllocator.deallocate(ptr, size); |
660 | 0 | m_allocated = false; |
661 | 0 | } |
662 | 11.6k | } CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 84 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 84 | if (ptr == GetAlignedArray()) | 648 | 84 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 84 | CRYPTOPP_ASSERT(size <= S); | 652 | 84 | CRYPTOPP_ASSERT(m_allocated); | 653 | 84 | m_allocated = false; | 654 | 84 | SecureWipeArray((pointer)ptr, size); | 655 | 84 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 84 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 5.47k | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 5.47k | if (ptr == GetAlignedArray()) | 648 | 5.47k | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 5.47k | CRYPTOPP_ASSERT(size <= S); | 652 | 5.47k | CRYPTOPP_ASSERT(m_allocated); | 653 | 5.47k | m_allocated = false; | 654 | 5.47k | SecureWipeArray((pointer)ptr, size); | 655 | 5.47k | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 5.47k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 757 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 757 | if (ptr == GetAlignedArray()) | 648 | 757 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 757 | CRYPTOPP_ASSERT(size <= S); | 652 | 757 | CRYPTOPP_ASSERT(m_allocated); | 653 | 757 | m_allocated = false; | 654 | 757 | SecureWipeArray((pointer)ptr, size); | 655 | 757 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 757 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 1.27k | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 1.27k | if (ptr == GetAlignedArray()) | 648 | 1.27k | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 1.27k | CRYPTOPP_ASSERT(size <= S); | 652 | 1.27k | CRYPTOPP_ASSERT(m_allocated); | 653 | 1.27k | m_allocated = false; | 654 | 1.27k | SecureWipeArray((pointer)ptr, size); | 655 | 1.27k | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 1.27k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 1.16k | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 1.16k | if (ptr == GetAlignedArray()) | 648 | 1.16k | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 1.16k | CRYPTOPP_ASSERT(size <= S); | 652 | 1.16k | CRYPTOPP_ASSERT(m_allocated); | 653 | 1.16k | m_allocated = false; | 654 | 1.16k | SecureWipeArray((pointer)ptr, size); | 655 | 1.16k | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 1.16k | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 339 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 339 | if (ptr == GetAlignedArray()) | 648 | 339 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 339 | CRYPTOPP_ASSERT(size <= S); | 652 | 339 | CRYPTOPP_ASSERT(m_allocated); | 653 | 339 | m_allocated = false; | 654 | 339 | SecureWipeArray((pointer)ptr, size); | 655 | 339 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 339 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 467 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 467 | if (ptr == GetAlignedArray()) | 648 | 467 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 467 | CRYPTOPP_ASSERT(size <= S); | 652 | 467 | CRYPTOPP_ASSERT(m_allocated); | 653 | 467 | m_allocated = false; | 654 | 467 | SecureWipeArray((pointer)ptr, size); | 655 | 467 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 467 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 70 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 70 | if (ptr == GetAlignedArray()) | 648 | 70 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 70 | CRYPTOPP_ASSERT(size <= S); | 652 | 70 | CRYPTOPP_ASSERT(m_allocated); | 653 | 70 | m_allocated = false; | 654 | 70 | SecureWipeArray((pointer)ptr, size); | 655 | 70 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 70 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 35 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 35 | if (ptr == GetAlignedArray()) | 648 | 35 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 35 | CRYPTOPP_ASSERT(size <= S); | 652 | 35 | CRYPTOPP_ASSERT(m_allocated); | 653 | 35 | m_allocated = false; | 654 | 35 | SecureWipeArray((pointer)ptr, size); | 655 | 35 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 35 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 69 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 69 | if (ptr == GetAlignedArray()) | 648 | 69 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 69 | CRYPTOPP_ASSERT(size <= S); | 652 | 69 | CRYPTOPP_ASSERT(m_allocated); | 653 | 69 | m_allocated = false; | 654 | 69 | SecureWipeArray((pointer)ptr, size); | 655 | 69 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 69 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 807 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 807 | if (ptr == GetAlignedArray()) | 648 | 807 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 807 | CRYPTOPP_ASSERT(size <= S); | 652 | 807 | CRYPTOPP_ASSERT(m_allocated); | 653 | 807 | m_allocated = false; | 654 | 807 | SecureWipeArray((pointer)ptr, size); | 655 | 807 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 807 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 74 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 74 | if (ptr == GetAlignedArray()) | 648 | 74 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 74 | CRYPTOPP_ASSERT(size <= S); | 652 | 74 | CRYPTOPP_ASSERT(m_allocated); | 653 | 74 | m_allocated = false; | 654 | 74 | SecureWipeArray((pointer)ptr, size); | 655 | 74 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 74 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 73 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 73 | if (ptr == GetAlignedArray()) | 648 | 73 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 73 | CRYPTOPP_ASSERT(size <= S); | 652 | 73 | CRYPTOPP_ASSERT(m_allocated); | 653 | 73 | m_allocated = false; | 654 | 73 | SecureWipeArray((pointer)ptr, size); | 655 | 73 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 73 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 73 | if (ptr == GetAlignedArray()) | 648 | 73 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 73 | CRYPTOPP_ASSERT(size <= S); | 652 | 73 | CRYPTOPP_ASSERT(m_allocated); | 653 | 73 | m_allocated = false; | 654 | 73 | SecureWipeArray((pointer)ptr, size); | 655 | 73 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 73 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 139 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 139 | if (ptr == GetAlignedArray()) | 648 | 139 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 139 | CRYPTOPP_ASSERT(size <= S); | 652 | 139 | CRYPTOPP_ASSERT(m_allocated); | 653 | 139 | m_allocated = false; | 654 | 139 | SecureWipeArray((pointer)ptr, size); | 655 | 139 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 139 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 49 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 49 | if (ptr == GetAlignedArray()) | 648 | 49 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 49 | CRYPTOPP_ASSERT(size <= S); | 652 | 49 | CRYPTOPP_ASSERT(m_allocated); | 653 | 49 | m_allocated = false; | 654 | 49 | SecureWipeArray((pointer)ptr, size); | 655 | 49 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 49 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 49 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 49 | if (ptr == GetAlignedArray()) | 648 | 49 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 49 | CRYPTOPP_ASSERT(size <= S); | 652 | 49 | CRYPTOPP_ASSERT(m_allocated); | 653 | 49 | m_allocated = false; | 654 | 49 | SecureWipeArray((pointer)ptr, size); | 655 | 49 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 49 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 144 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 144 | if (ptr == GetAlignedArray()) | 648 | 144 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 144 | CRYPTOPP_ASSERT(size <= S); | 652 | 144 | CRYPTOPP_ASSERT(m_allocated); | 653 | 144 | m_allocated = false; | 654 | 144 | SecureWipeArray((pointer)ptr, size); | 655 | 144 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 144 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 43 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 43 | if (ptr == GetAlignedArray()) | 648 | 43 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 43 | CRYPTOPP_ASSERT(size <= S); | 652 | 43 | CRYPTOPP_ASSERT(m_allocated); | 653 | 43 | m_allocated = false; | 654 | 43 | SecureWipeArray((pointer)ptr, size); | 655 | 43 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 43 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 43 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 43 | if (ptr == GetAlignedArray()) | 648 | 43 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 43 | CRYPTOPP_ASSERT(size <= S); | 652 | 43 | CRYPTOPP_ASSERT(m_allocated); | 653 | 43 | m_allocated = false; | 654 | 43 | SecureWipeArray((pointer)ptr, size); | 655 | 43 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 43 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 53 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 53 | if (ptr == GetAlignedArray()) | 648 | 53 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 53 | CRYPTOPP_ASSERT(size <= S); | 652 | 53 | CRYPTOPP_ASSERT(m_allocated); | 653 | 53 | m_allocated = false; | 654 | 53 | SecureWipeArray((pointer)ptr, size); | 655 | 53 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 53 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 53 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 53 | if (ptr == GetAlignedArray()) | 648 | 53 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 53 | CRYPTOPP_ASSERT(size <= S); | 652 | 53 | CRYPTOPP_ASSERT(m_allocated); | 653 | 53 | m_allocated = false; | 654 | 53 | SecureWipeArray((pointer)ptr, size); | 655 | 53 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 53 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 178 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 178 | if (ptr == GetAlignedArray()) | 648 | 178 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 178 | CRYPTOPP_ASSERT(size <= S); | 652 | 178 | CRYPTOPP_ASSERT(m_allocated); | 653 | 178 | m_allocated = false; | 654 | 178 | SecureWipeArray((pointer)ptr, size); | 655 | 178 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 178 | } |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Line | Count | Source | 644 | 187 | { | 645 | | // Avoid assert on pointer in deallocate. SecBlock regularly uses NULL | 646 | | // pointers rather returning non-NULL 0-sized pointers. | 647 | 187 | if (ptr == GetAlignedArray()) | 648 | 187 | { | 649 | | // If the m_allocated assert fires then | 650 | | // something overwrote the flag. | 651 | 187 | CRYPTOPP_ASSERT(size <= S); | 652 | 187 | CRYPTOPP_ASSERT(m_allocated); | 653 | 187 | m_allocated = false; | 654 | 187 | SecureWipeArray((pointer)ptr, size); | 655 | 187 | } | 656 | 0 | else | 657 | 0 | { | 658 | 0 | if (ptr) | 659 | 0 | m_fallbackAllocator.deallocate(ptr, size); | 660 | 0 | m_allocated = false; | 661 | 0 | } | 662 | 187 | } |
Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 64ul, CryptoPP::NullAllocator<unsigned short>, false>::deallocate(void*, unsigned long) Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 96ul, CryptoPP::NullAllocator<unsigned int>, false>::deallocate(void*, unsigned long) Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false>::deallocate(void*, unsigned long) |
663 | | |
664 | | /// \brief Reallocates a block of memory |
665 | | /// \param oldPtr the previous allocation |
666 | | /// \param oldSize the size of the previous allocation |
667 | | /// \param newSize the new, requested size |
668 | | /// \param preserve flag that indicates if the old allocation should |
669 | | /// be preserved |
670 | | /// \return pointer to the new memory block |
671 | | /// \details FixedSizeAllocatorWithCleanup provides a fixed-size, stack- |
672 | | /// based allocation at compile time. If size is less than or equal to |
673 | | /// S, then a pointer to the static array is returned. |
674 | | /// \details The class can grow its memory block at runtime if a suitable |
675 | | /// allocator is available. If size grows beyond S and a suitable |
676 | | /// allocator is available, then the statically allocated array is |
677 | | /// obsoleted. If a suitable allocator is not available, as with a |
678 | | /// NullAllocator, then the function returns NULL and a runtime error |
679 | | /// eventually occurs. |
680 | | /// \note size is the count of elements, and not the number of bytes. |
681 | | /// \sa reallocate(), SecBlockWithHint |
682 | | pointer reallocate(pointer oldPtr, size_type oldSize, size_type newSize, bool preserve) |
683 | 9 | { |
684 | 9 | if (oldPtr == GetAlignedArray() && newSize <= S) |
685 | 9 | { |
686 | 9 | CRYPTOPP_ASSERT(oldSize <= S); |
687 | 9 | if (oldSize > newSize) |
688 | 0 | SecureWipeArray(oldPtr+newSize, oldSize-newSize); |
689 | 9 | return oldPtr; |
690 | 9 | } |
691 | | |
692 | 0 | pointer newPtr = allocate(newSize, NULLPTR); |
693 | 0 | if (preserve && newSize) |
694 | 0 | { |
695 | 0 | const size_type copySize = STDMIN(oldSize, newSize); |
696 | 0 | if (newPtr && oldPtr) // GCC analyzer warning |
697 | 0 | memcpy_s(newPtr, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize); |
698 | 0 | } |
699 | 0 | deallocate(oldPtr, oldSize); |
700 | 0 | return newPtr; |
701 | 9 | } |
702 | | |
703 | | CRYPTOPP_CONSTEXPR size_type max_size() const |
704 | | { |
705 | | return STDMAX(m_fallbackAllocator.max_size(), S); |
706 | | } |
707 | | |
708 | | private: |
709 | | |
710 | | // T_Align16 is false. Normally we would use the natural |
711 | | // alignment of T. The problem we are having is, some toolchains |
712 | | // are changing the boundary for 64-bit arrays. 64-bit elements |
713 | | // require 8-byte alignment, but the toolchain is laying the array |
714 | | // out on a 4 byte boundary. See GH #992 for mystery alignment, |
715 | | // https://github.com/weidai11/cryptopp/issues/992 |
716 | 23.3k | T* GetAlignedArray() {return m_array;} CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false>::GetAlignedArray() Line | Count | Source | 716 | 168 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 10.9k | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 1.51k | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 2.54k | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 2.32k | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 678 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 934 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 70 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 140 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false>::GetAlignedArray() Line | Count | Source | 716 | 138 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 1.61k | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false>::GetAlignedArray() Line | Count | Source | 716 | 157 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 146 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 146 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 278 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 98 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false>::GetAlignedArray() Line | Count | Source | 716 | 98 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 288 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false>::GetAlignedArray() Line | Count | Source | 716 | 86 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false>::GetAlignedArray() Line | Count | Source | 716 | 86 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 106 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 106 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false>::GetAlignedArray() Line | Count | Source | 716 | 356 | T* GetAlignedArray() {return m_array;} |
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Line | Count | Source | 716 | 374 | T* GetAlignedArray() {return m_array;} |
Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 64ul, CryptoPP::NullAllocator<unsigned short>, false>::GetAlignedArray() Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 96ul, CryptoPP::NullAllocator<unsigned int>, false>::GetAlignedArray() Unexecuted instantiation: CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false>::GetAlignedArray() |
717 | | CRYPTOPP_ALIGN_DATA(8) T m_array[S]; |
718 | | |
719 | | A m_fallbackAllocator; |
720 | | bool m_allocated; |
721 | | }; |
722 | | |
723 | | /// \brief Secure memory block with allocator and cleanup |
724 | | /// \tparam T a class or type |
725 | | /// \tparam A AllocatorWithCleanup derived class for allocation and cleanup |
726 | | /// \sa <A HREF="https://www.cryptopp.com/wiki/SecBlock">SecBlock</A> |
727 | | /// on the Crypto++ wiki. |
728 | | /// \since Crypto++ 2.0 |
729 | | template <class T, class A = AllocatorWithCleanup<T> > |
730 | | class SecBlock |
731 | | { |
732 | | public: |
733 | | typedef typename A::value_type value_type; |
734 | | typedef typename A::pointer iterator; |
735 | | typedef typename A::const_pointer const_iterator; |
736 | | typedef typename A::size_type size_type; |
737 | | |
738 | | /// \brief Returns the maximum number of elements the block can hold |
739 | | /// \details <tt>ELEMS_MAX</tt> is the maximum number of elements the |
740 | | /// <tt>SecBlock</tt> can hold. The value of <tt>ELEMS_MAX</tt> is |
741 | | /// <tt>SIZE_MAX/sizeof(T)</tt>. <tt>std::numeric_limits</tt> was avoided |
742 | | /// due to lack of <tt>constexpr</tt>-ness in C++03 and below. |
743 | | /// \note In C++03 and below <tt>ELEMS_MAX</tt> is a static data member of type |
744 | | /// <tt>size_type</tt>. In C++11 and above <tt>ELEMS_MAX</tt> is an <tt>enum</tt> |
745 | | /// inheriting from <tt>size_type</tt>. In both cases <tt>ELEMS_MAX</tt> can be |
746 | | /// used before objects are fully constructed, and it does not suffer the |
747 | | /// limitations of class methods like <tt>max_size</tt>. |
748 | | /// \sa <A HREF="http://github.com/weidai11/cryptopp/issues/346">Issue 346/CVE-2016-9939</A> |
749 | | /// \since Crypto++ 6.0 |
750 | | #if defined(CRYPTOPP_DOXYGEN_PROCESSING) |
751 | | static const size_type ELEMS_MAX = ...; |
752 | | #elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION <= 1400) |
753 | | static const size_type ELEMS_MAX = (~(size_type)0)/sizeof(T); |
754 | | #elif defined(CRYPTOPP_CXX11_STRONG_ENUM) |
755 | | enum : size_type {ELEMS_MAX = A::ELEMS_MAX}; |
756 | | #else |
757 | | static const size_type ELEMS_MAX = SIZE_MAX/sizeof(T); |
758 | | #endif |
759 | | |
760 | | /// \brief Construct a SecBlock with space for size elements. |
761 | | /// \param size the size of the allocation, in elements |
762 | | /// \throw std::bad_alloc |
763 | | /// \details The elements are not initialized. |
764 | | /// \since Crypto++ 2.0 |
765 | | /// \note size is the count of elements, and not the number of bytes |
766 | | explicit SecBlock(size_type size=0) |
767 | 84.5M | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 2.89k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 646 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 84 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 10.4M | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 5.47k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 1.51k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 757 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 757 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 1.27k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 1.16k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 339 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 467 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 35 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 70 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 69 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 40 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 40 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 80 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 73 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 74.0M | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 807 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 74 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 762 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 73 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 73 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 139 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 49 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 49 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 49 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 144 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 43 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 43 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 53 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 53 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 178 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 187 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 536 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 383 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 724 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 355 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 369 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true> >::SecBlock(unsigned long) Line | Count | Source | 767 | 369 | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(unsigned long) CryptoPP::SecBlock<char, CryptoPP::AllocatorWithCleanup<char, false> >::SecBlock(unsigned long) Line | Count | Source | 767 | 7.68k | : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } |
|
768 | | |
769 | | /// \brief Copy construct a SecBlock from another SecBlock |
770 | | /// \param t the other SecBlock |
771 | | /// \throw std::bad_alloc |
772 | | /// \since Crypto++ 2.0 |
773 | | SecBlock(const SecBlock<T, A> &t) |
774 | 5.09M | : m_mark(t.m_mark), m_size(t.m_size), m_ptr(m_alloc.allocate(t.m_size, NULLPTR)) { |
775 | 5.09M | CRYPTOPP_ASSERT((!t.m_ptr && !m_size) || (t.m_ptr && m_size)); |
776 | 5.09M | if (m_ptr && t.m_ptr) |
777 | 0 | memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); |
778 | 5.09M | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> > const&) CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SecBlock(CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> > const&) Line | Count | Source | 774 | 5.09M | : m_mark(t.m_mark), m_size(t.m_size), m_ptr(m_alloc.allocate(t.m_size, NULLPTR)) { | 775 | 5.09M | CRYPTOPP_ASSERT((!t.m_ptr && !m_size) || (t.m_ptr && m_size)); | 776 | 5.09M | if (m_ptr && t.m_ptr) | 777 | 0 | memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); | 778 | 5.09M | } |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::SecBlock(CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::SecBlock(CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::SecBlock(CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> >::SecBlock(CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::SecBlock(CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::SecBlock(CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> > const&) Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::SecBlock(CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> > const&) |
779 | | |
780 | | /// \brief Construct a SecBlock from an array of elements. |
781 | | /// \param ptr a pointer to an array of T |
782 | | /// \param len the number of elements in the memory block |
783 | | /// \throw std::bad_alloc |
784 | | /// \details If <tt>ptr!=NULL</tt> and <tt>len!=0</tt>, then the block is initialized from the pointer |
785 | | /// <tt>ptr</tt>. If <tt>ptr==NULL</tt> and <tt>len!=0</tt>, then the block is initialized to 0. |
786 | | /// Otherwise, the block is empty and not initialized. |
787 | | /// \since Crypto++ 2.0 |
788 | | /// \note size is the count of elements, and not the number of bytes |
789 | | SecBlock(const T *ptr, size_type len) |
790 | 262 | : m_mark(ELEMS_MAX), m_size(len), m_ptr(m_alloc.allocate(len, NULLPTR)) { |
791 | 262 | CRYPTOPP_ASSERT((!m_ptr && !m_size) || (m_ptr && m_size)); |
792 | 262 | if (m_ptr && ptr) |
793 | 226 | memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); |
794 | 36 | else if (m_ptr && m_size) |
795 | 36 | std::memset(m_ptr, 0, m_size*sizeof(T)); |
796 | 262 | } CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SecBlock(unsigned char const*, unsigned long) Line | Count | Source | 790 | 36 | : m_mark(ELEMS_MAX), m_size(len), m_ptr(m_alloc.allocate(len, NULLPTR)) { | 791 | 36 | CRYPTOPP_ASSERT((!m_ptr && !m_size) || (m_ptr && m_size)); | 792 | 36 | if (m_ptr && ptr) | 793 | 0 | memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); | 794 | 36 | else if (m_ptr && m_size) | 795 | 36 | std::memset(m_ptr, 0, m_size*sizeof(T)); | 796 | 36 | } |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::SecBlock(unsigned long const*, unsigned long) Line | Count | Source | 790 | 226 | : m_mark(ELEMS_MAX), m_size(len), m_ptr(m_alloc.allocate(len, NULLPTR)) { | 791 | 226 | CRYPTOPP_ASSERT((!m_ptr && !m_size) || (m_ptr && m_size)); | 792 | 226 | if (m_ptr && ptr) | 793 | 226 | memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); | 794 | 0 | else if (m_ptr && m_size) | 795 | 0 | std::memset(m_ptr, 0, m_size*sizeof(T)); | 796 | 226 | } |
|
797 | | |
798 | | ~SecBlock() |
799 | 89.6M | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::~SecBlock() Line | Count | Source | 799 | 2.89k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::~SecBlock() Line | Count | Source | 799 | 646 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::~SecBlock() Line | Count | Source | 799 | 383 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::~SecBlock() Line | Count | Source | 799 | 73 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::~SecBlock() Line | Count | Source | 799 | 84 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::~SecBlock() Line | Count | Source | 799 | 74.0M | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::~SecBlock() Line | Count | Source | 799 | 15.5M | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 5.47k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> >::~SecBlock() Line | Count | Source | 799 | 1.51k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 757 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> >::~SecBlock() Line | Count | Source | 799 | 757 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 1.27k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 1.16k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::~SecBlock() Line | Count | Source | 799 | 724 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true> >::~SecBlock() Line | Count | Source | 799 | 369 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::~SecBlock() Line | Count | Source | 799 | 369 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::~SecBlock() Line | Count | Source | 799 | 355 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 339 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 467 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 70 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 35 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::~SecBlock() Line | Count | Source | 799 | 69 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> >::~SecBlock() Line | Count | Source | 799 | 40 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> >::~SecBlock() Line | Count | Source | 799 | 80 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> >::~SecBlock() Line | Count | Source | 799 | 40 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 807 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::~SecBlock() Line | Count | Source | 799 | 74 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::~SecBlock() Line | Count | Source | 799 | 762 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 73 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 73 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 139 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 49 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::~SecBlock() Line | Count | Source | 799 | 49 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::~SecBlock() Line | Count | Source | 799 | 49 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 144 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::~SecBlock() Line | Count | Source | 799 | 43 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> >::~SecBlock() Line | Count | Source | 799 | 43 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 53 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 53 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::~SecBlock() Line | Count | Source | 799 | 178 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Line | Count | Source | 799 | 187 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::~SecBlock() Line | Count | Source | 799 | 496 | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 96ul, CryptoPP::NullAllocator<unsigned int>, false> >::~SecBlock() Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false> >::~SecBlock() CryptoPP::SecBlock<char, CryptoPP::AllocatorWithCleanup<char, false> >::~SecBlock() Line | Count | Source | 799 | 7.68k | {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} |
|
800 | | |
801 | | #ifdef __BORLANDC__ |
802 | | /// \brief Cast operator |
803 | | /// \return block pointer cast to non-const <tt>T *</tt> |
804 | | /// \since Crypto++ 2.0 |
805 | | operator T *() const |
806 | | {return (T*)m_ptr;} |
807 | | #else |
808 | | /// \brief Cast operator |
809 | | /// \return block pointer cast to <tt>const void *</tt> |
810 | | /// \since Crypto++ 2.0 |
811 | | operator const void *() const |
812 | 9 | {return m_ptr;} Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::operator void const*() const Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::operator void const*() const CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator void const*() const Line | Count | Source | 812 | 9 | {return m_ptr;} |
|
813 | | |
814 | | /// \brief Cast operator |
815 | | /// \return block pointer cast to non-const <tt>void *</tt> |
816 | | /// \since Crypto++ 2.0 |
817 | | operator void *() |
818 | 8.95M | {return m_ptr;} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::operator void*() Line | Count | Source | 818 | 8.75M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::operator void*() Line | Count | Source | 818 | 20.9k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::operator void*() Line | Count | Source | 818 | 11.4k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator void*() Line | Count | Source | 818 | 738 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator void*() Line | Count | Source | 818 | 738 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::operator void*() Line | Count | Source | 818 | 149 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator void*() Line | Count | Source | 818 | 20 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator void*() Line | Count | Source | 818 | 20 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator void*() Line | Count | Source | 818 | 10 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator void*() Line | Count | Source | 818 | 138k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator void*() Line | Count | Source | 818 | 55 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator void*() Line | Count | Source | 818 | 27.1k | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator void*() |
819 | | |
820 | | /// \brief Cast operator |
821 | | /// \return block pointer cast to <tt>const T *</tt> |
822 | | /// \since Crypto++ 2.0 |
823 | | operator const T *() const |
824 | 738M | {return m_ptr;} CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::operator unsigned long const*() const Line | Count | Source | 824 | 9.43k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 18.6k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 18.6k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 33.0k | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 96ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 2.59k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char const*() const Line | Count | Source | 824 | 10 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::operator unsigned char const*() const Line | Count | Source | 824 | 842k | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char const*() const Line | Count | Source | 824 | 379k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long const*() const Line | Count | Source | 824 | 62 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::operator unsigned long const*() const Line | Count | Source | 824 | 737M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::operator unsigned int const*() const Line | Count | Source | 824 | 934 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::operator unsigned short const*() const Line | Count | Source | 824 | 256 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 136k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int const*() const Line | Count | Source | 824 | 23.9k | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char const*() const |
825 | | |
826 | | /// \brief Cast operator |
827 | | /// \return block pointer cast to non-const <tt>T *</tt> |
828 | | /// \since Crypto++ 2.0 |
829 | | operator T *() |
830 | 4.11G | {return m_ptr;} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::operator unsigned char*() Line | Count | Source | 830 | 3.46G | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 5.56M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> >::operator unsigned int*() Line | Count | Source | 830 | 388k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> >::operator unsigned long*() Line | Count | Source | 830 | 726k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 208k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 1.47M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 97.1k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 129k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 6.25k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char*() Line | Count | Source | 830 | 203 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 348k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator unsigned char*() Line | Count | Source | 830 | 43.3k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator unsigned char*() Line | Count | Source | 830 | 152k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::operator unsigned char*() Line | Count | Source | 830 | 6.33k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::operator unsigned int*() Line | Count | Source | 830 | 2.93k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator unsigned char*() Line | Count | Source | 830 | 67.9k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 756 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 20.4k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 2.89k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 2.91k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 1.11M | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 96ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> >::operator unsigned int*() Line | Count | Source | 830 | 1.39k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::operator unsigned short*() Line | Count | Source | 830 | 16 | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::operator unsigned short*() CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::operator unsigned int*() Line | Count | Source | 830 | 6.73k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 64 | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char*() CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::operator unsigned long*() Line | Count | Source | 830 | 3.77k | {return m_ptr;} |
CryptoPP::SecBlock<char, CryptoPP::AllocatorWithCleanup<char, false> >::operator char*() Line | Count | Source | 830 | 6.39M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char*() Line | Count | Source | 830 | 9.92k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 3.17k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::operator unsigned long*() Line | Count | Source | 830 | 635M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator unsigned long*() Line | Count | Source | 830 | 1.29M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::operator unsigned char*() Line | Count | Source | 830 | 64 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> >::operator unsigned int*() Line | Count | Source | 830 | 352 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> >::operator unsigned int*() Line | Count | Source | 830 | 309 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> >::operator unsigned short*() Line | Count | Source | 830 | 1.61k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::operator unsigned short*() Line | Count | Source | 830 | 96 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 287k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 132 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::operator unsigned int*() Line | Count | Source | 830 | 690 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::operator unsigned char*() Line | Count | Source | 830 | 8.03k | {return m_ptr;} |
|
831 | | #endif |
832 | | |
833 | | /// \brief Provides an iterator pointing to the first element in the memory block |
834 | | /// \return iterator pointing to the first element in the memory block |
835 | | /// \since Crypto++ 2.0 |
836 | | iterator begin() |
837 | 2.10M | {return m_ptr;} CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false> >::begin() Line | Count | Source | 837 | 12 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::begin() Line | Count | Source | 837 | 4.28k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::begin() Line | Count | Source | 837 | 188 | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::begin() Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::begin() CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::begin() Line | Count | Source | 837 | 640 | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::begin() Line | Count | Source | 837 | 8.85k | {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::begin() Line | Count | Source | 837 | 2.09M | {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::begin() Line | Count | Source | 837 | 16 | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::begin() Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::begin() |
838 | | /// \brief Provides a constant iterator pointing to the first element in the memory block |
839 | | /// \return constant iterator pointing to the first element in the memory block |
840 | | /// \since Crypto++ 2.0 |
841 | | const_iterator begin() const |
842 | 640 | {return m_ptr;} Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::begin() const Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::begin() const Unexecuted instantiation: CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::begin() const CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::begin() const Line | Count | Source | 842 | 640 | {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::begin() const |
843 | | /// \brief Provides an iterator pointing beyond the last element in the memory block |
844 | | /// \return iterator pointing beyond the last element in the memory block |
845 | | /// \since Crypto++ 2.0 |
846 | | iterator end() |
847 | 3.95k | {return m_ptr+m_size;} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::end() Line | Count | Source | 847 | 3.95k | {return m_ptr+m_size;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::end() |
848 | | /// \brief Provides a constant iterator pointing beyond the last element in the memory block |
849 | | /// \return constant iterator pointing beyond the last element in the memory block |
850 | | /// \since Crypto++ 2.0 |
851 | | const_iterator end() const |
852 | 841 | {return m_ptr+m_size;} Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::end() const CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::end() const Line | Count | Source | 852 | 841 | {return m_ptr+m_size;} |
|
853 | | |
854 | | /// \brief Provides a pointer to the first element in the memory block |
855 | | /// \return pointer to the first element in the memory block |
856 | | /// \since Crypto++ 2.0 |
857 | 6.12M | typename A::pointer data() {return m_ptr;} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::data() Line | Count | Source | 857 | 28 | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() Line | Count | Source | 857 | 40.4k | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() Line | Count | Source | 857 | 21.5k | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::data() Line | Count | Source | 857 | 2.96M | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::data() Line | Count | Source | 857 | 3.10M | typename A::pointer data() {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::data() Line | Count | Source | 857 | 17 | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::data() Line | Count | Source | 857 | 160 | typename A::pointer data() {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::data() Line | Count | Source | 857 | 517 | typename A::pointer data() {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::data() Line | Count | Source | 857 | 6 | typename A::pointer data() {return m_ptr;} |
|
858 | | /// \brief Provides a pointer to the first element in the memory block |
859 | | /// \return constant pointer to the first element in the memory block |
860 | | /// \since Crypto++ 2.0 |
861 | 33.1k | typename A::const_pointer data() const {return m_ptr;} CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() const Line | Count | Source | 861 | 20.2k | typename A::const_pointer data() const {return m_ptr;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::data() const Line | Count | Source | 861 | 10.7k | typename A::const_pointer data() const {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::data() const Line | Count | Source | 861 | 198 | typename A::const_pointer data() const {return m_ptr;} |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::data() const Line | Count | Source | 861 | 2.00k | typename A::const_pointer data() const {return m_ptr;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::data() const |
862 | | |
863 | | /// \brief Provides the count of elements in the SecBlock |
864 | | /// \return number of elements in the memory block |
865 | | /// \note the return value is the count of elements, and not the number of bytes |
866 | | /// \since Crypto++ 2.0 |
867 | 610M | size_type size() const {return m_size;} CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::size() const Line | Count | Source | 867 | 9.61M | size_type size() const {return m_size;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::size() const Line | Count | Source | 867 | 710 | size_type size() const {return m_size;} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::size() const Line | Count | Source | 867 | 738 | size_type size() const {return m_size;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::size() const Line | Count | Source | 867 | 600M | size_type size() const {return m_size;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::size() const Line | Count | Source | 867 | 20 | size_type size() const {return m_size;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false> >::size() const CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::size() const Line | Count | Source | 867 | 1.60k | size_type size() const {return m_size;} |
Unexecuted instantiation: CryptoPP::SecBlock<char, CryptoPP::AllocatorWithCleanup<char, false> >::size() const CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::size() const Line | Count | Source | 867 | 3.09k | size_type size() const {return m_size;} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::size() const Line | Count | Source | 867 | 66.4k | size_type size() const {return m_size;} |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::size() const |
868 | | /// \brief Determines if the SecBlock is empty |
869 | | /// \return true if number of elements in the memory block is 0, false otherwise |
870 | | /// \since Crypto++ 2.0 |
871 | 0 | bool empty() const {return m_size == 0;} |
872 | | |
873 | | /// \brief Provides a byte pointer to the first element in the memory block |
874 | | /// \return byte pointer to the first element in the memory block |
875 | | /// \since Crypto++ 2.0 |
876 | 1.48M | byte * BytePtr() {return (byte *)m_ptr;} |
877 | | /// \brief Return a byte pointer to the first element in the memory block |
878 | | /// \return constant byte pointer to the first element in the memory block |
879 | | /// \since Crypto++ 2.0 |
880 | | const byte * BytePtr() const {return (const byte *)m_ptr;} |
881 | | /// \brief Provides the number of bytes in the SecBlock |
882 | | /// \return the number of bytes in the memory block |
883 | | /// \note the return value is the number of bytes, and not count of elements. |
884 | | /// \since Crypto++ 2.0 |
885 | 102k | size_type SizeInBytes() const {return m_size*sizeof(T);} CryptoPP::SecBlock<unsigned int, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::SizeInBytes() const Line | Count | Source | 885 | 20.9k | size_type SizeInBytes() const {return m_size*sizeof(T);} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::SizeInBytes() const Line | Count | Source | 885 | 11.4k | size_type SizeInBytes() const {return m_size*sizeof(T);} |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SizeInBytes() const Line | Count | Source | 885 | 39 | size_type SizeInBytes() const {return m_size*sizeof(T);} |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::SizeInBytes() const Line | Count | Source | 885 | 69.8k | size_type SizeInBytes() const {return m_size*sizeof(T);} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::SizeInBytes() const Line | Count | Source | 885 | 28 | size_type SizeInBytes() const {return m_size*sizeof(T);} |
CryptoPP::SecBlock<unsigned char, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::SizeInBytes() const Line | Count | Source | 885 | 28 | size_type SizeInBytes() const {return m_size*sizeof(T);} |
|
886 | | |
887 | | /// \brief Set contents and size from an array |
888 | | /// \param ptr a pointer to an array of T |
889 | | /// \param len the number of elements in the memory block |
890 | | /// \details The array pointed to by <tt>ptr</tt> must be distinct |
891 | | /// from this SecBlock because Assign() calls New() and then std::memcpy(). |
892 | | /// The call to New() will invalidate all pointers and iterators, like |
893 | | /// the pointer returned from data(). |
894 | | /// \details If the memory block is reduced in size, then the reclaimed |
895 | | /// memory is set to 0. If an assignment occurs, then Assign() resets |
896 | | /// the element count after the previous block is zeroized. |
897 | | /// \since Crypto++ 2.0 |
898 | | void Assign(const T *ptr, size_type len) |
899 | 118 | { |
900 | 118 | New(len); |
901 | 118 | if (m_ptr && ptr) // GCC analyzer warning |
902 | 115 | memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); |
903 | 118 | m_mark = ELEMS_MAX; |
904 | 118 | } |
905 | | |
906 | | /// \brief Set contents from a value |
907 | | /// \param count the number of values to copy |
908 | | /// \param value the value, repeated count times |
909 | | /// \details If the memory block is reduced in size, then the reclaimed |
910 | | /// memory is set to 0. If an assignment occurs, then Assign() resets |
911 | | /// the element count after the previous block is zeroized. |
912 | | /// \since Crypto++ 6.0 |
913 | | void Assign(size_type count, T value) |
914 | | { |
915 | | New(count); |
916 | | for (size_t i=0; i<count; ++i) |
917 | | m_ptr[i] = value; |
918 | | m_mark = ELEMS_MAX; |
919 | | } |
920 | | |
921 | | /// \brief Copy contents from another SecBlock |
922 | | /// \param t the other SecBlock |
923 | | /// \details Assign checks for self assignment. |
924 | | /// \details If the memory block is reduced in size, then the reclaimed |
925 | | /// memory is set to 0. If an assignment occurs, then Assign() resets |
926 | | /// the element count after the previous block is zeroized. |
927 | | /// \since Crypto++ 2.0 |
928 | | void Assign(const SecBlock<T, A> &t) |
929 | 5.09M | { |
930 | 5.09M | if (this != &t) |
931 | 5.09M | { |
932 | 5.09M | New(t.m_size); |
933 | 5.09M | if (m_ptr && t.m_ptr) // GCC analyzer warning |
934 | 9 | memcpy_s(m_ptr, m_size*sizeof(T), t, t.m_size*sizeof(T)); |
935 | 5.09M | } |
936 | 5.09M | m_mark = ELEMS_MAX; |
937 | 5.09M | } CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::Assign(CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> > const&) Line | Count | Source | 929 | 5.09M | { | 930 | 5.09M | if (this != &t) | 931 | 5.09M | { | 932 | 5.09M | New(t.m_size); | 933 | 5.09M | if (m_ptr && t.m_ptr) // GCC analyzer warning | 934 | 0 | memcpy_s(m_ptr, m_size*sizeof(T), t, t.m_size*sizeof(T)); | 935 | 5.09M | } | 936 | 5.09M | m_mark = ELEMS_MAX; | 937 | 5.09M | } |
Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::Assign(CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> > const&) CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::Assign(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> > const&) Line | Count | Source | 929 | 9 | { | 930 | 9 | if (this != &t) | 931 | 9 | { | 932 | 9 | New(t.m_size); | 933 | 9 | if (m_ptr && t.m_ptr) // GCC analyzer warning | 934 | 9 | memcpy_s(m_ptr, m_size*sizeof(T), t, t.m_size*sizeof(T)); | 935 | 9 | } | 936 | 9 | m_mark = ELEMS_MAX; | 937 | 9 | } |
|
938 | | |
939 | | /// \brief Append contents from an array |
940 | | /// \param ptr a pointer to an array of T |
941 | | /// \param len the number of elements in the memory block |
942 | | /// \throw InvalidArgument if resulting size would overflow |
943 | | /// \details The array pointed to by <tt>ptr</tt> must be distinct |
944 | | /// from this SecBlock because Append() calls Grow() and then std::memcpy(). |
945 | | /// The call to Grow() will invalidate all pointers and iterators, like |
946 | | /// the pointer returned from data(). |
947 | | /// \details Append() may be less efficient than a ByteQueue because |
948 | | /// Append() must Grow() the internal array and then copy elements. |
949 | | /// The ByteQueue can copy elements without growing. |
950 | | /// \sa ByteQueue |
951 | | /// \since Crypto++ 8.6 |
952 | | void Append(const T *ptr, size_type len) |
953 | | { |
954 | | if (ELEMS_MAX - m_size < len) |
955 | | throw InvalidArgument("SecBlock: buffer overflow"); |
956 | | |
957 | | const size_type oldSize = m_size; |
958 | | Grow(m_size+len); |
959 | | if (m_ptr && ptr) // GCC analyzer warning |
960 | | memcpy_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), ptr, len*sizeof(T)); |
961 | | m_mark = ELEMS_MAX; |
962 | | } |
963 | | |
964 | | /// \brief Append contents from another SecBlock |
965 | | /// \param t the other SecBlock |
966 | | /// \throw InvalidArgument if resulting size would overflow |
967 | | /// \details Internally, this SecBlock calls Grow() and then appends t. |
968 | | /// \details Append() may be less efficient than a ByteQueue because |
969 | | /// Append() must Grow() the internal array and then copy elements. |
970 | | /// The ByteQueue can copy elements without growing. |
971 | | /// \sa ByteQueue |
972 | | /// \since Crypto++ 8.6 |
973 | | void Append(const SecBlock<T, A> &t) |
974 | | { |
975 | | if (ELEMS_MAX - m_size < t.m_size) |
976 | | throw InvalidArgument("SecBlock: buffer overflow"); |
977 | | |
978 | | const size_type oldSize = m_size; |
979 | | if (this != &t) // s += t |
980 | | { |
981 | | Grow(m_size+t.m_size); |
982 | | if (m_ptr && t.m_ptr) // GCC analyzer warning |
983 | | memcpy_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); |
984 | | } |
985 | | else // t += t |
986 | | { |
987 | | Grow(m_size*2); |
988 | | if (m_ptr) // GCC analyzer warning |
989 | | memmove_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), m_ptr, oldSize*sizeof(T)); |
990 | | } |
991 | | m_mark = ELEMS_MAX; |
992 | | } |
993 | | |
994 | | /// \brief Append contents from a value |
995 | | /// \param count the number of values to copy |
996 | | /// \param value the value, repeated count times |
997 | | /// \throw InvalidArgument if resulting size would overflow |
998 | | /// \details Internally, this SecBlock calls Grow() and then appends value. |
999 | | /// \details Append() may be less efficient than a ByteQueue because |
1000 | | /// Append() must Grow() the internal array and then copy elements. |
1001 | | /// The ByteQueue can copy elements without growing. |
1002 | | /// \sa ByteQueue |
1003 | | /// \since Crypto++ 8.6 |
1004 | | void Append(size_type count, T value) |
1005 | | { |
1006 | | if (ELEMS_MAX - m_size < count) |
1007 | | throw InvalidArgument("SecBlock: buffer overflow"); |
1008 | | |
1009 | | const size_type oldSize = m_size; |
1010 | | Grow(m_size+count); |
1011 | | for (size_t i=oldSize; i<oldSize+count; ++i) |
1012 | | m_ptr[i] = value; |
1013 | | m_mark = ELEMS_MAX; |
1014 | | } |
1015 | | |
1016 | | /// \brief Sets the number of elements to zeroize |
1017 | | /// \param count the number of elements |
1018 | | /// \details SetMark is a remediation for Issue 346/CVE-2016-9939 while |
1019 | | /// preserving the streaming interface. The <tt>count</tt> controls the number of |
1020 | | /// elements zeroized, which can be less than <tt>size</tt> or 0. |
1021 | | /// \details An internal variable, <tt>m_mark</tt>, is initialized to the maximum number |
1022 | | /// of elements. The maximum number of elements is <tt>ELEMS_MAX</tt>. Deallocation |
1023 | | /// triggers a zeroization, and the number of elements zeroized is |
1024 | | /// <tt>STDMIN(m_size, m_mark)</tt>. After zeroization, the memory is returned to the |
1025 | | /// system. |
1026 | | /// \details The ASN.1 decoder uses SetMark() to set the element count to 0 |
1027 | | /// before throwing an exception. In this case, the attacker provides a large |
1028 | | /// BER encoded length (say 64MB) but only a small number of content octets |
1029 | | /// (say 16). If the allocator zeroized all 64MB, then a transient DoS could |
1030 | | /// occur as CPU cycles are spent zeroizing uninitialized memory. |
1031 | | /// \details Generally speaking, any operation which changes the size of the SecBlock |
1032 | | /// results in the mark being reset to <tt>ELEMS_MAX</tt>. In particular, if Assign(), |
1033 | | /// New(), Grow(), CleanNew(), CleanGrow() are called, then the count is reset to |
1034 | | /// <tt>ELEMS_MAX</tt>. The list is not exhaustive. |
1035 | | /// \since Crypto++ 6.0 |
1036 | | /// \sa <A HREF="http://github.com/weidai11/cryptopp/issues/346">Issue 346/CVE-2016-9939</A> |
1037 | 169 | void SetMark(size_t count) {m_mark = count;} |
1038 | | |
1039 | | /// \brief Assign contents from another SecBlock |
1040 | | /// \param t the other SecBlock |
1041 | | /// \return reference to this SecBlock |
1042 | | /// \details Internally, operator=() calls Assign(). |
1043 | | /// \details If the memory block is reduced in size, then the reclaimed |
1044 | | /// memory is set to 0. If an assignment occurs, then Assign() resets |
1045 | | /// the element count after the previous block is zeroized. |
1046 | | /// \since Crypto++ 2.0 |
1047 | | SecBlock<T, A>& operator=(const SecBlock<T, A> &t) |
1048 | 5.09M | { |
1049 | | // Assign guards for self-assignment |
1050 | 5.09M | Assign(t); |
1051 | 5.09M | return *this; |
1052 | 5.09M | } CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::operator=(CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> > const&) Line | Count | Source | 1048 | 5.09M | { | 1049 | | // Assign guards for self-assignment | 1050 | 5.09M | Assign(t); | 1051 | 5.09M | return *this; | 1052 | 5.09M | } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::operator=(CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> > const&) Line | Count | Source | 1048 | 9 | { | 1049 | | // Assign guards for self-assignment | 1050 | 9 | Assign(t); | 1051 | 9 | return *this; | 1052 | 9 | } |
|
1053 | | |
1054 | | /// \brief Append contents from another SecBlock |
1055 | | /// \param t the other SecBlock |
1056 | | /// \return reference to this SecBlock |
1057 | | /// \details Internally, operator+=() calls Append(). |
1058 | | /// \since Crypto++ 2.0 |
1059 | | SecBlock<T, A>& operator+=(const SecBlock<T, A> &t) |
1060 | | { |
1061 | | // Append guards for overflow |
1062 | | Append(t); |
1063 | | return *this; |
1064 | | } |
1065 | | |
1066 | | /// \brief Construct a SecBlock from this and another SecBlock |
1067 | | /// \param t the other SecBlock |
1068 | | /// \return a newly constructed SecBlock that is a concatenation of this |
1069 | | /// and t. |
1070 | | /// \details Internally, a new SecBlock is created from this and a |
1071 | | /// concatenation of t. |
1072 | | /// \since Crypto++ 2.0 |
1073 | | SecBlock<T, A> operator+(const SecBlock<T, A> &t) |
1074 | | { |
1075 | | CRYPTOPP_ASSERT((!m_ptr && !m_size) || (m_ptr && m_size)); |
1076 | | CRYPTOPP_ASSERT((!t.m_ptr && !t.m_size) || (t.m_ptr && t.m_size)); |
1077 | | if(!t.m_size) return SecBlock(*this); |
1078 | | |
1079 | | SecBlock<T, A> result(m_size+t.m_size); |
1080 | | if (m_size) |
1081 | | memcpy_s(result.m_ptr, result.m_size*sizeof(T), m_ptr, m_size*sizeof(T)); |
1082 | | if (result.m_ptr && t.m_ptr) // GCC analyzer warning |
1083 | | memcpy_s(result.m_ptr+m_size, (result.m_size-m_size)*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); |
1084 | | return result; |
1085 | | } |
1086 | | |
1087 | | /// \brief Bitwise compare two SecBlocks |
1088 | | /// \param t the other SecBlock |
1089 | | /// \return true if the size and bits are equal, false otherwise |
1090 | | /// \details Uses a constant time compare if the arrays are equal size. |
1091 | | /// The constant time compare is VerifyBufsEqual() found in |
1092 | | /// <tt>misc.h</tt>. |
1093 | | /// \sa operator!=() |
1094 | | /// \since Crypto++ 2.0 |
1095 | | bool operator==(const SecBlock<T, A> &t) const |
1096 | 0 | { |
1097 | 0 | return m_size == t.m_size && VerifyBufsEqual( |
1098 | 0 | reinterpret_cast<const byte*>(m_ptr), |
1099 | 0 | reinterpret_cast<const byte*>(t.m_ptr), m_size*sizeof(T)); |
1100 | 0 | } |
1101 | | |
1102 | | /// \brief Bitwise compare two SecBlocks |
1103 | | /// \param t the other SecBlock |
1104 | | /// \return true if the size and bits are equal, false otherwise |
1105 | | /// \details Uses a constant time compare if the arrays are equal size. |
1106 | | /// The constant time compare is VerifyBufsEqual() found in |
1107 | | /// <tt>misc.h</tt>. |
1108 | | /// \details Internally, operator!=() returns the inverse of operator==(). |
1109 | | /// \sa operator==() |
1110 | | /// \since Crypto++ 2.0 |
1111 | | bool operator!=(const SecBlock<T, A> &t) const |
1112 | 0 | { |
1113 | 0 | return !operator==(t); |
1114 | 0 | } |
1115 | | |
1116 | | /// \brief Change size without preserving contents |
1117 | | /// \param newSize the new size of the memory block |
1118 | | /// \details Old content is not preserved. If the memory block is |
1119 | | /// reduced in size, then the reclaimed content is set to 0. If the |
1120 | | /// memory block grows in size, then the new memory is initialized |
1121 | | /// to 0. New() resets the element count after the previous block |
1122 | | /// is zeroized. |
1123 | | /// \details Internally, this SecBlock calls reallocate(). |
1124 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1125 | | /// \since Crypto++ 2.0 |
1126 | | void New(size_type newSize) |
1127 | 46.8M | { |
1128 | 46.8M | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); |
1129 | 46.8M | m_size = newSize; |
1130 | 46.8M | m_mark = ELEMS_MAX; |
1131 | 46.8M | } CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::New(unsigned long) Line | Count | Source | 1127 | 5.23M | { | 1128 | 5.23M | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 5.23M | m_size = newSize; | 1130 | 5.23M | m_mark = ELEMS_MAX; | 1131 | 5.23M | } |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, true> >::New(unsigned long) Line | Count | Source | 1127 | 243 | { | 1128 | 243 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 243 | m_size = newSize; | 1130 | 243 | m_mark = ELEMS_MAX; | 1131 | 243 | } |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::New(unsigned long) Line | Count | Source | 1127 | 256 | { | 1128 | 256 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 256 | m_size = newSize; | 1130 | 256 | m_mark = ELEMS_MAX; | 1131 | 256 | } |
CryptoPP::SecBlock<unsigned int, CryptoPP::AllocatorWithCleanup<unsigned int, false> >::New(unsigned long) Line | Count | Source | 1127 | 191 | { | 1128 | 191 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 191 | m_size = newSize; | 1130 | 191 | m_mark = ELEMS_MAX; | 1131 | 191 | } |
CryptoPP::SecBlock<unsigned short, CryptoPP::AllocatorWithCleanup<unsigned short, false> >::New(unsigned long) Line | Count | Source | 1127 | 1 | { | 1128 | 1 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 1 | m_size = newSize; | 1130 | 1 | m_mark = ELEMS_MAX; | 1131 | 1 | } |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::New(unsigned long) Line | Count | Source | 1127 | 300 | { | 1128 | 300 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 300 | m_size = newSize; | 1130 | 300 | m_mark = ELEMS_MAX; | 1131 | 300 | } |
CryptoPP::SecBlock<unsigned long, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::New(unsigned long) Line | Count | Source | 1127 | 9 | { | 1128 | 9 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 9 | m_size = newSize; | 1130 | 9 | m_mark = ELEMS_MAX; | 1131 | 9 | } |
CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::New(unsigned long) Line | Count | Source | 1127 | 41.5M | { | 1128 | 41.5M | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); | 1129 | 41.5M | m_size = newSize; | 1130 | 41.5M | m_mark = ELEMS_MAX; | 1131 | 41.5M | } |
|
1132 | | |
1133 | | /// \brief Change size without preserving contents |
1134 | | /// \param newSize the new size of the memory block |
1135 | | /// \details Old content is not preserved. If the memory block is |
1136 | | /// reduced in size, then the reclaimed content is set to 0. If the |
1137 | | /// memory block grows in size, then the new memory is initialized |
1138 | | /// to 0. CleanNew() resets the element count after the previous |
1139 | | /// block is zeroized. |
1140 | | /// \details Internally, this SecBlock calls New(). |
1141 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1142 | | /// \since Crypto++ 2.0 |
1143 | | void CleanNew(size_type newSize) |
1144 | 27.1M | { |
1145 | 27.1M | New(newSize); |
1146 | 27.1M | if (m_ptr) {memset_z(m_ptr, 0, m_size*sizeof(T));} |
1147 | 27.1M | m_mark = ELEMS_MAX; |
1148 | 27.1M | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::CleanNew(unsigned long) CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::CleanNew(unsigned long) Line | Count | Source | 1144 | 27.1M | { | 1145 | 27.1M | New(newSize); | 1146 | 27.1M | if (m_ptr) {memset_z(m_ptr, 0, m_size*sizeof(T));} | 1147 | 27.1M | m_mark = ELEMS_MAX; | 1148 | 27.1M | } |
|
1149 | | |
1150 | | /// \brief Change size and preserve contents |
1151 | | /// \param newSize the new size of the memory block |
1152 | | /// \details Old content is preserved. New content is not initialized. |
1153 | | /// \details Internally, this SecBlock calls reallocate() when size must |
1154 | | /// increase. If the size does not increase, then CleanGrow() does not |
1155 | | /// take action. If the size must change, then use resize(). CleanGrow() |
1156 | | /// resets the element count after the previous block is zeroized. |
1157 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1158 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1159 | | /// \since Crypto++ 2.0 |
1160 | | void Grow(size_type newSize) |
1161 | 0 | { |
1162 | 0 | if (newSize > m_size) |
1163 | 0 | { |
1164 | 0 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); |
1165 | 0 | m_size = newSize; |
1166 | 0 | } |
1167 | 0 | m_mark = ELEMS_MAX; |
1168 | 0 | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::Grow(unsigned long) Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::Grow(unsigned long) Unexecuted instantiation: CryptoPP::SecBlock<char, CryptoPP::AllocatorWithCleanup<char, false> >::Grow(unsigned long) |
1169 | | |
1170 | | /// \brief Change size and preserve contents |
1171 | | /// \param newSize the new size of the memory block |
1172 | | /// \details Old content is preserved. New content is initialized to 0. |
1173 | | /// \details Internally, this SecBlock calls reallocate() when size must |
1174 | | /// increase. If the size does not increase, then CleanGrow() does not |
1175 | | /// take action. If the size must change, then use resize(). CleanGrow() |
1176 | | /// resets the element count after the previous block is zeroized. |
1177 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1178 | | /// \since Crypto++ 2.0 |
1179 | | void CleanGrow(size_type newSize) |
1180 | 15.6M | { |
1181 | 15.6M | if (newSize > m_size) |
1182 | 2.35M | { |
1183 | 2.35M | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); |
1184 | 2.35M | memset_z(m_ptr+m_size, 0, (newSize-m_size)*sizeof(T)); |
1185 | 2.35M | m_size = newSize; |
1186 | 2.35M | } |
1187 | 15.6M | m_mark = ELEMS_MAX; |
1188 | 15.6M | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::CleanGrow(unsigned long) CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::CleanGrow(unsigned long) Line | Count | Source | 1180 | 15.6M | { | 1181 | 15.6M | if (newSize > m_size) | 1182 | 2.35M | { | 1183 | 2.35M | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); | 1184 | 2.35M | memset_z(m_ptr+m_size, 0, (newSize-m_size)*sizeof(T)); | 1185 | 2.35M | m_size = newSize; | 1186 | 2.35M | } | 1187 | 15.6M | m_mark = ELEMS_MAX; | 1188 | 15.6M | } |
|
1189 | | |
1190 | | /// \brief Change size and preserve contents |
1191 | | /// \param newSize the new size of the memory block |
1192 | | /// \details Old content is preserved. If the memory block grows in size, then |
1193 | | /// new memory is not initialized. resize() resets the element count after |
1194 | | /// the previous block is zeroized. |
1195 | | /// \details Internally, this SecBlock calls reallocate(). |
1196 | | /// \sa New(), CleanNew(), Grow(), CleanGrow(), resize() |
1197 | | /// \since Crypto++ 2.0 |
1198 | | void resize(size_type newSize) |
1199 | 6.11k | { |
1200 | 6.11k | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); |
1201 | 6.11k | m_size = newSize; |
1202 | 6.11k | m_mark = ELEMS_MAX; |
1203 | 6.11k | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::resize(unsigned long) CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, true> >::resize(unsigned long) Line | Count | Source | 1199 | 808 | { | 1200 | 808 | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); | 1201 | 808 | m_size = newSize; | 1202 | 808 | m_mark = ELEMS_MAX; | 1203 | 808 | } |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::resize(unsigned long) Line | Count | Source | 1199 | 5.30k | { | 1200 | 5.30k | m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); | 1201 | 5.30k | m_size = newSize; | 1202 | 5.30k | m_mark = ELEMS_MAX; | 1203 | 5.30k | } |
|
1204 | | |
1205 | | /// \brief Swap contents with another SecBlock |
1206 | | /// \param b the other SecBlock |
1207 | | /// \details Internally, std::swap() is called on m_alloc, m_size and m_ptr. |
1208 | | /// \since Crypto++ 2.0 |
1209 | | void swap(SecBlock<T, A> &b) |
1210 | 3.71M | { |
1211 | | // Swap must occur on the allocator in case its FixedSize that spilled into the heap. |
1212 | 3.71M | std::swap(m_alloc, b.m_alloc); |
1213 | 3.71M | std::swap(m_mark, b.m_mark); |
1214 | 3.71M | std::swap(m_size, b.m_size); |
1215 | 3.71M | std::swap(m_ptr, b.m_ptr); |
1216 | 3.71M | } Unexecuted instantiation: CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >::swap(CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, false> >&) CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >::swap(CryptoPP::SecBlock<unsigned long, CryptoPP::AllocatorWithCleanup<unsigned long, true> >&) Line | Count | Source | 1210 | 3.71M | { | 1211 | | // Swap must occur on the allocator in case its FixedSize that spilled into the heap. | 1212 | 3.71M | std::swap(m_alloc, b.m_alloc); | 1213 | 3.71M | std::swap(m_mark, b.m_mark); | 1214 | 3.71M | std::swap(m_size, b.m_size); | 1215 | 3.71M | std::swap(m_ptr, b.m_ptr); | 1216 | 3.71M | } |
CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::swap(CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >&) Line | Count | Source | 1210 | 124 | { | 1211 | | // Swap must occur on the allocator in case its FixedSize that spilled into the heap. | 1212 | 124 | std::swap(m_alloc, b.m_alloc); | 1213 | 124 | std::swap(m_mark, b.m_mark); | 1214 | 124 | std::swap(m_size, b.m_size); | 1215 | 124 | std::swap(m_ptr, b.m_ptr); | 1216 | 124 | } |
|
1217 | | |
1218 | | protected: |
1219 | | A m_alloc; |
1220 | | size_type m_mark, m_size; |
1221 | | T *m_ptr; |
1222 | | }; |
1223 | | |
1224 | | #ifdef CRYPTOPP_DOXYGEN_PROCESSING |
1225 | | /// \brief \ref SecBlock "SecBlock<byte>" typedef. |
1226 | | class SecByteBlock : public SecBlock<byte> {}; |
1227 | | /// \brief \ref SecBlock "SecBlock<word>" typedef. |
1228 | | class SecWordBlock : public SecBlock<word> {}; |
1229 | | /// \brief SecBlock using \ref AllocatorWithCleanup "AllocatorWithCleanup<byte, true>" typedef |
1230 | | class AlignedSecByteBlock : public SecBlock<byte, AllocatorWithCleanup<byte, true> > {}; |
1231 | | #else |
1232 | | typedef SecBlock<byte> SecByteBlock; |
1233 | | typedef SecBlock<word> SecWordBlock; |
1234 | | typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedSecByteBlock; |
1235 | | #endif |
1236 | | |
1237 | | // No need for move semantics on derived class *if* the class does not add any |
1238 | | // data members; see http://stackoverflow.com/q/31755703, and Rule of {0|3|5}. |
1239 | | |
1240 | | /// \brief Fixed size stack-based SecBlock |
1241 | | /// \tparam T class or type |
1242 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
1243 | | /// \tparam A AllocatorBase derived class for allocation and cleanup |
1244 | | template <class T, unsigned int S, class A = FixedSizeAllocatorWithCleanup<T, S> > |
1245 | | class FixedSizeSecBlock : public SecBlock<T, A> |
1246 | | { |
1247 | | public: |
1248 | | /// \brief Construct a FixedSizeSecBlock |
1249 | 16.3k | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} CryptoPP::FixedSizeSecBlock<unsigned char, 32u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 84 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 16u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 5.47k | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 16u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 16ul, CryptoPP::NullAllocator<unsigned int>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 1.51k | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 16u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 757 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 16u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 16ul, CryptoPP::NullAllocator<unsigned long>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 757 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 25u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 25ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 1.27k | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 8u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 8ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 1.16k | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 82u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 82ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 339 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 82u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 82ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 467 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 4u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 4ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 35 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 2u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 2ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 70 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 8u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 8ul, CryptoPP::NullAllocator<unsigned char>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 69 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 24u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 24ul, CryptoPP::NullAllocator<unsigned int>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 40 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 5u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 40 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 4u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 80 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 16u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 16ul, CryptoPP::NullAllocator<unsigned char>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 73 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 32u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 32ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 807 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 52u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 52ul, CryptoPP::NullAllocator<unsigned long>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 74 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 18u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 18ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 73 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 1024u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 1024ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 73 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 3u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 3ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 139 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 36u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 36ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 49 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned short, 4u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 4ul, CryptoPP::NullAllocator<unsigned short>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 49 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 4u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 4ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 144 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned short, 32u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 32ul, CryptoPP::NullAllocator<unsigned short>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 43 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned short, 5u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned short, 5ul, CryptoPP::NullAllocator<unsigned short>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 43 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 44u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 44ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 53 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 5u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 5ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 53 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 136u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 136ul, CryptoPP::NullAllocator<unsigned char>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 178 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 8u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 8ul, CryptoPP::NullAllocator<unsigned int>, false> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 187 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 32u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 32ul, CryptoPP::NullAllocator<unsigned char>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 383 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 64u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 64ul, CryptoPP::NullAllocator<unsigned char>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 724 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned int, 12u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned int, 12ul, CryptoPP::NullAllocator<unsigned int>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 355 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned long, 12u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned long, 12ul, CryptoPP::NullAllocator<unsigned long>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 369 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
CryptoPP::FixedSizeSecBlock<unsigned char, 128u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 128ul, CryptoPP::NullAllocator<unsigned char>, true> >::FixedSizeSecBlock() Line | Count | Source | 1249 | 369 | explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} |
Unexecuted instantiation: CryptoPP::FixedSizeSecBlock<unsigned char, 256u, CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char, 256ul, CryptoPP::NullAllocator<unsigned char>, false> >::FixedSizeSecBlock() Unexecuted instantiation: CryptoPP::FixedSizeSecBlock<unsigned char, 64u, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::FixedSizeSecBlock() Unexecuted instantiation: CryptoPP::FixedSizeSecBlock<unsigned char, 20u, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::FixedSizeSecBlock() |
1250 | | }; |
1251 | | |
1252 | | /// \brief Fixed size stack-based SecBlock with 16-byte alignment |
1253 | | /// \tparam T class or type |
1254 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
1255 | | /// \tparam T_Align16 boolean that determines whether allocations should be |
1256 | | /// aligned on a 16-byte boundary |
1257 | | template <class T, unsigned int S, bool T_Align16 = true> |
1258 | | class FixedSizeAlignedSecBlock : public FixedSizeSecBlock<T, S, FixedSizeAllocatorWithCleanup<T, S, NullAllocator<T>, T_Align16> > |
1259 | | { |
1260 | | }; |
1261 | | |
1262 | | /// \brief Stack-based SecBlock that grows into the heap |
1263 | | /// \tparam T class or type |
1264 | | /// \tparam S fixed-size of the stack-based memory block, in elements |
1265 | | /// \tparam A AllocatorBase derived class for allocation and cleanup |
1266 | | template <class T, unsigned int S, class A = FixedSizeAllocatorWithCleanup<T, S, AllocatorWithCleanup<T> > > |
1267 | | class SecBlockWithHint : public SecBlock<T, A> |
1268 | | { |
1269 | | public: |
1270 | | /// construct a SecBlockWithHint with a count of elements |
1271 | | explicit SecBlockWithHint(size_t size) : SecBlock<T, A>(size) {} |
1272 | | }; |
1273 | | |
1274 | | template<class T, bool A, class V, bool B> |
1275 | | inline bool operator==(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<V, B>&) {return (true);} |
1276 | | template<class T, bool A, class V, bool B> |
1277 | | inline bool operator!=(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<V, B>&) {return (false);} |
1278 | | |
1279 | | NAMESPACE_END |
1280 | | |
1281 | | NAMESPACE_BEGIN(std) |
1282 | | |
1283 | | /// \brief Swap two SecBlocks |
1284 | | /// \tparam T class or type |
1285 | | /// \tparam A AllocatorBase derived class for allocation and cleanup |
1286 | | /// \param a the first SecBlock |
1287 | | /// \param b the second SecBlock |
1288 | | template <class T, class A> |
1289 | | inline void swap(CryptoPP::SecBlock<T, A> &a, CryptoPP::SecBlock<T, A> &b) |
1290 | 325 | { |
1291 | 325 | a.swap(b); |
1292 | 325 | } |
1293 | | |
1294 | | #if defined(_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) || (defined(_STLPORT_VERSION) && !defined(_STLP_MEMBER_TEMPLATE_CLASSES)) |
1295 | | // working for STLport 5.1.3 and MSVC 6 SP5 |
1296 | | template <class _Tp1, class _Tp2> |
1297 | | inline CryptoPP::AllocatorWithCleanup<_Tp2>& |
1298 | | __stl_alloc_rebind(CryptoPP::AllocatorWithCleanup<_Tp1>& __a, const _Tp2*) |
1299 | | { |
1300 | | return (CryptoPP::AllocatorWithCleanup<_Tp2>&)(__a); |
1301 | | } |
1302 | | #endif |
1303 | | |
1304 | | NAMESPACE_END |
1305 | | |
1306 | | #if defined(CRYPTOPP_MSC_VERSION) |
1307 | | # pragma warning(pop) |
1308 | | #endif |
1309 | | |
1310 | | #endif |