From: Krzysztof Jackiewicz Date: Thu, 28 May 2015 07:28:09 +0000 (+0200) Subject: Make CryptoAlgorithm copyable. X-Git-Tag: accepted/tizen/mobile/20150629.000431~13 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fsecurity%2Fkey-manager.git;a=commitdiff_plain;h=60a4223c6d9ebeeb9173f4225f364d3c6df2bd99 Make CryptoAlgorithm copyable. [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 --- diff --git a/src/include/ckm/ckm-type.h b/src/include/ckm/ckm-type.h index d17f8a9..12c91b0 100644 --- a/src/include/ckm/ckm-type.h +++ b/src/include/ckm/ckm-type.h @@ -164,7 +164,7 @@ protected: protected: BaseParam() {} }; - typedef std::unique_ptr BaseParamPtr; + typedef std::shared_ptr BaseParamPtr; class BufferParam : public BaseParam { public: diff --git a/src/manager/common/protocols.cpp b/src/manager/common/protocols.cpp index 7bd6eac..efa0beb 100644 --- a/src/manager/common/protocols.cpp +++ b/src/manager/common/protocols.cpp @@ -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) { } diff --git a/src/manager/common/protocols.h b/src/manager/common/protocols.h index f2baa9d..43f52be 100644 --- a/src/manager/common/protocols.h +++ b/src/manager/common/protocols.h @@ -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; diff --git a/tests/test_serialization.cpp b/tests/test_serialization.cpp index 4c6e5b5..d4ceb5f 100644 --- a/tests/test_serialization.cpp +++ b/tests/test_serialization.cpp @@ -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(666), 666, true); - CryptoAlgorithmSerializable input(std::move(ca)); + CryptoAlgorithmSerializable input(ca); CryptoAlgorithmSerializable output; auto msg = MessageBuffer::Serialize(input); RawBuffer buffer = msg.Pop();