1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0
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.
20 ******************************************************************/
29 #include "byte_array.h"
30 #include "pki_errors.h"
33 * @struct CertificateX509
35 * Certificate structure.
37 * Structure fields contain byte arrays pointed to relative DER certificate positions.
41 ByteArray tbs; /**< TBS certificate.*/
42 ByteArray serNum; /**< Serial number.*/
43 ByteArray pubKey; /**< Public key.*/
45 ByteArray signR; /**< Signature r value.*/
46 ByteArray signS; /**< Signature s value.*/
48 ByteArray issuer; /**< Issuer name.*/
49 ByteArray subject; /**< Subject name.*/
51 ByteArray validFrom; /**< Start time of certificate validity. */
52 ByteArray validTo; /**< End time of certificate validity. */
57 * Reads certificate from byte array and write it into certificate structure.
59 * @param[in] code Byte array with DER encoded certificate
60 * @param[out] crt Pointer to certificate structure
61 * @return PKI_SUCCESS if successful
63 PKIError DecodeCertificate(ByteArray code, CertificateX509 *crt);
66 * Parse ECDSA public key, remove ASN.1 extra bytes.
68 * @param ByteArray structure which contains public key
69 * @return PKI_SUCCESS if public key is correct, error code in case of invalid key
71 PKIError ParsePublicKey(ByteArray *caPublicKey);