Imported Upstream version 1.0.0
[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 /**@def CRL_INITIALIZER
56  *
57  * Initializes of existing CRL fields to {NULL, 0}.
58  */
59 #undef CRL_INITIALIZER
60 #define CRL_INITIALIZER {BYTE_ARRAY_INITIALIZER,\
61                          BYTE_ARRAY_INITIALIZER,\
62                          BYTE_ARRAY_INITIALIZER,\
63                          BYTE_ARRAY_INITIALIZER,\
64                          BYTE_ARRAY_INITIALIZER}
65
66 #ifdef X509_DEBUG
67 /**
68  * Prints Certificate List to console.
69  *
70  * @param crl - pointer to certificate list structure
71  * @return PKI_SUCCESS if success, error code otherwise
72  */
73 PKIError PrintCRL(const CertificateList *const crl);
74 #endif
75
76 /**
77  * Decodes and checks Certificate List.
78  *
79  * @param code - certificate list structure in DER format
80  * @param crl - pointer to certificate list structure
81  * @param caPubKey - ByteArray structure contains CA public key
82  * @return PKI_SUCCESS if success, error code otherwise
83  */
84 PKIError DecodeCertificateList(ByteArray code, CertificateList *crl,  ByteArray caPubKey);
85
86 #ifdef __cplusplus
87 }
88 #endif //__cplusplus
89 #endif //_CRL_H_