tls_sign_misc.h
Go to the documentation of this file.
1 /**
2  * @file tls_sign_misc.h
3  * @brief Helper functions for signature generation and verification
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneIPSEC 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_SIGN_MISC_H
32 #define _TLS_SIGN_MISC_H
33 
34 //Dependencies
35 #include "tls.h"
36 
37 //Extract signature algorithm from legacy signature scheme
38 #define TLS_SIGN_ALGO(signScheme) ((TlsSignatureAlgo) LSB(signScheme))
39 
40 //Extract hash algorithm from legacy signature scheme
41 #define TLS_HASH_ALGO(signScheme) ((TlsHashAlgo) MSB(signScheme))
42 
43 //C++ guard
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 //TLS related functions
49 error_t tlsSelectSignAlgo(TlsContext *context, const TlsCertDesc *cert,
50  const TlsSignSchemeList *signAlgoList);
51 
53  size_t *written);
54 
56  uint8_t *p, size_t *written);
57 
59  size_t *written);
60 
61 bool_t tlsIsSignAlgoOffered(uint16_t signScheme,
62  const TlsSignSchemeList *signSchemeList);
63 
64 bool_t tlsIsSignAlgoAcceptable(TlsContext *context, uint16_t signScheme,
65  const TlsCertDesc *cert);
66 
67 bool_t tlsIsSignAlgoSupported(TlsContext *context, uint16_t signScheme);
68 bool_t tlsIsCertSignAlgoSupported(uint16_t signScheme);
69 
70 //C++ guard
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif
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
TLS (Transport Layer Security)
TlsSignSchemeList
Definition: tls.h:1522
#define TlsContext
Definition: tls.h:36
error_t tlsFormatSignAlgosCertExtension(TlsContext *context, uint8_t *p, size_t *written)
Format SignatureAlgorithmsCert extension.
error_t tlsFormatSupportedSignAlgos(TlsContext *context, uint8_t *p, size_t *written)
Format the list of supported signature algorithms.
bool_t tlsIsSignAlgoOffered(uint16_t signScheme, const TlsSignSchemeList *signSchemeList)
Check whether a signature algorithm is offered in the SignatureAlgorithms extension.
bool_t tlsIsSignAlgoAcceptable(TlsContext *context, uint16_t signScheme, const TlsCertDesc *cert)
Check whether a signature algorithm is compatible with the specified end-entity certificate.
error_t tlsSelectSignAlgo(TlsContext *context, const TlsCertDesc *cert, const TlsSignSchemeList *signAlgoList)
Select the algorithm to be used when generating digital signatures.
Definition: tls_sign_misc.c:85
bool_t tlsIsSignAlgoSupported(TlsContext *context, uint16_t signScheme)
Check whether a signature algorithm can be used for digital signatures.
error_t tlsFormatSignAlgosExtension(TlsContext *context, uint8_t *p, size_t *written)
Format SignatureAlgorithms extension.
bool_t tlsIsCertSignAlgoSupported(uint16_t signScheme)
Check whether a signature algorithm can be used for X.509 certificate validation.