tls_certificate.h
Go to the documentation of this file.
1 /**
2  * @file tls_certificate.h
3  * @brief Certificate handling
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSL Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _TLS_CERTIFICATE_H
32 #define _TLS_CERTIFICATE_H
33 
34 //Dependencies
35 #include "tls.h"
36 #include "pkix/x509_common.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //TLS related functions
44 error_t tlsFormatCertificateList(TlsContext *context, uint8_t *p,
45  size_t *written);
46 
47 error_t tlsFormatRawPublicKey(TlsContext *context, uint8_t *p,
48  size_t *written);
49 
50 error_t tlsParseCertificateList(TlsContext *context, const uint8_t *p,
51  size_t length);
52 
53 error_t tlsParseRawPublicKey(TlsContext *context, const uint8_t *p,
54  size_t length);
55 
57  const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos,
58  const TlsSignHashAlgos *certSignHashAlgos, const TlsSupportedGroupList *curveList,
59  const TlsCertAuthorities *certAuthorities);
60 
62  const X509CertificateInfo *certInfo, uint_t pathLen,
63  const char_t *subjectName);
64 
66  TlsCertificateType *certType, TlsSignatureAlgo *certSignAlgo,
67  TlsHashAlgo *certHashAlgo, TlsNamedGroup *namedCurve);
68 
70  const X509SubjectPublicKeyInfo *subjectPublicKeyInfo);
71 
73  TlsConnectionEnd entity, TlsKeyExchMethod keyExchMethod);
74 
75 //C++ guard
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
X.509 common definitions.
uint8_t length
Definition: dtls_misc.h:149
int bool_t
Definition: compiler_port.h:49
uint8_t p
Definition: ndp.h:298
TlsConnectionEnd
TLS connection end.
Definition: tls.h:859
error_t tlsValidateCertificate(TlsContext *context, const X509CertificateInfo *certInfo, uint_t pathLen, const char_t *subjectName)
Verify certificate against root CAs.
X.509 certificate.
Definition: x509_common.h:920
error_t tlsFormatCertificateList(TlsContext *context, uint8_t *p, size_t *written)
Format certificate chain.
TlsHashAlgo
Hash algorithms.
Definition: tls.h:1092
error_t tlsParseRawPublicKey(TlsContext *context, const uint8_t *p, size_t length)
Parse raw public key.
__start_packed struct @65 TlsSignHashAlgos
List of signature algorithms.
#define TlsContext
Definition: tls.h:36
error_t
Error codes.
Definition: error.h:42
error_t tlsGetCertificateType(const X509CertificateInfo *certInfo, TlsCertificateType *certType, TlsSignatureAlgo *certSignAlgo, TlsHashAlgo *certHashAlgo, TlsNamedGroup *namedCurve)
Retrieve the certificate type.
TlsKeyExchMethod
Key exchange methods.
Definition: tls.h:1024
bool_t tlsIsCertificateAcceptable(TlsContext *context, const TlsCertDesc *cert, const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos, const TlsSignHashAlgos *certSignHashAlgos, const TlsSupportedGroupList *curveList, const TlsCertAuthorities *certAuthorities)
Check whether a certificate is acceptable.
__start_packed struct @67 TlsCertAuthorities
List of certificate authorities.
TlsCertificateType
Certificate types.
Definition: tls.h:1069
Certificate descriptor.
Definition: tls.h:1877
char char_t
Definition: compiler_port.h:43
Subject public key information.
Definition: x509_common.h:694
error_t tlsCheckKeyUsage(const X509CertificateInfo *certInfo, TlsConnectionEnd entity, TlsKeyExchMethod keyExchMethod)
Check certificate key usage.
error_t tlsFormatRawPublicKey(TlsContext *context, uint8_t *p, size_t *written)
Format raw public key.
TlsSignatureAlgo
Signature algorithms.
Definition: tls.h:1109
__start_packed struct @75 TlsSupportedGroupList
List of supported groups.
TLS (Transport Layer Security)
error_t tlsReadSubjectPublicKey(TlsContext *context, const X509SubjectPublicKeyInfo *subjectPublicKeyInfo)
Extract the subject public key from the received certificate.
error_t tlsParseCertificateList(TlsContext *context, const uint8_t *p, size_t length)
Parse certificate chain.
TlsNamedGroup
Named groups.
Definition: tls.h:1205
unsigned int uint_t
Definition: compiler_port.h:45