Make CryptoAlgorithm copyable. 51/40051/2
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 28 May 2015 07:28:09 +0000 (09:28 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 28 May 2015 12:17:19 +0000 (14:17 +0200)
[Problem] CryptoAlgorithm have to be copied on client side. One copy has to
remain on client side for decryption and the other has to be serialized in
client.
[Solution] Unique_ptr replaced with shared_ptr so that CryptoAlgorithm copying
is possible.

[Verification] Run ckm-tests-internal -t SERIALIZATION_TEST

Change-Id: Ied81a1414cc9c6b40206116895f713b779a685ac

src/include/ckm/ckm-type.h
src/manager/common/protocols.cpp
src/manager/common/protocols.h
tests/test_serialization.cpp

index d17f8a9..12c91b0 100644 (file)
@@ -164,7 +164,7 @@ protected:
     protected:
         BaseParam() {}
     };
-    typedef std::unique_ptr<BaseParam> BaseParamPtr;
+    typedef std::shared_ptr<BaseParam> BaseParamPtr;
 
     class BufferParam : public BaseParam {
     public:
index 7bd6eac..efa0beb 100644 (file)
@@ -111,8 +111,8 @@ void PKCS12Serializable::Serialize(IStream &stream) const
 
 
 CryptoAlgorithmSerializable::CryptoAlgorithmSerializable() {}
-CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(CryptoAlgorithm &&algo) :
-        CryptoAlgorithm(std::move(algo))
+CryptoAlgorithmSerializable::CryptoAlgorithmSerializable(const CryptoAlgorithm &algo) :
+        CryptoAlgorithm(algo)
 {
 }
 
index f2baa9d..43f52be 100644 (file)
@@ -107,7 +107,7 @@ struct COMMON_API CryptoAlgorithmSerializable : public CryptoAlgorithm, ISeriali
     DECLARE_EXCEPTION_TYPE(Exception, UnsupportedParam);
 
     CryptoAlgorithmSerializable();
-    explicit CryptoAlgorithmSerializable(CryptoAlgorithm &&);
+    explicit CryptoAlgorithmSerializable(const CryptoAlgorithm &);
     explicit CryptoAlgorithmSerializable(IStream &);
 
     void Serialize(IStream &) const;
index 4c6e5b5..d4ceb5f 100644 (file)
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(Serialization_CryptoAlgorithm) {
     addParam(ca,ParamName::ED_TAG_LEN, 128, true);
     addParam(ca,ParamName::ED_AAD, AAD, true);
 
-    CryptoAlgorithmSerializable input(std::move(ca));
+    CryptoAlgorithmSerializable input(ca);
     CryptoAlgorithmSerializable output;
     auto msg = MessageBuffer::Serialize(input);
     RawBuffer buffer = msg.Pop();
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(Serialization_CryptoAlgorithm_wrong_name) {
     // unuspported param name
     addParam(ca, static_cast<ParamName>(666), 666, true);
 
-    CryptoAlgorithmSerializable input(std::move(ca));
+    CryptoAlgorithmSerializable input(ca);
     CryptoAlgorithmSerializable output;
     auto msg = MessageBuffer::Serialize(input);
     RawBuffer buffer = msg.Pop();