Update parameter list API
[platform/core/security/key-manager.git] / src / manager / common / protocols.cpp
index 128f28f..91a3497 100644 (file)
@@ -33,7 +33,9 @@ char const * const SERVICE_SOCKET_ECHO = "/tmp/.central-key-manager-echo.sock";
 char const * const SERVICE_SOCKET_CKM_CONTROL = "/tmp/.central-key-manager-api-control.sock";
 char const * const SERVICE_SOCKET_CKM_STORAGE = "/tmp/.central-key-manager-api-storage.sock";
 char const * const SERVICE_SOCKET_OCSP = "/tmp/.central-key-manager-api-ocsp.sock";
+char const * const SERVICE_SOCKET_ENCRYPTION = "/tmp/.central-key-manager-api-encryption.sock";
 char const * const LABEL_NAME_SEPARATOR = " ";
+char const * const LABEL_SYSTEM_DB = "/";
 
 
 PKCS12Serializable::PKCS12Serializable() {}
@@ -110,17 +112,15 @@ void PKCS12Serializable::Serialize(IStream &stream) const
 
 
 CryptoAlgorithmSerializable::CryptoAlgorithmSerializable() {}
-CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(CryptoAlgorithm &&algo) :
-        CryptoAlgorithm(std::move(algo))
+CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(const CryptoAlgorithm &algo) :
+        CryptoAlgorithm(algo)
 {
 }
 
 CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(IStream &stream)
 {
     size_t plen = 0;
-    int type;
-    Deserializer<int,size_t>::Deserialize(stream, type, plen);
-    m_type = static_cast<AlgoType>(type);
+    Deserializer<size_t>::Deserialize(stream, plen);
     while(plen) {
         ParamName name;
         uint64_t integer;
@@ -130,13 +130,13 @@ CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(IStream &stream)
         name = static_cast<ParamName>(tmpName);
         switch (name) {
         case ParamName::ED_IV:
-        case ParamName::ED_CTR:
         case ParamName::ED_AAD:
         case ParamName::ED_LABEL:
             Deserializer<RawBuffer>::Deserialize(stream, buffer);
-            m_params.emplace(name, BufferParam::create(buffer));
+            setParam(name, buffer);
             break;
 
+        case ParamName::ALGO_TYPE:
         case ParamName::ED_CTR_LEN:
         case ParamName::ED_TAG_LEN:
         case ParamName::GEN_KEY_LEN:
@@ -144,7 +144,7 @@ CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(IStream &stream)
         case ParamName::SV_HASH_ALGO:
         case ParamName::SV_RSA_PADDING:
             Deserializer<uint64_t>::Deserialize(stream, integer);
-            m_params.emplace(name, IntParam::create(integer));
+            setParam(name, integer);
             break;
 
         default:
@@ -156,14 +156,14 @@ CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(IStream &stream)
 
 void CryptoAlgorithmSerializable::Serialize(IStream &stream) const
 {
-    Serializer<int,size_t>::Serialize(stream, static_cast<int>(m_type), m_params.size());
+    Serializer<size_t>::Serialize(stream, m_params.size());
     for(const auto& it : m_params) {
         Serializer<int>::Serialize(stream, static_cast<int>(it.first));
         uint64_t integer;
         RawBuffer buffer;
-        if (CKM_API_SUCCESS == it.second->getInt(integer))
+        if (it.second->getInt(integer))
             Serializer<uint64_t>::Serialize(stream, integer);
-        else if (CKM_API_SUCCESS == it.second->getBuffer(buffer))
+        else if (it.second->getBuffer(buffer))
             Serializer<RawBuffer>::Serialize(stream, buffer);
         else
             ThrowMsg(UnsupportedParam, "Unsupported param type");