- primo commit.
This commit is contained in:
SaraP
2021-09-07 16:50:23 +02:00
parent a5a65b4c8d
commit f8c998f6ff
633 changed files with 108631 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "Common/NMR_SecureContext.h"
#include "Common/NMR_Exception.h"
namespace NMR {
bool CSecureContext::hasDekCtx() const {
return m_bHasDek;
}
ContentEncryptionDescriptor CSecureContext::getDekCtx() const {
return m_sDekDescriptor;
}
void CSecureContext::setDekCtx(ContentEncryptionDescriptor const & descriptor) {
m_sDekDescriptor = descriptor;
m_bHasDek = true;
}
ClientConsumerMap::const_iterator CSecureContext::kekCtxBegin() const {
return m_ConsumerMap.cbegin();
}
ClientConsumerMap::const_iterator CSecureContext::kekCtxEnd() const {
return m_ConsumerMap.cend();
}
void CSecureContext::addKekCtx(std::string const & consumerId, KeyWrappingDescriptor const & descriptor) {
if (m_ConsumerMap.find(consumerId) != m_ConsumerMap.end())
throw CNMRException(NMR_ERROR_KEYSTOREDUPLICATECONSUMERID);
m_ConsumerMap[consumerId] = descriptor;
}
KeyWrappingDescriptor CSecureContext::getKekCtx(std::string const & consumerId) const {
auto it = m_ConsumerMap.find(consumerId);
if (it != m_ConsumerMap.end())
return (*it).second;
throw CNMRException(NMR_ERROR_KEKDESCRIPTORNOTFOUND);
}
bool CSecureContext::emptyKekCtx() const {
return m_ConsumerMap.empty();
}
}