Break circular dependency 80/290880/5 accepted/tizen/unified/20230407.140024
authorDariusz Michaluk <d.michaluk@samsung.com>
Tue, 4 Apr 2023 10:42:43 +0000 (12:42 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Tue, 4 Apr 2023 12:05:12 +0000 (14:05 +0200)
Change-Id: If31b792293891f7e80d6e143e355ae0c67e5ed42

13 files changed:
CMakeLists.txt
src/dcm-client/CMakeLists.txt
src/dcm-client/device_certificate_manager.h [deleted file]
src/dcm-client/device_certificate_manager_ext.h [deleted file]
src/dcm-client/device_certificate_manager_ext_types.h [deleted file]
src/dcm-daemon/CMakeLists.txt
src/dcm-daemon/dcm_session.cpp
src/include/CMakeLists.txt [new file with mode: 0644]
src/include/device_certificate_manager.h [new file with mode: 0644]
src/include/device_certificate_manager_ext.h [new file with mode: 0644]
src/include/device_certificate_manager_ext_types.h [new file with mode: 0644]
src/shared/bundle.cpp
tests/CMakeLists.txt

index ebfb43ae8b52ea9a454d8b386b55205fbcb195a2..7751b48cffa01718b83a936c3e45967ab9ac0e35 100644 (file)
@@ -51,7 +51,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
 SET(DCM_UNIX_SOCKET_PATH "/run/device-certificate-manager.socket")
 ADD_DEFINITIONS(-DDCM_UNIX_SOCKET_PATH="${DCM_UNIX_SOCKET_PATH}")
 
-INCLUDE_DIRECTORIES(src/shared)
+ADD_SUBDIRECTORY(src/include)
 ADD_SUBDIRECTORY(src/dcm-client)
 ADD_SUBDIRECTORY(src/dcm-daemon)
 ADD_SUBDIRECTORY(pkgconfig)
index fc8b553824c0ad454585f5d9e80f31343ad8ec38..9d02801d5c91f67dfd84e69df4b95afb6bf37b8f 100644 (file)
@@ -27,7 +27,7 @@ PKG_CHECK_MODULES(CLIENT_DEPS REQUIRED dlog)
 
 INCLUDE_DIRECTORIES(SYSTEM ${CLIENT_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
 LINK_DIRECTORIES(${CLIENT_DEPS_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ../include ../shared)
 
 PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS dcm_support.proto)
 
@@ -86,12 +86,6 @@ SET_TARGET_PROPERTIES(${TARGET_CLIENT_EXT}
 INSTALL(TARGETS ${TARGET_CLIENT} ${TARGET_CLIENT_EXT}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
-INSTALL(FILES
-       device_certificate_manager.h
-       device_certificate_manager_ext.h
-       device_certificate_manager_ext_types.h
-       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/device-certificate-manager)
-
 INSTALL(FILES
        ${CMAKE_CURRENT_BINARY_DIR}/dcm_support.pb.h
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/device-certificate-manager-backend)
diff --git a/src/dcm-client/device_certificate_manager.h b/src/dcm-client/device_certificate_manager.h
deleted file mode 100644 (file)
index db4c2d6..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/******************************************************************
- *
- * Copyright 2017 - 2018 Samsung Electronics All Rights Reserved.
- *
- * 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 __DEVICE_CERTIFICATE_MANAGER_H__
-#define __DEVICE_CERTIFICATE_MANAGER_H__
-
-#include <stddef.h>
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup CAPI_DEVICE_CERTIFICATE_MANAGER_MODULE
- * @{
- */
-
-
-/**
- * @brief Enumeration for DCM error values.
- * @since_tizen 5.0
- */
-typedef enum {
-    DCM_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-    DCM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
-    DCM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-    DCM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-    DCM_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Feature needed to run API is not supported */
-    DCM_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */
-    DCM_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
-
-    DCM_ERROR_SOCKET = TIZEN_ERROR_DEVICE_CERTIFICATE_MANAGER | 0x01, /**< Socket error between client and server */
-} dcm_error_e;
-
-
-/**
- * @brief Enumeration for DCM message digest algorithms.
- * @since_tizen 5.0
- */
-typedef enum {
-    DCM_DIGEST_NONE=0, /**< No message digest algorithm */
-    DCM_DIGEST_MD2, /**< Message digest algorithm MD2 */
-    DCM_DIGEST_MD4, /**< Message digest algorithm MD4 */
-    DCM_DIGEST_MD5, /**< Message digest algorithm MD5 */
-    DCM_DIGEST_SHA1, /**< Message digest algorithm SHA1 */
-    DCM_DIGEST_SHA224, /**< Message digest algorithm SHA224 */
-    DCM_DIGEST_SHA256, /**< Message digest algorithm SHA256 */
-    DCM_DIGEST_SHA384, /**< Message digest algorithm SHA384 */
-    DCM_DIGEST_SHA512, /**< Message digest algorithm SHA512 */
-    DCM_DIGEST_RIPEMD160, /**< Message digest algorithm RIPEMD160 */
-} dcm_digest_algorithm_e;
-
-
-/**
- * @platform
- * @brief Creates a new key context based on specific name indication (service name, key usage, key type).
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @remarks The @a key_ctx should be freed with dcm_free_key_context() after use.
- *
- * @param[in] service  Service name indicates first category name (if null, default value is used)
- * @param[in] usage  Usage name indicates sub-category name (if null, default value is used)
- * @param[in] key_type  Key type name indication (if null, default value is used)
- * @param[out] key_ctx  Newly created key context
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- *
- * @see dcm_free_key_context()
- */
-int dcm_create_key_context(const char *service, const char *usage, const char *key_type, void **key_ctx);
-
-
-/**
- * @platform
- * @brief Destroys the key context that was created by calling dcm_create_key_context().
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @param[in] key_ctx  Key context object to be deallocated
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_NO_DATA No such key context object
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- *
- * @see dcm_create_key_context()
- */
-int dcm_free_key_context(void *key_ctx);
-
-
-/**
- * @platform
- * @brief Returns a certificate chain which was pre-injected in device.
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @remarks The @a cert_chain should be freed using free().
- *
- * @param[in] key_ctx  Key context object that identifies proper certificate chain
- * @param[out] cert_chain  Certificate chain in binary, will be allocated by the library
- * @param[out] cert_chain_len  The total length of certificate chain
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_NO_DATA No certificate chain available
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- */
-int dcm_get_certificate_chain(const void *key_ctx, char **cert_chain, size_t *cert_chain_len);
-
-
-/**
- * @platform
- * @brief Returns the key size in bits for a given key context.
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @param[in] key_ctx  Key context object that identifies proper certificate chain
- * @param[out] key_bit_len  Key length in bits
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_NO_DATA No certificate chain available
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- */
-int dcm_get_key_bit_length(const void *key_ctx, size_t *key_bit_len);
-
-
-/**
- * @platform
- * @brief Returns the key type name for a given key context.
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @remarks The @a key_type should be freed using free().
- *
- * @param[in] key_ctx  Key context object that identifies proper certificate chain
- * @param[out] key_type  Key type name (UNKNOWN, RSA or ECDSA), will be allocated by the library
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_NO_DATA No certificate chain available
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- */
-int dcm_get_key_type(const void *key_ctx, char **key_type);
-
-/**
- * @platform
- * @brief Creates a signature on a given data using a private key and returns the signature.
- * @since_tizen 5.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @remarks The private key is identified by @a key_ctx.
- * @remarks The @a message can be NULL but then @a message_len must be 0.
- * @remarks The @a signature should be freed using free().
- *
- * @param[in] key_ctx  Key context object that identifies a proper private key for signing
- * @param[in] md  Message digest algorithm used in creating signature
- * @param[in] message  Message that is signed with a key
- * @param[in] message_len  Length of the message
- * @param[out] signature  Newly created signature, will be allocated by the library
- * @param[out] signature_len  Length of a newly created signature
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- */
-int dcm_create_signature(const void *key_ctx, dcm_digest_algorithm_e md,
-                         const char *message, size_t message_len,
-                         char **signature, size_t *signature_len);
-
-/**
- * @brief Handle to a struct containing E2EE message bundle
- * @since_tizen 7.5
- */
-typedef struct dcm_e2ee_bundle_s* dcm_e2ee_bundle_h;
-
-/**
- * @platform
- * @brief Creates an E2EE message bundle from a binary message.
- * @since_tizen 7.5
- *
- * @param[in] message  The binary message. Usually received from another E2EE peer. The @a message
- *                     must be allocated with malloc(). The bundle takes the ownership of the
- *                     @a message and will free it automatically using free().
- * @param[in] message_len  Length of the @a message
- * @param[out] bundle  Bundle allowing deserialization of the E2EE message. Must be freed with
- *                     dcm_e2ee_free_bundle() when no longer needed.
- *
- * @return #DCM_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid (message = NULL or bundle = NULL)
- *                                      or the message format is invalid.
- * @retval #DCM_ERROR_NOT_SUPPORTED The message is not in Tizen platform format.
- *
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_create_bundle(unsigned char *message, size_t message_len, dcm_e2ee_bundle_h* bundle);
-
-/**
- * @platform
- * @brief Releases the memory associated with E2EE message bundle.
- * @since_tizen 7.5
- *
- * @remarks It will free the underlying binary message.
- *
- * @param[in] bundle  Bundle to be freed
- *
- * @see dcm_e2ee_create_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-void dcm_e2ee_free_bundle(dcm_e2ee_bundle_h bundle);
-
-/**
- * @platform
- * @brief Retrieves a pointer to the whole binary message contained in the E2EE bundle.
- * @since_tizen 7.5
- *
- * @remarks The typical use is to retrieve the message from a bundle created and signed with
- *          dcm_e2ee_create_signed_bundle()
- *
- * @param[in] bundle  The bundle to retrieve from
- * @param[out] message  The pointer to the binary message contained in the @a bundle. The pointer
- *                      must not be freed. The pointer becomes invalid after the @a bundle is freed
- * @param[out] message_len  The length of the @a message
- *
- * @return #DCM_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle, @a message or @a message_len is NULL.
- *
- * @see dcm_e2ee_create_signed_bundle()
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_get_bundle_message(const dcm_e2ee_bundle_h bundle,
-                                const unsigned char** message,
-                                size_t* message_len);
-
-/**
- * @platform
- * @brief Retrieves a pointer to the platform string contained in the E2EE bundle.
- * @since_tizen 7.5
- *
- * @remarks The typical use is to retrieve the platform string from a bundle created with
- *          dcm_e2ee_create_bundle() from received binary message.
- *
- * @param[in] bundle  The bundle to retrieve from
- * @param[out] platform  The pointer to the platform string contained in the @a bundle. The pointer
- *                       must not be freed. The pointer becomes invalid after the @a bundle is freed
- *
- * @return #DCM_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle or @a platform is NULL.
- *
- * @see dcm_e2ee_create_bundle()
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_get_bundle_platform(const dcm_e2ee_bundle_h bundle, const char** platform);
-
-/**
- * @platform
- * @brief Retrieves a pointer to the package id string contained in the E2EE bundle.
- * @since_tizen 7.5
- *
- * @remarks The typical use is to retrieve the package id from a bundle created with
- *          dcm_e2ee_create_bundle() from received binary message.
- *
- * @param[in] bundle  The bundle to retrieve from
- * @param[out] pkg_id  The pointer to the package id string contained in the @a bundle. The pointer
- *                     must not be freed. The pointer becomes invalid after the @a bundle is freed
- *
- * @return #DCM_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle or @a pkg_id is NULL.
- *
- * @see dcm_e2ee_create_bundle()
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_get_bundle_pkg_id(const dcm_e2ee_bundle_h bundle, const char** pkg_id);
-
-/**
- * @platform
- * @brief Retrieves a pointer to the payload byte sequence contained in the E2EE bundle.
- * @since_tizen 7.5
- *
- * @remarks The typical use is to retrieve the binary payload from a bundle created with
- *          dcm_e2ee_create_bundle() from received binary message.
- *
- * @param[in] bundle  The bundle to retrieve from
- * @param[out] payload  The pointer to the payload byte sequence contained in the @a bundle. The
- *                      pointer must not be freed. The pointer becomes invalid after the @a bundle
- *                      is freed
- * @param[out] payload_len  The length of the @a payload
- *
- * @return #DCM_ERROR_NONE on success, otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle, @a payload or @a payload_len is NULL.
- *
- * @see dcm_e2ee_create_bundle()
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_get_bundle_payload(const dcm_e2ee_bundle_h bundle,
-                                const unsigned char** payload,
-                                size_t* payload_len);
-
-/**
- * @platform
- * @brief Creates an E2EE message bundle from a payload and signs it using given private key.
- * @since_tizen 7.5
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/devicecertificate
- *
- * @remarks The private key is identified by @a key_ctx.
- * @remarks The @a payload can be NULL but then @a payload_len must be 0.
- * @remarks The @a signature should be freed using free().
- *
- * @param[in] key_ctx  Key context object that identifies a proper private key for signing
- * @param[in] md  Message digest algorithm used in creating signature
- * @param[in] payload  Byte sequence used to construct the E2EE message that will be signed
- * @param[in] payload_len  Length of the @a payload
- * @param[out] bundle  Newly created bundle containing the signed E2EE message. Must be freed with
- *                     dcm_e2ee_free_bundle() when no longer needed
- * @param[out] signature  Newly created signature, will be allocated by the library. Must be freed
- *                        using free() when no longer needed
- * @param[out] signature_len  Length of a newly created @a signature
- *
- * @return #DCM_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_ERROR_NONE Successful
- * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid (@a key_ctx = NULL, @a payload =
- *                                      NULL but @a payload_len > 0, @a bundle = NULL, @a signature
- *                                      = NULL or @a signature_len = NULL)
- * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
- * @retval #DCM_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_ERROR_UNKNOWN Unknown error
- *
- * @see dcm_e2ee_free_bundle()
- * @see #dcm_e2ee_bundle_h
- */
-int dcm_e2ee_create_signed_bundle(const void *key_ctx,
-                                  dcm_digest_algorithm_e md,
-                                  const unsigned char *payload,
-                                  size_t payload_len,
-                                  dcm_e2ee_bundle_h* bundle,
-                                  char **signature,
-                                  size_t *signature_len);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DEVICE_CERTIFICATE_MANAGER_H__ */
diff --git a/src/dcm-client/device_certificate_manager_ext.h b/src/dcm-client/device_certificate_manager_ext.h
deleted file mode 100644 (file)
index 94f8528..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/******************************************************************
- *
- * Copyright 2021 Samsung Electronics All Rights Reserved.
- *
- * 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 __DEVICE_CERTIFICATE_MANAGER_EXT_H__
-#define __DEVICE_CERTIFICATE_MANAGER_EXT_H__
-
-#include <stddef.h>
-
-#include "device_certificate_manager_ext_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * @platform
- * @brief Calls dcm_ext_backend_call_api in the DCM backend with specified method name & arguments.
- * @since_tizen 6.5
- * @privlevel platform
- * @privilege custom one, defined by the backend for given method call
- *
- * @remarks To know which privilege is checked on the API call, please consult implementation of given method in DCM backend.
- * @remarks Both: input and output buffers can be passed as NULLs, if the method doesn't expect or return any data.
- *
- * @param[in] method_name  Name of method to be called within DCM backend
- * @param[in] input_data  Serialized input data for the method call - client should know data format expected by DCM backend
- * @param[in] input_len  Length of the input data in bytes
- * @param[out] output_data Output from the DCM backend method call, will be allocated by the library, to be released with free() by client
- * @param[out] output_len Lenght of the output data in bytes
- * @return #DCM_EXT_ERROR_NONE on success,
- *         otherwise a negative error value
- *
- * @retval #DCM_EXT_ERROR_NONE Successful
- * @retval #DCM_EXT_ERROR_INVALID_PARAMETER Input parameter is invalid
- * @retval #DCM_EXT_ERROR_OUT_OF_MEMORY Out of memory during processing
- * @retval #DCM_EXT_ERROR_PERMISSION_DENIED Failed to access device certificate manager
- * @retval #DCM_EXT_ERROR_NOT_SUPPORTED DCM backend supporting the API call requested is not loaded on daemon side
- * @retval #DCM_EXT_ERROR_SOCKET Socket error between client and server
- * @retval #DCM_EXT_ERROR_UNKNOWN Unknown error
- */
-int dcm_ext_call_api(const char* method_name, const char* input_data, size_t input_len,
-                     char** output_data, size_t* output_len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DEVICE_CERTIFICATE_MANAGER_EXT_H__ */
diff --git a/src/dcm-client/device_certificate_manager_ext_types.h b/src/dcm-client/device_certificate_manager_ext_types.h
deleted file mode 100644 (file)
index 38a178a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/******************************************************************
- *
- * Copyright 2021 Samsung Electronics All Rights Reserved.
- *
- * 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 __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__
-#define __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__
-
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Enumeration for DCM EXT error values.
- * @since_tizen 6.5
- */
-typedef enum {
-    DCM_EXT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-    DCM_EXT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
-    DCM_EXT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-    DCM_EXT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-    DCM_EXT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< DCM backend supporting the API call requested is not loaded on daemon side */
-    DCM_EXT_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
-    DCM_EXT_ERROR_SOCKET = TIZEN_ERROR_DEVICE_CERTIFICATE_MANAGER | 0x01, /**< Socket error between client and server */
-} dcm_ext_error_e;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__ */
index b6612944b9654db2a7462dbdb97ac8ede5dad45b..960dcfee5808f2485385338410b8dc891a52dad0 100644 (file)
@@ -34,7 +34,7 @@ PKG_CHECK_MODULES(DAEMON_DEPS
 
 INCLUDE_DIRECTORIES(SYSTEM ${DAEMON_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
 LINK_DIRECTORIES(${DAEMON_DEPS_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ../include ../shared)
 
 PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ../dcm-client/dcm_support.proto)
 
index bea5811d3a9256ee20a676b411b9cefbdd315b5c..b585bcf0617c9224b74b1f47d66a4caebe8ad2cd 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "dcm_session.h"
 #include "dcm_server.h"
-#include "../dcm-client/device_certificate_manager_ext_types.h"
-#include "../dcm-client/device_certificate_manager.h"
+#include "device_certificate_manager_ext_types.h"
+#include "device_certificate_manager.h"
 #include "log.h"
 #include "bundle.h"
 
diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2a3c1e3
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    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        include/CMakeLists.txt
+# @author      Dariusz Michaluk <d.michaluk@samsung.com>
+
+INSTALL(FILES
+    device_certificate_manager.h
+    device_certificate_manager_ext.h
+    device_certificate_manager_ext_types.h
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/device-certificate-manager)
+
diff --git a/src/include/device_certificate_manager.h b/src/include/device_certificate_manager.h
new file mode 100644 (file)
index 0000000..db4c2d6
--- /dev/null
@@ -0,0 +1,428 @@
+/******************************************************************
+ *
+ * Copyright 2017 - 2018 Samsung Electronics All Rights Reserved.
+ *
+ * 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 __DEVICE_CERTIFICATE_MANAGER_H__
+#define __DEVICE_CERTIFICATE_MANAGER_H__
+
+#include <stddef.h>
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_DEVICE_CERTIFICATE_MANAGER_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Enumeration for DCM error values.
+ * @since_tizen 5.0
+ */
+typedef enum {
+    DCM_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+    DCM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
+    DCM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+    DCM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+    DCM_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Feature needed to run API is not supported */
+    DCM_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */
+    DCM_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+
+    DCM_ERROR_SOCKET = TIZEN_ERROR_DEVICE_CERTIFICATE_MANAGER | 0x01, /**< Socket error between client and server */
+} dcm_error_e;
+
+
+/**
+ * @brief Enumeration for DCM message digest algorithms.
+ * @since_tizen 5.0
+ */
+typedef enum {
+    DCM_DIGEST_NONE=0, /**< No message digest algorithm */
+    DCM_DIGEST_MD2, /**< Message digest algorithm MD2 */
+    DCM_DIGEST_MD4, /**< Message digest algorithm MD4 */
+    DCM_DIGEST_MD5, /**< Message digest algorithm MD5 */
+    DCM_DIGEST_SHA1, /**< Message digest algorithm SHA1 */
+    DCM_DIGEST_SHA224, /**< Message digest algorithm SHA224 */
+    DCM_DIGEST_SHA256, /**< Message digest algorithm SHA256 */
+    DCM_DIGEST_SHA384, /**< Message digest algorithm SHA384 */
+    DCM_DIGEST_SHA512, /**< Message digest algorithm SHA512 */
+    DCM_DIGEST_RIPEMD160, /**< Message digest algorithm RIPEMD160 */
+} dcm_digest_algorithm_e;
+
+
+/**
+ * @platform
+ * @brief Creates a new key context based on specific name indication (service name, key usage, key type).
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @remarks The @a key_ctx should be freed with dcm_free_key_context() after use.
+ *
+ * @param[in] service  Service name indicates first category name (if null, default value is used)
+ * @param[in] usage  Usage name indicates sub-category name (if null, default value is used)
+ * @param[in] key_type  Key type name indication (if null, default value is used)
+ * @param[out] key_ctx  Newly created key context
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ *
+ * @see dcm_free_key_context()
+ */
+int dcm_create_key_context(const char *service, const char *usage, const char *key_type, void **key_ctx);
+
+
+/**
+ * @platform
+ * @brief Destroys the key context that was created by calling dcm_create_key_context().
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @param[in] key_ctx  Key context object to be deallocated
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_NO_DATA No such key context object
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ *
+ * @see dcm_create_key_context()
+ */
+int dcm_free_key_context(void *key_ctx);
+
+
+/**
+ * @platform
+ * @brief Returns a certificate chain which was pre-injected in device.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @remarks The @a cert_chain should be freed using free().
+ *
+ * @param[in] key_ctx  Key context object that identifies proper certificate chain
+ * @param[out] cert_chain  Certificate chain in binary, will be allocated by the library
+ * @param[out] cert_chain_len  The total length of certificate chain
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_NO_DATA No certificate chain available
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ */
+int dcm_get_certificate_chain(const void *key_ctx, char **cert_chain, size_t *cert_chain_len);
+
+
+/**
+ * @platform
+ * @brief Returns the key size in bits for a given key context.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @param[in] key_ctx  Key context object that identifies proper certificate chain
+ * @param[out] key_bit_len  Key length in bits
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_NO_DATA No certificate chain available
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ */
+int dcm_get_key_bit_length(const void *key_ctx, size_t *key_bit_len);
+
+
+/**
+ * @platform
+ * @brief Returns the key type name for a given key context.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @remarks The @a key_type should be freed using free().
+ *
+ * @param[in] key_ctx  Key context object that identifies proper certificate chain
+ * @param[out] key_type  Key type name (UNKNOWN, RSA or ECDSA), will be allocated by the library
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_NO_DATA No certificate chain available
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ */
+int dcm_get_key_type(const void *key_ctx, char **key_type);
+
+/**
+ * @platform
+ * @brief Creates a signature on a given data using a private key and returns the signature.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @remarks The private key is identified by @a key_ctx.
+ * @remarks The @a message can be NULL but then @a message_len must be 0.
+ * @remarks The @a signature should be freed using free().
+ *
+ * @param[in] key_ctx  Key context object that identifies a proper private key for signing
+ * @param[in] md  Message digest algorithm used in creating signature
+ * @param[in] message  Message that is signed with a key
+ * @param[in] message_len  Length of the message
+ * @param[out] signature  Newly created signature, will be allocated by the library
+ * @param[out] signature_len  Length of a newly created signature
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ */
+int dcm_create_signature(const void *key_ctx, dcm_digest_algorithm_e md,
+                         const char *message, size_t message_len,
+                         char **signature, size_t *signature_len);
+
+/**
+ * @brief Handle to a struct containing E2EE message bundle
+ * @since_tizen 7.5
+ */
+typedef struct dcm_e2ee_bundle_s* dcm_e2ee_bundle_h;
+
+/**
+ * @platform
+ * @brief Creates an E2EE message bundle from a binary message.
+ * @since_tizen 7.5
+ *
+ * @param[in] message  The binary message. Usually received from another E2EE peer. The @a message
+ *                     must be allocated with malloc(). The bundle takes the ownership of the
+ *                     @a message and will free it automatically using free().
+ * @param[in] message_len  Length of the @a message
+ * @param[out] bundle  Bundle allowing deserialization of the E2EE message. Must be freed with
+ *                     dcm_e2ee_free_bundle() when no longer needed.
+ *
+ * @return #DCM_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid (message = NULL or bundle = NULL)
+ *                                      or the message format is invalid.
+ * @retval #DCM_ERROR_NOT_SUPPORTED The message is not in Tizen platform format.
+ *
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_create_bundle(unsigned char *message, size_t message_len, dcm_e2ee_bundle_h* bundle);
+
+/**
+ * @platform
+ * @brief Releases the memory associated with E2EE message bundle.
+ * @since_tizen 7.5
+ *
+ * @remarks It will free the underlying binary message.
+ *
+ * @param[in] bundle  Bundle to be freed
+ *
+ * @see dcm_e2ee_create_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+void dcm_e2ee_free_bundle(dcm_e2ee_bundle_h bundle);
+
+/**
+ * @platform
+ * @brief Retrieves a pointer to the whole binary message contained in the E2EE bundle.
+ * @since_tizen 7.5
+ *
+ * @remarks The typical use is to retrieve the message from a bundle created and signed with
+ *          dcm_e2ee_create_signed_bundle()
+ *
+ * @param[in] bundle  The bundle to retrieve from
+ * @param[out] message  The pointer to the binary message contained in the @a bundle. The pointer
+ *                      must not be freed. The pointer becomes invalid after the @a bundle is freed
+ * @param[out] message_len  The length of the @a message
+ *
+ * @return #DCM_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle, @a message or @a message_len is NULL.
+ *
+ * @see dcm_e2ee_create_signed_bundle()
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_get_bundle_message(const dcm_e2ee_bundle_h bundle,
+                                const unsigned char** message,
+                                size_t* message_len);
+
+/**
+ * @platform
+ * @brief Retrieves a pointer to the platform string contained in the E2EE bundle.
+ * @since_tizen 7.5
+ *
+ * @remarks The typical use is to retrieve the platform string from a bundle created with
+ *          dcm_e2ee_create_bundle() from received binary message.
+ *
+ * @param[in] bundle  The bundle to retrieve from
+ * @param[out] platform  The pointer to the platform string contained in the @a bundle. The pointer
+ *                       must not be freed. The pointer becomes invalid after the @a bundle is freed
+ *
+ * @return #DCM_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle or @a platform is NULL.
+ *
+ * @see dcm_e2ee_create_bundle()
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_get_bundle_platform(const dcm_e2ee_bundle_h bundle, const char** platform);
+
+/**
+ * @platform
+ * @brief Retrieves a pointer to the package id string contained in the E2EE bundle.
+ * @since_tizen 7.5
+ *
+ * @remarks The typical use is to retrieve the package id from a bundle created with
+ *          dcm_e2ee_create_bundle() from received binary message.
+ *
+ * @param[in] bundle  The bundle to retrieve from
+ * @param[out] pkg_id  The pointer to the package id string contained in the @a bundle. The pointer
+ *                     must not be freed. The pointer becomes invalid after the @a bundle is freed
+ *
+ * @return #DCM_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle or @a pkg_id is NULL.
+ *
+ * @see dcm_e2ee_create_bundle()
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_get_bundle_pkg_id(const dcm_e2ee_bundle_h bundle, const char** pkg_id);
+
+/**
+ * @platform
+ * @brief Retrieves a pointer to the payload byte sequence contained in the E2EE bundle.
+ * @since_tizen 7.5
+ *
+ * @remarks The typical use is to retrieve the binary payload from a bundle created with
+ *          dcm_e2ee_create_bundle() from received binary message.
+ *
+ * @param[in] bundle  The bundle to retrieve from
+ * @param[out] payload  The pointer to the payload byte sequence contained in the @a bundle. The
+ *                      pointer must not be freed. The pointer becomes invalid after the @a bundle
+ *                      is freed
+ * @param[out] payload_len  The length of the @a payload
+ *
+ * @return #DCM_ERROR_NONE on success, otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER @a bundle, @a payload or @a payload_len is NULL.
+ *
+ * @see dcm_e2ee_create_bundle()
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_get_bundle_payload(const dcm_e2ee_bundle_h bundle,
+                                const unsigned char** payload,
+                                size_t* payload_len);
+
+/**
+ * @platform
+ * @brief Creates an E2EE message bundle from a payload and signs it using given private key.
+ * @since_tizen 7.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/devicecertificate
+ *
+ * @remarks The private key is identified by @a key_ctx.
+ * @remarks The @a payload can be NULL but then @a payload_len must be 0.
+ * @remarks The @a signature should be freed using free().
+ *
+ * @param[in] key_ctx  Key context object that identifies a proper private key for signing
+ * @param[in] md  Message digest algorithm used in creating signature
+ * @param[in] payload  Byte sequence used to construct the E2EE message that will be signed
+ * @param[in] payload_len  Length of the @a payload
+ * @param[out] bundle  Newly created bundle containing the signed E2EE message. Must be freed with
+ *                     dcm_e2ee_free_bundle() when no longer needed
+ * @param[out] signature  Newly created signature, will be allocated by the library. Must be freed
+ *                        using free() when no longer needed
+ * @param[out] signature_len  Length of a newly created @a signature
+ *
+ * @return #DCM_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_ERROR_NONE Successful
+ * @retval #DCM_ERROR_INVALID_PARAMETER Input parameter is invalid (@a key_ctx = NULL, @a payload =
+ *                                      NULL but @a payload_len > 0, @a bundle = NULL, @a signature
+ *                                      = NULL or @a signature_len = NULL)
+ * @retval #DCM_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_ERROR_NOT_SUPPORTED Feature needed to run API is not supported
+ * @retval #DCM_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_ERROR_UNKNOWN Unknown error
+ *
+ * @see dcm_e2ee_free_bundle()
+ * @see #dcm_e2ee_bundle_h
+ */
+int dcm_e2ee_create_signed_bundle(const void *key_ctx,
+                                  dcm_digest_algorithm_e md,
+                                  const unsigned char *payload,
+                                  size_t payload_len,
+                                  dcm_e2ee_bundle_h* bundle,
+                                  char **signature,
+                                  size_t *signature_len);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DEVICE_CERTIFICATE_MANAGER_H__ */
diff --git a/src/include/device_certificate_manager_ext.h b/src/include/device_certificate_manager_ext.h
new file mode 100644 (file)
index 0000000..94f8528
--- /dev/null
@@ -0,0 +1,64 @@
+/******************************************************************
+ *
+ * Copyright 2021 Samsung Electronics All Rights Reserved.
+ *
+ * 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 __DEVICE_CERTIFICATE_MANAGER_EXT_H__
+#define __DEVICE_CERTIFICATE_MANAGER_EXT_H__
+
+#include <stddef.h>
+
+#include "device_certificate_manager_ext_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @platform
+ * @brief Calls dcm_ext_backend_call_api in the DCM backend with specified method name & arguments.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege custom one, defined by the backend for given method call
+ *
+ * @remarks To know which privilege is checked on the API call, please consult implementation of given method in DCM backend.
+ * @remarks Both: input and output buffers can be passed as NULLs, if the method doesn't expect or return any data.
+ *
+ * @param[in] method_name  Name of method to be called within DCM backend
+ * @param[in] input_data  Serialized input data for the method call - client should know data format expected by DCM backend
+ * @param[in] input_len  Length of the input data in bytes
+ * @param[out] output_data Output from the DCM backend method call, will be allocated by the library, to be released with free() by client
+ * @param[out] output_len Lenght of the output data in bytes
+ * @return #DCM_EXT_ERROR_NONE on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DCM_EXT_ERROR_NONE Successful
+ * @retval #DCM_EXT_ERROR_INVALID_PARAMETER Input parameter is invalid
+ * @retval #DCM_EXT_ERROR_OUT_OF_MEMORY Out of memory during processing
+ * @retval #DCM_EXT_ERROR_PERMISSION_DENIED Failed to access device certificate manager
+ * @retval #DCM_EXT_ERROR_NOT_SUPPORTED DCM backend supporting the API call requested is not loaded on daemon side
+ * @retval #DCM_EXT_ERROR_SOCKET Socket error between client and server
+ * @retval #DCM_EXT_ERROR_UNKNOWN Unknown error
+ */
+int dcm_ext_call_api(const char* method_name, const char* input_data, size_t input_len,
+                     char** output_data, size_t* output_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DEVICE_CERTIFICATE_MANAGER_EXT_H__ */
diff --git a/src/include/device_certificate_manager_ext_types.h b/src/include/device_certificate_manager_ext_types.h
new file mode 100644 (file)
index 0000000..38a178a
--- /dev/null
@@ -0,0 +1,46 @@
+/******************************************************************
+ *
+ * Copyright 2021 Samsung Electronics All Rights Reserved.
+ *
+ * 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 __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__
+#define __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enumeration for DCM EXT error values.
+ * @since_tizen 6.5
+ */
+typedef enum {
+    DCM_EXT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+    DCM_EXT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
+    DCM_EXT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+    DCM_EXT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+    DCM_EXT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< DCM backend supporting the API call requested is not loaded on daemon side */
+    DCM_EXT_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+    DCM_EXT_ERROR_SOCKET = TIZEN_ERROR_DEVICE_CERTIFICATE_MANAGER | 0x01, /**< Socket error between client and server */
+} dcm_ext_error_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DEVICE_CERTIFICATE_MANAGER_EXT_TYPES_H__ */
index 2921cf71d2cf3a9cdc7f54b846f34ecf854f36db..7120aead40883c43393a7714a0ed945a07a9cc2f 100644 (file)
@@ -21,7 +21,7 @@
 #include <cstring>
 
 #include "bundle.h"
-#include "../dcm-client/device_certificate_manager.h"
+#include "device_certificate_manager.h"
 
 namespace {
 constexpr char PLATFORM[] = "Tizen";
index 3f0aed4e6224223d56e615219755c2277338d8e3..075a7574f6dafff2411b141f8acc2ff4ffef5170 100644 (file)
@@ -52,7 +52,7 @@ PKG_CHECK_MODULES(TEST_DEPS REQUIRED dlog libsmack)
 
 INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS} ${TEST_DEPS_INCLUDE_DIRS})
 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS} ${TEST_DEPS_LIBRARY_DIRS})
-INCLUDE_DIRECTORIES(../src/dcm-client ../src/dcm-daemon ../src/shared)
+INCLUDE_DIRECTORIES(../src/dcm-client ../src/dcm-daemon ../src/shared ../src/include)
 
 ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)