The DCM daemon does not need to be modified.
##Testing
-
-There are currently two general testing applications and one KONAI SE specific tool:
+There is currently one general testing application and one KONAI SE specific tool:
- *dcm_api_test*
-- *dcm_example_capi*
-All testing applications should be executed after implementing changes to the DCM or to the DCM backend repository.
+Testing application should be executed after implementing changes to the DCM or to the DCM backend repository.
There is also one KONAI SE specific tool: *dcm_konaise_tool* used to test the KONAI SE backend implementation.
The list of examples of execution of the *dcm_konaise_tool* is displayed after running the tool in the command line without any arguments.
/******************************************************************
*
- * Copyright 2018 Samsung Electronics All Rights Reserved.
+ * Copyright 2018 - 2020 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.
* To ensure your application is running only on devices with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
* More details on using features in your application can be found in the <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"><b>feature element description</b></a>.
*
- * @section CAPI_PRIVACY_PRIVILEGE_MANAGER_MODULE_OVERVIEW Overview
+ * @section CAPI_DEVICE_CERTIFICATE_MANAGER_MODULE_OVERVIEW Overview
* Device Certificate Manager provides cryptography services (digital certificates and keys)
* for authentication and secure communication with another system.
* Device certificate and key was embedded in device storage.
*
+ * @section CAPI_DEVICE_CERTIFICATE_MANAGER_MODULE_EXAMPLES Examples
+ * Device Certificate Manager API example
+ * @snippet device_certificate_manager_example.c Device Certificate Manager API example
+ *
*/
#endif /* __TIZEN_CORE_DEVICE_CERTIFICATE_MANAGER_DOC_H__ */
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2017 - 2020 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.
+ *
+ ******************************************************************/
+
+/**
+ * @file device_certificate_manager_example.c
+ * @brief Device Certificate Manager API example.
+ */
+
+//! [Device Certificate Manager API example]
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "device_certificate_manager.h"
+
+int main()
+{
+ int result;
+ void *key_ctx = NULL;
+ char *key_type = NULL;
+ size_t key_len;
+ char *cert_chain = NULL;
+ size_t cert_chain_len;
+ char *signature = NULL;
+ size_t signature_len;
+
+ result = dcm_create_key_context("example_client", "test_usage", "", &key_ctx);
+ if (result != DCM_ERROR_NONE) {
+ printf("Can't create context\n");
+ goto exit;
+ }
+
+ result = dcm_get_certificate_chain(key_ctx, &cert_chain, &cert_chain_len);
+ if (result != DCM_ERROR_NONE) {
+ printf("Can't get cert chain\n");
+ goto exit;
+ }
+ printf("Cert is %zu bytes\n", cert_chain_len);
+ printf("Received cert %s\n", cert_chain);
+
+ result = dcm_get_key_type(key_ctx, &key_type);
+ if (result != DCM_ERROR_NONE) {
+ printf("Can't get key type\n");
+ goto exit;
+ }
+
+ result = dcm_get_key_bit_length(key_ctx, &key_len);
+ if (result != DCM_ERROR_NONE) {
+ printf("Can't get key length\n");
+ goto exit;
+ }
+ printf("Private key is %zu bits\n", key_len);
+ printf("Private key is %s\n", key_type);
+
+ result = dcm_create_signature(key_ctx, DCM_DIGEST_SHA256, "12345678901234567890123456789012", 32, &signature, &signature_len);
+ if (result != DCM_ERROR_NONE) {
+ printf("Can't create signature\n");
+ goto exit;
+ }
+
+ for(unsigned int i = 0; i < signature_len; i++) {
+ printf("%x ", (int)(*(unsigned char*)(&signature[i])));
+ }
+ printf("\n");
+
+exit:
+ free(signature);
+ free(cert_chain);
+ free(key_type);
+ dcm_free_key_context(key_ctx);
+
+ return result;
+}
+//! [Device Certificate Manager API example]
%manifest %{name}.manifest
%license LICENSE
%{_bindir}/dcm_api_test
-%{_bindir}/dcm_example_capi
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
-ADD_EXECUTABLE(dcm_example_capi example_capi.c)
-TARGET_LINK_LIBRARIES(dcm_example_capi device-certificate-manager)
-
ADD_EXECUTABLE(dcm_api_test api_test.cpp)
TARGET_LINK_LIBRARIES(dcm_api_test
device-certificate-manager
${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
INSTALL(TARGETS
- dcm_example_capi
dcm_api_test
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2017 - 2019 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.
- *
- ******************************************************************/
-
-#include "device_certificate_manager.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-int main()
-{
- int result;
- void *key_ctx = NULL;
- char *key_type = NULL;
- size_t key_len;
- char *cert_chain = NULL;
- size_t cert_chain_len;
- char *signature = NULL;
- size_t signature_len;
-
- result = dcm_create_key_context("example_client", "test_usage", "", &key_ctx);
- if(result != DCM_ERROR_NONE) {
- printf("Can't create context\n");
- goto exit;
- }
-
- result = dcm_get_key_type(key_ctx, &key_type);
- if(result != DCM_ERROR_NONE) {
- printf("Can't get key type\n");
- goto exit;
- }
- printf("Using key type %s\n", key_type);
-
- result = dcm_get_certificate_chain(key_ctx, &cert_chain, &cert_chain_len);
- if(result != DCM_ERROR_NONE) {
- printf("Can't get cert chain\n");
- goto exit;
- }
- printf("Cert is %zu bytes\n", cert_chain_len);
- printf("Received cert %s\n", cert_chain);
-
- result = dcm_get_key_bit_length(key_ctx, &key_len);
- if(result != DCM_ERROR_NONE) {
- printf("Can't get key length\n");
- goto exit;
- }
- printf("Private key is %zu bits\n", key_len);
- printf("Private key is %s\n", key_type);
-
- result = dcm_create_signature(key_ctx, DCM_DIGEST_SHA256, "12345678901234567890123456789012", 32, &signature, &signature_len);
- if(result != DCM_ERROR_NONE) {
- printf("Can't create signature\n");
- goto exit;
- }
-
- for(unsigned int i = 0; i < signature_len; i++) {
- printf("%x ", (int)(*(unsigned char*)(&signature[i])));
- }
- printf("\n");
-
-exit:
- free(signature);
- free(cert_chain);
- free(key_type);
- dcm_free_key_context(key_ctx);
-
- return result;
-}