Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / ck_manager / include / cert_generator.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 INCLUDE_ISSUER_ISSUER_H_
24 #define INCLUDE_ISSUER_ISSUER_H_
25
26 #include "Certificate.h" // Certificate ASN.1 type
27 #include "pki.h"
28 #include "pki_errors.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #define X509_V1 0
35 #define X509_V2 1
36 #define X509_V3 2
37
38 /**
39  * Encodes X.509 certificate with specified parameters.
40  *
41  * @param[in] subjectName pointer to serial subject's common name
42  * @param[in] issuerName pointer to issuer's common name
43  * @param[in] notBefore pointer to certificate validity limit
44  * @param[in] notAfter pointer to certificate validity limit
45  * @param[in] subjectPublicKey pointer to subject's public key to be signed
46  * @param[in] issuerPrivateKey pointer to issuer's private key to sign certificate
47  * @param[out] encodedCertificate pointer to allocated memory for DER encoded certificate
48  *          (ISSUER_MAX_CERT_SIZE bytes should be allocated)
49  * @return PKI_SUCCESS if success, error code otherwise
50  */
51 PKIError GenerateCertificate (const UTF8String_t *subjectName, const UTF8String_t *issuerName,
52                         const UTCTime_t *notBefore, const UTCTime_t *notAfter,
53                         const BIT_STRING_t *subjectPublicKey, const BIT_STRING_t *issuerPrivateKey,
54                         ByteArray *encodedCertificate);
55
56 #ifdef __cplusplus
57 }
58 #endif
59
60 #endif /* INCLUDE_ISSUER_ISSUER_H_ */