Add certificate verification
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / pkix / crl.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics 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  *      LICENSE-2.0" target="_blank">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
22
23 #ifndef _CRL_H_
24 #define _CRL_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif //__cplusplus
29
30 #include "byte_array.h"
31 #include "pki_errors.h"
32
33 /// Maximal number of revoked certificates in list
34 #ifdef WITH_ARDUINO
35 #define CRL_MAX_LEN              (256)
36 #else
37 #define CRL_MAX_LEN              (1024)
38 #endif // WITH_ARDUINO
39 /**
40  * @struct CertificateList
41  *
42  * CRL structure.
43  *
44  * Structure fields contain byte arrays  pointed to relative DER certificate positions.
45  */
46 typedef struct
47 {
48     ByteArray    tbs;       /**< TBS sequence of CRL.*/
49     ByteArray    issuer;    /**< Issuer name.*/
50     ByteArray    date;      /**< The issue-date for CRL.*/
51     ByteArray    signR;     /**< Signature  r value.*/
52     ByteArray    signS;     /**< Signature  s value.*/
53 } CertificateList;
54
55 #ifdef X509_DEBUG
56 /**
57  * Prints Certificate List to console.
58  *
59  * @param crl - pointer to certificate list structure
60  * @return PKI_SUCCESS if success, error code otherwise
61  */
62 PKIError PrintCRL(const CertificateList *const crl);
63 #endif
64
65 /**
66  * Decodes and checks Certificate List.
67  *
68  * @param code - certificate list structure in DER format
69  * @param crl - pointer to certificate list structure
70  * @param caPubKey - ByteArray structure contains CA public key
71  * @return PKI_SUCCESS if success, error code otherwise
72  */
73 PKIError DecodeCertificateList(ByteArray code, CertificateList *crl,  ByteArray caPubKey);
74
75 #ifdef __cplusplus
76 }
77 #endif //__cplusplus
78 #endif //_CRL_H_