%{_includedir}/ckm/ckm/ckm-error.h
%{_includedir}/ckm/ckm/ckm-echo.h
%{_includedir}/ckm/ckm/ckm-key.h
+%{_includedir}/ckm/ckm/ckm-password.h
%{_includedir}/ckm/ckm/ckm-raw-buffer.h
%{_includedir}/ckm/ckm/ckm-type.h
%{_includedir}/ckm/ckmc/ckmc-manager.h
${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-error.h
${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-echo.h
${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-key.h
+ ${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-password.h
${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-raw-buffer.h
${KEY_MANAGER_SRC_PATH}/include/ckm/ckm-type.h
DESTINATION /usr/include/ckm/ckm
--- /dev/null
+/* Copyright (c) 2014 Samsung Electronics Co.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ *
+ *
+ * @file safe-buffer.h
+ * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief Custom allocator for std
+ */
+
+#ifndef _SAFE_PASSWORD_H_
+#define _SAFE_PASSWORD_H_
+
+#include <ckm/ckm-raw-buffer.h>
+#include <boost/container/string.hpp>
+
+namespace CKM {
+
+typedef boost::container::basic_string<char, std::char_traits<char>, erase_on_dealloc<char>> Password;
+
+} // namespace CKM
+
+#endif //_ERASE_ON_DEALLOC_H_
#include <vector>
#include <ckm/ckm-raw-buffer.h>
+#include <ckm/ckm-password.h>
namespace CKM {
typedef std::vector<RawBuffer> RawBufferVector;
typedef std::string Alias;
typedef std::vector<Alias> AliasVector;
-typedef std::string Password;
enum class KeyType : int {
KEY_NONE,
#include <iostream>
#include <string.h>
-std::string _tostring(const char *str)
+CKM::Password _tostring(const char *str)
{
if(str == NULL)
- return std::string();
- return std::string(str);
+ return CKM::Password();
+ return CKM::Password(str);
}
CKM::CertificateShPtr _toCkmCertificate(const ckmc_cert_s *cert)
#include <memory>
#include <dpl/raw-buffer.h>
+// temporary fix for tizen 2.3
+#include <ckm/ckm-password.h>
namespace CKM {
// Abstract data stream buffer
stream.Write(length, str->c_str());
}
+ // Password
+ static void Serialize(IStream& stream, const Password& str)
+ {
+ int length = str.size();
+ stream.Write(sizeof(length), &length);
+ stream.Write(length, str.c_str());
+ }
+ static void Serialize(IStream& stream, const Password* const str)
+ {
+ int length = str->size();
+ stream.Write(sizeof(length), &length);
+ stream.Write(length, str->c_str());
+ }
+
// STL templates
// std::list
delete[] buf;
}
+ // Password
+ static void Deserialize(IStream& stream, Password& str)
+ {
+ int length;
+ stream.Read(sizeof(length), &length);
+ char * buf = new char[length + 1];
+ stream.Read(length, buf);
+ buf[length] = 0;
+ str = Password(buf);
+ delete[] buf;
+ }
+ static void Deserialize(IStream& stream, Password*& str)
+ {
+ int length;
+ stream.Read(sizeof(length), &length);
+ char * buf = new char[length + 1];
+ stream.Read(length, buf);
+ buf[length] = 0;
+ str = new Password(buf);
+ delete[] buf;
+ }
+
// STL templates
// std::list
#include <test_common.h>
#include <iostream>
-const std::string PASSWORD = "12345TIZEN12345AAAAAAAAA";
-const std::string INCORRECT_PASSWORD = "AAAAAAAAAAAAAAAAAAAAA";
-const std::string NEW_PASSWORD = "NEW12345TIZEN12345NEW";
+const CKM::Password PASSWORD = "12345TIZEN12345AAAAAAAAA";
+const CKM::Password INCORRECT_PASSWORD = "AAAAAAAAAAAAAAAAAAAAA";
+const CKM::Password NEW_PASSWORD = "NEW12345TIZEN12345NEW";
const std::string USERNAME_SHORT = "AB";
const std::string USERNAME_LONG = "SOFTWARE_CENTER_SYSTEM_SW_LAB_SECURITY_PART";
CKM::RawBuffer rb_test;
BOOST_REQUIRE_NO_THROW(rb_test =
CKM::KeyProvider::generateDomainKEK(USERNAME_LONG, PASSWORD));
- BOOST_REQUIRE_NO_THROW(keyProvider = CKM::KeyProvider(rb_test, std::string(PASSWORD)));
+ BOOST_REQUIRE_NO_THROW(keyProvider = CKM::KeyProvider(rb_test, PASSWORD));
BOOST_REQUIRE_MESSAGE(keyProvider.isInitialized(),
"KeyProvider created, but uninitialized");
BOOST_REQUIRE_NO_THROW(rb_test = keyProvider.getPureDomainKEK());