+++ /dev/null
-/******************************************************************
- *
- * Copyright 2017 Samsung Electronics All Rights Reserved.
- *
- * Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
- *
- * 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.
- *
- ******************************************************************/
-
-#ifndef DCM_DAEMON_MBEDTLS_WRAPPER_H_
-#define DCM_DAEMON_MBEDTLS_WRAPPER_H_
-
-#include <mbedtls/x509_crt.h>
-#include <mbedtls/error.h>
-#include <mbedtls/bignum.h>
-#include <boost/noncopyable.hpp>
-#include <string>
-
-struct mbedtls_x509_crt_wrapper : public mbedtls_x509_crt, public boost::noncopyable {
- mbedtls_x509_crt_wrapper() {
- mbedtls_x509_crt_init(this);
- }
-
- ~mbedtls_x509_crt_wrapper() {
- mbedtls_x509_crt_free(this);
- }
-
- int parse(const std::string& pem) {
- return mbedtls_x509_crt_parse(this, reinterpret_cast<const unsigned char *>(pem.c_str()), pem.size() + 1);
- }
-};
-
-static inline std::string mbedtls_error_to_string(int error) {
- char buffer[256];
- mbedtls_strerror(error, buffer, sizeof(buffer));
- return std::string(buffer);
-}
-
-struct mbedtls_mpi_wrapper : public mbedtls_mpi, public boost::noncopyable {
- mbedtls_mpi_wrapper() {
- mbedtls_mpi_init(this);
- }
-
- ~mbedtls_mpi_wrapper() {
- mbedtls_mpi_free(this);
- }
-
- int read_binary(const void * data, size_t length) {
- return mbedtls_mpi_read_binary(this, (const unsigned char *)data, length);
- }
-
- int get_raw(const void * data, size_t length) {
- const int ciL = sizeof(mbedtls_mpi_uint);
- const int biL = ciL * 8;
- int error = mbedtls_mpi_grow(this, (length * 8 + biL - 1) / biL);
- if(error != 0)
- return error;
- mbedtls_mpi_lset(this, 0);
- memcpy(this->p, data, length);
- return 0;
- }
-};
-
-#endif /* DCM_DAEMON_MBEDTLS_WRAPPER_H_ */
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2017 Samsung Electronics All Rights Reserved.
+ *
+ * Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#ifndef DCM_DAEMON_MBEDTLS_WRAPPER_H_
+#define DCM_DAEMON_MBEDTLS_WRAPPER_H_
+
+#include <mbedtls/x509_crt.h>
+#include <mbedtls/error.h>
+#include <mbedtls/bignum.h>
+#include <boost/noncopyable.hpp>
+#include <string>
+
+struct mbedtls_x509_crt_wrapper : public mbedtls_x509_crt, public boost::noncopyable {
+ mbedtls_x509_crt_wrapper() {
+ mbedtls_x509_crt_init(this);
+ }
+
+ ~mbedtls_x509_crt_wrapper() {
+ mbedtls_x509_crt_free(this);
+ }
+
+ int parse(const std::string& pem) {
+ return mbedtls_x509_crt_parse(this, reinterpret_cast<const unsigned char *>(pem.c_str()), pem.size() + 1);
+ }
+};
+
+static inline std::string mbedtls_error_to_string(int error) {
+ char buffer[256];
+ mbedtls_strerror(error, buffer, sizeof(buffer));
+ return std::string(buffer);
+}
+
+struct mbedtls_mpi_wrapper : public mbedtls_mpi, public boost::noncopyable {
+ mbedtls_mpi_wrapper() {
+ mbedtls_mpi_init(this);
+ }
+
+ ~mbedtls_mpi_wrapper() {
+ mbedtls_mpi_free(this);
+ }
+
+ int read_binary(const void * data, size_t length) {
+ return mbedtls_mpi_read_binary(this, (const unsigned char *)data, length);
+ }
+
+ int get_raw(const void * data, size_t length) {
+ const int ciL = sizeof(mbedtls_mpi_uint);
+ const int biL = ciL * 8;
+ int error = mbedtls_mpi_grow(this, (length * 8 + biL - 1) / biL);
+ if(error != 0)
+ return error;
+ mbedtls_mpi_lset(this, 0);
+ memcpy(this->p, data, length);
+ return 0;
+ }
+};
+
+#endif /* DCM_DAEMON_MBEDTLS_WRAPPER_H_ */