tls_certificate.h
Go to the documentation of this file.
1 /**
2  * @file tls_certificate.h
3  * @brief X.509 certificate handling
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 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 2.4.0
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 TlsCertDesc *cert, const uint8_t *certTypes, size_t numCertTypes,
58  const TlsSupportedGroupList *curveList,
59  const TlsSignSchemeList *certSignAlgoList,
60  const TlsCertAuthorities *certAuthorities);
61 
63  const X509CertInfo *certInfo, uint_t pathLen, const char_t *subjectName);
64 
66  TlsCertificateType *certType, TlsNamedGroup *namedCurve);
67 
69  TlsSignatureScheme *signScheme);
70 
72  const X509SubjectPublicKeyInfo *subjectPublicKeyInfo);
73 
74 error_t tlsCheckKeyUsage(const X509CertInfo *certInfo,
75  TlsConnectionEnd entity, TlsKeyExchMethod keyExchMethod);
76 
77 //C++ guard
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
uint8_t p
Definition: ndp.h:300
Certificate descriptor.
Definition: tls.h:2064
X.509 certificate.
Definition: x509_common.h:1064
Subject Public Key Information extension.
Definition: x509_common.h:783
uint8_t length
Definition: tcp.h:368
TLS (Transport Layer Security)
TlsCertAuthorities
Definition: tls.h:1544
TlsKeyExchMethod
Key exchange methods.
Definition: tls.h:1123
TlsSignatureScheme
Signature schemes.
Definition: tls.h:1230
TlsSupportedGroupList
Definition: tls.h:1634
TlsCertificateType
Certificate types.
Definition: tls.h:1169
TlsSignSchemeList
Definition: tls.h:1522
#define TlsContext
Definition: tls.h:36
TlsConnectionEnd
TLS connection end.
Definition: tls.h:952
TlsNamedGroup
Named groups.
Definition: tls.h:1352
error_t tlsParseCertificateList(TlsContext *context, const uint8_t *p, size_t length)
Parse certificate chain.
error_t tlsFormatRawPublicKey(TlsContext *context, uint8_t *p, size_t *written)
Format raw public key.
error_t tlsCheckKeyUsage(const X509CertInfo *certInfo, TlsConnectionEnd entity, TlsKeyExchMethod keyExchMethod)
Check certificate key usage.
error_t tlsParseRawPublicKey(TlsContext *context, const uint8_t *p, size_t length)
Parse raw public key.
bool_t tlsIsCertificateAcceptable(TlsContext *context, const TlsCertDesc *cert, const uint8_t *certTypes, size_t numCertTypes, const TlsSupportedGroupList *curveList, const TlsSignSchemeList *certSignAlgoList, const TlsCertAuthorities *certAuthorities)
Check whether a certificate is acceptable.
error_t tlsValidateCertificate(TlsContext *context, const X509CertInfo *certInfo, uint_t pathLen, const char_t *subjectName)
Verify certificate against root CAs.
error_t tlsGetCertificateSignAlgo(const X509CertInfo *certInfo, TlsSignatureScheme *signScheme)
Retrieve the signature algorithm used to sign the certificate.
error_t tlsReadSubjectPublicKey(TlsContext *context, const X509SubjectPublicKeyInfo *subjectPublicKeyInfo)
Extract the subject public key from the received certificate.
error_t tlsFormatCertificateList(TlsContext *context, uint8_t *p, size_t *written)
Format certificate chain.
error_t tlsGetCertificateType(const X509CertInfo *certInfo, TlsCertificateType *certType, TlsNamedGroup *namedCurve)
Retrieve the certificate type.
X.509 common definitions.