Crypto++  5.6.3
Free C++ class library of cryptographic schemes
algparam.h
Go to the documentation of this file.
1 // algparam.h - written and placed in the public domain by Wei Dai
2 
3 //! \file
4 //! \headerfile algparam.h
5 //! \brief Classes for working with NameValuePairs
6 
7 
8 #ifndef CRYPTOPP_ALGPARAM_H
9 #define CRYPTOPP_ALGPARAM_H
10 
11 #include "config.h"
12 #include "cryptlib.h"
13 
14 // TODO: fix 6011 when the API/ABI can change
15 #if (CRYPTOPP_MSC_VERSION >= 1400)
16 # pragma warning(push)
17 # pragma warning(disable: 6011 28193)
18 #endif
19 
20 #include "smartptr.h"
21 #include "secblock.h"
22 #include "integer.h"
23 #include "misc.h"
24 
25 NAMESPACE_BEGIN(CryptoPP)
26 
27 //! \class ConstByteArrayParameter
28 //! \brief Used to pass byte array input as part of a NameValuePairs object
30 {
31 public:
32  //! \brief Construct a ConstByteArrayParameter
33  //! \param data a C-String
34  //! \param deepCopy flag indicating whether the data should be copied
35  //! \details The deepCopy option is used when the NameValuePairs object can't
36  //! keep a copy of the data available
37  ConstByteArrayParameter(const char *data = NULL, bool deepCopy = false)
38  : m_deepCopy(false), m_data(NULL), m_size(0)
39  {
40  Assign((const byte *)data, data ? strlen(data) : 0, deepCopy);
41  }
42 
43  //! \brief Construct a ConstByteArrayParameter
44  //! \param data a memory buffer
45  //! \param size the length of the memory buffer
46  //! \param deepCopy flag indicating whether the data should be copied
47  //! \details The deepCopy option is used when the NameValuePairs object can't
48  //! keep a copy of the data available
49  ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy = false)
50  : m_deepCopy(false), m_data(NULL), m_size(0)
51  {
52  Assign(data, size, deepCopy);
53  }
54 
55  //! \brief Construct a ConstByteArrayParameter
56  //! \tparam T a std::basic_string<char> class
57  //! \param string a std::basic_string<char> class
58  //! \param deepCopy flag indicating whether the data should be copied
59  //! \details The deepCopy option is used when the NameValuePairs object can't
60  //! keep a copy of the data available
61  template <class T> ConstByteArrayParameter(const T &string, bool deepCopy = false)
62  : m_deepCopy(false), m_data(NULL), m_size(0)
63  {
64  CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
65  Assign((const byte *)string.data(), string.size(), deepCopy);
66  }
67 
68  //! \brief Assign contents from a memory buffer
69  //! \param data a memory buffer
70  //! \param size the length of the memory buffer
71  //! \param deepCopy flag indicating whether the data should be copied
72  //! \details The deepCopy option is used when the NameValuePairs object can't
73  //! keep a copy of the data available
74  void Assign(const byte *data, size_t size, bool deepCopy)
75  {
76  // This fires, which means: no data with a size, or data with no size.
77  // assert((data && size) || !(data || size));
78  if (deepCopy)
79  m_block.Assign(data, size);
80  else
81  {
82  m_data = data;
83  m_size = size;
84  }
85  m_deepCopy = deepCopy;
86  }
87 
88  //! \brief Pointer to the first byte in the memory block
89  const byte *begin() const {return m_deepCopy ? m_block.begin() : m_data;}
90  //! \brief Pointer beyond the last byte in the memory block
91  const byte *end() const {return m_deepCopy ? m_block.end() : m_data + m_size;}
92  //! \brief Length of the memory block
93  size_t size() const {return m_deepCopy ? m_block.size() : m_size;}
94 
95 private:
96  bool m_deepCopy;
97  const byte *m_data;
98  size_t m_size;
99  SecByteBlock m_block;
100 };
101 
102 //! \class ByteArrayParameter
103 //! \brief Used to pass byte array input as part of a NameValuePairs object
105 {
106 public:
107  //! \brief Construct a ByteArrayParameter
108  //! \param data a memory buffer
109  //! \param size the length of the memory buffer
110  ByteArrayParameter(byte *data = NULL, unsigned int size = 0)
111  : m_data(data), m_size(size) {}
112 
113  //! \brief Construct a ByteArrayParameter
114  //! \param block a SecByteBlock
116  : m_data(block.begin()), m_size(block.size()) {}
117 
118  //! \brief Pointer to the first byte in the memory block
119  byte *begin() const {return m_data;}
120  //! \brief Pointer beyond the last byte in the memory block
121  byte *end() const {return m_data + m_size;}
122  //! \brief Length of the memory block
123  size_t size() const {return m_size;}
124 
125 private:
126  byte *m_data;
127  size_t m_size;
128 };
129 
130 //! \class CombinedNameValuePairs
131 //! \brief Combines two sets of NameValuePairs
132 //! \details CombinedNameValuePairs allows you to provide two sets of of NameValuePairs.
133 //! If a name is not found in the first set, then the second set is searched for the
134 //! name and value pair. The second set of NameValuePairs often provides default values.
135 class CRYPTOPP_DLL CombinedNameValuePairs : public NameValuePairs
136 {
137 public:
138  //! \brief Construct a CombinedNameValuePairs
139  //! \param pairs1 reference to the first set of NameValuePairs
140  //! \param pairs2 reference to the second set of NameValuePairs
142  : m_pairs1(pairs1), m_pairs2(pairs2) {}
143 
144  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
145 
146 private:
147  const NameValuePairs &m_pairs1, &m_pairs2;
148 };
149 
150 #ifndef CRYPTOPP_DOXYGEN_PROCESSING
151 template <class T, class BASE>
152 class GetValueHelperClass
153 {
154 public:
155  GetValueHelperClass(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst)
156  : m_pObject(pObject), m_name(name), m_valueType(&valueType), m_pValue(pValue), m_found(false), m_getValueNames(false)
157  {
158  if (strcmp(m_name, "ValueNames") == 0)
159  {
160  m_found = m_getValueNames = true;
161  NameValuePairs::ThrowIfTypeMismatch(m_name, typeid(std::string), *m_valueType);
162  if (searchFirst)
163  searchFirst->GetVoidValue(m_name, valueType, pValue);
164  if (typeid(T) != typeid(BASE))
165  pObject->BASE::GetVoidValue(m_name, valueType, pValue);
166  ((*reinterpret_cast<std::string *>(m_pValue) += "ThisPointer:") += typeid(T).name()) += ';';
167  }
168 
169  if (!m_found && strncmp(m_name, "ThisPointer:", 12) == 0 && strcmp(m_name+12, typeid(T).name()) == 0)
170  {
171  NameValuePairs::ThrowIfTypeMismatch(m_name, typeid(T *), *m_valueType);
172  *reinterpret_cast<const T **>(pValue) = pObject;
173  m_found = true;
174  return;
175  }
176 
177  if (!m_found && searchFirst)
178  m_found = searchFirst->GetVoidValue(m_name, valueType, pValue);
179 
180  if (!m_found && typeid(T) != typeid(BASE))
181  m_found = pObject->BASE::GetVoidValue(m_name, valueType, pValue);
182  }
183 
184  operator bool() const {return m_found;}
185 
186  template <class R>
187  GetValueHelperClass<T,BASE> & operator()(const char *name, const R & (T::*pm)() const)
188  {
189  if (m_getValueNames)
190  (*reinterpret_cast<std::string *>(m_pValue) += name) += ";";
191  if (!m_found && strcmp(name, m_name) == 0)
192  {
193  NameValuePairs::ThrowIfTypeMismatch(name, typeid(R), *m_valueType);
194  *reinterpret_cast<R *>(m_pValue) = (m_pObject->*pm)();
195  m_found = true;
196  }
197  return *this;
198  }
199 
200  GetValueHelperClass<T,BASE> &Assignable()
201  {
202 #ifndef __INTEL_COMPILER // ICL 9.1 workaround: Intel compiler copies the vTable pointer for some reason
203  if (m_getValueNames)
204  ((*reinterpret_cast<std::string *>(m_pValue) += "ThisObject:") += typeid(T).name()) += ';';
205  if (!m_found && strncmp(m_name, "ThisObject:", 11) == 0 && strcmp(m_name+11, typeid(T).name()) == 0)
206  {
207  NameValuePairs::ThrowIfTypeMismatch(m_name, typeid(T), *m_valueType);
208  *reinterpret_cast<T *>(m_pValue) = *m_pObject;
209  m_found = true;
210  }
211 #endif
212  return *this;
213  }
214 
215 private:
216  const T *m_pObject;
217  const char *m_name;
218  const std::type_info *m_valueType;
219  void *m_pValue;
220  bool m_found, m_getValueNames;
221 };
222 
223 template <class BASE, class T>
224 GetValueHelperClass<T, BASE> GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL, BASE *dummy=NULL)
225 {
226  CRYPTOPP_UNUSED(dummy);
227  return GetValueHelperClass<T, BASE>(pObject, name, valueType, pValue, searchFirst);
228 }
229 
230 template <class T>
231 GetValueHelperClass<T, T> GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL)
232 {
233  return GetValueHelperClass<T, T>(pObject, name, valueType, pValue, searchFirst);
234 }
235 
236 // ********************************************************
237 
238 // VC60 workaround
239 #if defined(_MSC_VER) && (_MSC_VER < 1300)
240 template <class R>
241 R Hack_DefaultValueFromConstReferenceType(const R &)
242 {
243  return R();
244 }
245 
246 template <class R>
247 bool Hack_GetValueIntoConstReference(const NameValuePairs &source, const char *name, const R &value)
248 {
249  return source.GetValue(name, const_cast<R &>(value));
250 }
251 
252 template <class T, class BASE>
253 class AssignFromHelperClass
254 {
255 public:
256  AssignFromHelperClass(T *pObject, const NameValuePairs &source)
257  : m_pObject(pObject), m_source(source), m_done(false)
258  {
259  if (source.GetThisObject(*pObject))
260  m_done = true;
261  else if (typeid(BASE) != typeid(T))
262  pObject->BASE::AssignFrom(source);
263  }
264 
265  template <class R>
266  AssignFromHelperClass & operator()(const char *name, void (T::*pm)(R)) // VC60 workaround: "const R &" here causes compiler error
267  {
268  if (!m_done)
269  {
270  R value = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
271  if (!Hack_GetValueIntoConstReference(m_source, name, value))
272  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'");
273  (m_pObject->*pm)(value);
274  }
275  return *this;
276  }
277 
278  template <class R, class S>
279  AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(R, S)) // VC60 workaround: "const R &" here causes compiler error
280  {
281  if (!m_done)
282  {
283  R value1 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
284  if (!Hack_GetValueIntoConstReference(m_source, name1, value1))
285  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name1 + "'");
286  S value2 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<S>(*(int *)NULL));
287  if (!Hack_GetValueIntoConstReference(m_source, name2, value2))
288  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name2 + "'");
289  (m_pObject->*pm)(value1, value2);
290  }
291  return *this;
292  }
293 
294 private:
295  T *m_pObject;
296  const NameValuePairs &m_source;
297  bool m_done;
298 };
299 #else
300 template <class T, class BASE>
301 class AssignFromHelperClass
302 {
303 public:
304  AssignFromHelperClass(T *pObject, const NameValuePairs &source)
305  : m_pObject(pObject), m_source(source), m_done(false)
306  {
307  if (source.GetThisObject(*pObject))
308  m_done = true;
309  else if (typeid(BASE) != typeid(T))
310  pObject->BASE::AssignFrom(source);
311  }
312 
313  template <class R>
314  AssignFromHelperClass & operator()(const char *name, void (T::*pm)(const R&))
315  {
316  if (!m_done)
317  {
318  R value;
319  if (!m_source.GetValue(name, value))
320  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'");
321  (m_pObject->*pm)(value);
322  }
323  return *this;
324  }
325 
326  template <class R, class S>
327  AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(const R&, const S&))
328  {
329  if (!m_done)
330  {
331  R value1;
332  if (!m_source.GetValue(name1, value1))
333  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name1 + "'");
334  S value2;
335  if (!m_source.GetValue(name2, value2))
336  throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name2 + "'");
337  (m_pObject->*pm)(value1, value2);
338  }
339  return *this;
340  }
341 
342 private:
343  T *m_pObject;
344  const NameValuePairs &m_source;
345  bool m_done;
346 };
347 #endif
348 
349 template <class BASE, class T>
350 AssignFromHelperClass<T, BASE> AssignFromHelper(T *pObject, const NameValuePairs &source, BASE *dummy=NULL)
351 {
352  CRYPTOPP_UNUSED(dummy);
353  return AssignFromHelperClass<T, BASE>(pObject, source);
354 }
355 
356 template <class T>
357 AssignFromHelperClass<T, T> AssignFromHelper(T *pObject, const NameValuePairs &source)
358 {
359  return AssignFromHelperClass<T, T>(pObject, source);
360 }
361 
362 #endif // CRYPTOPP_DOXYGEN_PROCESSING
363 
364 // ********************************************************
365 
366 // to allow the linker to discard Integer code if not needed.
367 typedef bool (CRYPTOPP_API * PAssignIntToInteger)(const std::type_info &valueType, void *pInteger, const void *pInt);
368 CRYPTOPP_DLL extern PAssignIntToInteger g_pAssignIntToInteger;
369 
370 CRYPTOPP_DLL const std::type_info & CRYPTOPP_API IntegerTypeId();
371 
372 //! \class AlgorithmParametersBase
373 //! \brief Base class for AlgorithmParameters
374 class CRYPTOPP_DLL AlgorithmParametersBase
375 {
376 public:
377  //! \class ParameterNotUsed
378  //! \brief Exception thrown when an AlgorithmParameter is unused
380  {
381  public:
382  ParameterNotUsed(const char *name) : Exception(OTHER_ERROR, std::string("AlgorithmParametersBase: parameter \"") + name + "\" not used") {}
383  };
384 
385  // this is actually a move, not a copy
387  : m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used)
388  {
389  m_next.reset(const_cast<AlgorithmParametersBase &>(x).m_next.release());
390  x.m_used = true;
391  }
392 
393  //! \brief Construct a AlgorithmParametersBase
394  //! \param name the parameter name
395  //! \param throwIfNotUsed flags indicating whether an exception should be thrown
396  //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
397  //! will be thrown in the destructor if the parameter is not not retrieved.
398  AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
399  : m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {}
400 
401  virtual ~AlgorithmParametersBase() CRYPTOPP_THROW
402  {
403 #ifdef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
404  if (!std::uncaught_exception())
405 #else
406  try
407 #endif
408  {
409  if (m_throwIfNotUsed && !m_used)
410  throw ParameterNotUsed(m_name);
411  }
412 #ifndef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
413  catch(const Exception&)
414  {
415  }
416 #endif
417  }
418 
419  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
420 
421 protected:
422  friend class AlgorithmParameters;
423  void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60
424 
425  virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0;
426  virtual void MoveInto(void *p) const =0; // not really const
427 
428  const char *m_name;
429  bool m_throwIfNotUsed;
430  mutable bool m_used;
432 };
433 
434 //! \class AlgorithmParametersTemplate
435 //! \brief Template base class for AlgorithmParameters
436 //! \tparam T the class or type
437 template <class T>
439 {
440 public:
441  //! \brief Construct an AlgorithmParametersTemplate
442  //! \param name the name of the value
443  //! \param value a reference to the value
444  //! \param throwIfNotUsed flags indicating whether an exception should be thrown
445  //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
446  //! will be thrown in the destructor if the parameter is not not retrieved.
447  AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed)
448  : AlgorithmParametersBase(name, throwIfNotUsed), m_value(value)
449  {
450  }
451 
452  void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const
453  {
454  // special case for retrieving an Integer parameter when an int was passed in
455  if (!(g_pAssignIntToInteger != NULL && typeid(T) == typeid(int) && g_pAssignIntToInteger(valueType, pValue, &m_value)))
456  {
457  NameValuePairs::ThrowIfTypeMismatch(name, typeid(T), valueType);
458  *reinterpret_cast<T *>(pValue) = m_value;
459  }
460  }
461 
462  void MoveInto(void *buffer) const
463  {
465  CRYPTOPP_UNUSED(p); // silence warning
466  }
467 
468 protected:
469  T m_value;
470 };
471 
472 CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<bool>;
473 CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<int>;
474 CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<ConstByteArrayParameter>;
475 
476 //! \class AlgorithmParameters
477 //! \brief An object that implements NameValuePairs
478 //! \tparam T the class or type
479 //! \param name the name of the object or value to retrieve
480 //! \param value reference to a variable that receives the value
481 //! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
482 //! \note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
483 //! such as MSVC 7.0 and earlier.
484 //! \note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
485 //! repeatedly using operator() on the object returned by MakeParameters, for example:
486 //! <pre>
487 //! AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
488 //! </pre>
489 class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs
490 {
491 public:
493 
494 #ifdef __BORLANDC__
495  template <class T>
496  AlgorithmParameters(const char *name, const T &value, bool throwIfNotUsed=true)
497  : m_next(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed))
498  , m_defaultThrowIfNotUsed(throwIfNotUsed)
499  {
500  }
501 #endif
502 
504 
505  AlgorithmParameters & operator=(const AlgorithmParameters &x);
506 
507  //! \tparam T the class or type
508  //! \param name the name of the object or value to retrieve
509  //! \param value reference to a variable that receives the value
510  //! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
511  template <class T>
512  AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
513  {
514  member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
515  p->m_next.reset(m_next.release());
516  m_next.reset(p.release());
517  m_defaultThrowIfNotUsed = throwIfNotUsed;
518  return *this;
519  }
520 
521  //! \brief Appends a NameValuePair to a collection of NameValuePairs
522  //! \tparam T the class or type
523  //! \param name the name of the object or value to retrieve
524  //! \param value reference to a variable that receives the value
525  template <class T>
526  AlgorithmParameters & operator()(const char *name, const T &value)
527  {
528  return operator()(name, value, m_defaultThrowIfNotUsed);
529  }
530 
531  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
532 
533 protected:
535  bool m_defaultThrowIfNotUsed;
536 };
537 
538 //! \brief Create an object that implements NameValuePairs
539 //! \tparam T the class or type
540 //! \param name the name of the object or value to retrieve
541 //! \param value reference to a variable that receives the value
542 //! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
543 //! \note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
544 //! such as MSVC 7.0 and earlier.
545 //! \note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
546 //! repeatedly using \p operator() on the object returned by \p MakeParameters, for example:
547 //! <pre>
548 //! AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
549 //! </pre>
550 #ifdef __BORLANDC__
552 #else
553 template <class T>
554 AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed = true)
555 {
556  return AlgorithmParameters()(name, value, throwIfNotUsed);
557 }
558 #endif
559 
560 #define CRYPTOPP_GET_FUNCTION_ENTRY(name) (Name::name(), &ThisClass::Get##name)
561 #define CRYPTOPP_SET_FUNCTION_ENTRY(name) (Name::name(), &ThisClass::Set##name)
562 #define CRYPTOPP_SET_FUNCTION_ENTRY2(name1, name2) (Name::name1(), Name::name2(), &ThisClass::Set##name1##And##name2)
563 
564 // TODO: fix 6011 when the API/ABI can change
565 #if (CRYPTOPP_MSC_VERSION >= 1400)
566 # pragma warning(pop)
567 #endif
568 
569 NAMESPACE_END
570 
571 #endif
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:29
Base class for all exceptions thrown by the library.
Definition: cryptlib.h:139
An invalid argument was detected.
Definition: cryptlib.h:182
bool GetThisObject(T &object) const
Get a copy of this object or subobject.
Definition: cryptlib.h:313
CombinedNameValuePairs(const NameValuePairs &pairs1, const NameValuePairs &pairs2)
Construct a CombinedNameValuePairs.
Definition: algparam.h:141
Utility functions for the Crypto++ library.
Base class for AlgorithmParameters.
Definition: algparam.h:374
ConstByteArrayParameter(const T &string, bool deepCopy=false)
Construct a ConstByteArrayParameter.
Definition: algparam.h:61
AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
Construct a AlgorithmParametersBase.
Definition: algparam.h:398
ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy=false)
Construct a ConstByteArrayParameter.
Definition: algparam.h:49
Abstract base classes that provide a uniform interface to this library.
virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
Classes for automatic resource management.
size_t size() const
Length of the memory block.
Definition: algparam.h:93
Library configuration file.
ConstByteArrayParameter(const char *data=NULL, bool deepCopy=false)
Construct a ConstByteArrayParameter.
Definition: algparam.h:37
Combines two sets of NameValuePairs.
Definition: algparam.h:135
SecBlock typedef.
Definition: secblock.h:728
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:104
const byte * begin() const
Pointer to the first byte in the memory block.
Definition: algparam.h:89
Classes and functions for secure memory allocations.
bool GetValue(const char *name, T &value) const
Get a named value.
Definition: cryptlib.h:335
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:554
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
Definition: misc.h:121
Exception thrown when an AlgorithmParameter is unused.
Definition: algparam.h:379
byte * begin() const
Pointer to the first byte in the memory block.
Definition: algparam.h:119
void Assign(const byte *data, size_t size, bool deepCopy)
Assign contents from a memory buffer.
Definition: algparam.h:74
Template base class for AlgorithmParameters.
Definition: algparam.h:438
size_t size() const
Length of the memory block.
Definition: algparam.h:123
AlgorithmParameters & operator()(const char *name, const T &value)
Appends a NameValuePair to a collection of NameValuePairs.
Definition: algparam.h:526
const byte * end() const
Pointer beyond the last byte in the memory block.
Definition: algparam.h:91
byte * end() const
Pointer beyond the last byte in the memory block.
Definition: algparam.h:121
ByteArrayParameter(byte *data=NULL, unsigned int size=0)
Construct a ByteArrayParameter.
Definition: algparam.h:110
ByteArrayParameter(SecByteBlock &block)
Construct a ByteArrayParameter.
Definition: algparam.h:115
static void ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
Ensures an expected name and type is present.
Definition: cryptlib.h:392
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
Definition: algparam.h:512
An object that implements NameValuePairs.
Definition: algparam.h:489
AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed)
Construct an AlgorithmParametersTemplate.
Definition: algparam.h:447
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:277