Add manufacturer certificate
[platform/upstream/iotivity.git] / resource / csdk / security / src / pkix_interface.c
1 //******************************************************************
2 //
3 // Copyright 2016 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include "pkix_interface.h"
22 #include "credresource.h"
23 #include "crlresource.h"
24 #include "srmresourcestrings.h"
25 #include "logger.h"
26
27 #define TAG "OIC_SRM_PKIX_INTERFACE"
28
29 void GetPkixInfo(PkiInfo_t * inf)
30 {
31     OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
32     if (NULL == inf)
33     {
34         OIC_LOG(ERROR, TAG, "NULL passed");
35         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
36         return;
37     }
38     GetDerOwnCert(&inf->crt, PRIMARY_CERT);
39     GetDerKey(&inf->key, PRIMARY_CERT);
40     GetDerCaCert(&inf->ca, TRUST_CA);
41     GetDerCrl(&inf->crl);
42     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
43 }
44
45 void GetManufacturerPkixInfo(PkiInfo_t * inf)
46 {
47     OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
48     if (NULL == inf)
49     {
50         OIC_LOG(ERROR, TAG, "NULL passed");
51         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
52         return;
53     }
54     GetDerOwnCert(&inf->crt, MF_PRIMARY_CERT);
55     GetDerKey(&inf->key, MF_PRIMARY_CERT);
56     GetDerCaCert(&inf->ca, MF_TRUST_CA);
57     // CRL not provided
58     inf->crl.data = NULL;
59     inf->crl.len = 0;
60     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
61 }
62
63 void InitCipherSuiteList(bool * list)
64 {
65     OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
66     if (NULL == list)
67     {
68         OIC_LOG(ERROR, TAG, "NULL passed");
69         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
70         return;
71     }
72     InitCipherSuiteListInternal(list, TRUST_CA);
73     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
74 }
75
76 void InitManufacturerCipherSuiteList(bool * list)
77 {
78     OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
79     if (NULL == list)
80     {
81         OIC_LOG(ERROR, TAG, "NULL passed");
82         OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
83         return;
84     }
85     InitCipherSuiteListInternal(list, MF_TRUST_CA);
86     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
87 }