diff options
author | weidai <weidai11@users.noreply.github.com> | 2009-03-02 02:39:17 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2009-03-02 02:39:17 +0000 |
commit | d8a644fc4ee2af9dc62f2a8c167b023d0c71d13b (patch) | |
tree | 0fecaa7a6728d07549a41864ea2cedfb245f0bd3 /algparam.cpp | |
parent | fa25129ac981ceed9569496c02b83771b394fa40 (diff) | |
download | cryptopp-git-d8a644fc4ee2af9dc62f2a8c167b023d0c71d13b.tar.gz |
changes for 5.6:
- added AuthenticatedSymmetricCipher interface class and Filter wrappers
- added CCM, GCM (with SSE2 assembly), CMAC, and SEED
- improved AES speed on x86 and x64
- removed WORD64_AVAILABLE; compiler 64-bit int support is now required
Diffstat (limited to 'algparam.cpp')
-rw-r--r-- | algparam.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/algparam.cpp b/algparam.cpp index c9da677d..84f8be04 100644 --- a/algparam.cpp +++ b/algparam.cpp @@ -22,7 +22,7 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf { if (strcmp(name, "ValueNames") == 0) { - ThrowIfTypeMismatch(name, typeid(std::string), valueType); + NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType); if (m_next.get()) m_next->GetVoidValue(name, valueType, pValue); (*reinterpret_cast<std::string *>(pValue) += m_name) += ";"; @@ -40,9 +40,53 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf return false; } +AlgorithmParameters::AlgorithmParameters() + : m_constructed(false), m_defaultThrowIfNotUsed(true) +{ + new(m_first) member_ptr<AlgorithmParametersBase>; +} + +AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x) + : m_constructed(false), m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed) +{ + if (x.m_constructed) + { + x.First().MoveInto(m_first); + m_constructed = true; + } + else + new(m_first) member_ptr<AlgorithmParametersBase>(x.Next().release()); +} + +AlgorithmParameters::~AlgorithmParameters() +{ + if (m_constructed) + First().~AlgorithmParametersBase(); + else + Next().~member_ptr<AlgorithmParametersBase>(); +} + bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const { - return m_ptr->GetVoidValue(name, valueType, pValue); + if (m_constructed) + return First().GetVoidValue(name, valueType, pValue); + else if (Next().get()) + return Next()->GetVoidValue(name, valueType, pValue); + else + return false; +} + +AlgorithmParametersBase & AlgorithmParameters::First() +{ + return *reinterpret_cast<AlgorithmParametersBase *>(m_first); +} + +member_ptr<AlgorithmParametersBase> & AlgorithmParameters::Next() +{ + if (m_constructed) + return First().m_next; + else + return *reinterpret_cast<member_ptr<AlgorithmParametersBase> *>(m_first); } NAMESPACE_END |