ike_sign_misc.h
Go to the documentation of this file.
1 /**
2  * @file ike_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.4
29  **/
30 
31 #ifndef _IKE_SIGN_MISC_H
32 #define _IKE_SIGN_MISC_H
33 
34 //Dependencies
35 #include "ike/ike.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /**
44  * @brief Signature format
45  **/
46 
47 typedef enum
48 {
52 
53 
54 /**
55  * @brief Signature algorithms
56  **/
57 
58 typedef enum
59 {
68 
69 
70 //IKEv2 related functions
71 error_t ikeFormatDsaSignature(const DsaSignature *signature, uint8_t *data,
72  size_t *length, IkeSignFormat format);
73 
75  const EcdsaSignature *signature, uint8_t *data, size_t *length,
76  IkeSignFormat format);
77 
78 error_t ikeParseDsaSignature(const uint8_t *data, size_t length,
79  DsaSignature *signature, IkeSignFormat format);
80 
82  size_t length, EcdsaSignature *signature, IkeSignFormat format);
83 
84 error_t ikeSelectSignAlgoId(IkeCertType certType, const HashAlgo *hashAlgo,
85  X509SignAlgoId *signAlgoId);
86 
87 error_t ikeSelectSignAlgo(const X509SignAlgoId *signAlgoId,
88  IkeSignAlgo *signAlgo, const HashAlgo **hashAlgo);
89 
91  uint16_t preferredHashAlgoId);
92 
93 error_t ikeGetSignedOctets(IkeSaEntry *sa, const uint8_t *id, size_t idLen,
94  uint8_t *macId, DataChunk *messageChunks, bool_t initiator);
95 
97  const uint8_t *id, size_t idLen, uint8_t *digest, bool_t initiator);
98 
99 //C++ guard
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
@ IKE_SIGN_ALGO_ED448
Definition: ike_sign_misc.h:66
@ IKE_SIGN_ALGO_NONE
Definition: ike_sign_misc.h:60
ECDSA signature.
Definition: ecdsa.h:49
IkeCertType
Certificate types.
Definition: ike.h:1222
int bool_t
Definition: compiler_port.h:53
IkeSignAlgo
Signature algorithms.
Definition: ike_sign_misc.h:59
uint8_t data[]
Definition: ethernet.h:222
@ IKE_SIGN_ALGO_RSA
Definition: ike_sign_misc.h:61
EC domain parameters.
Definition: ec.h:76
error_t ikeParseEcdsaSignature(EcDomainParameters *params, const uint8_t *data, size_t length, EcdsaSignature *signature, IkeSignFormat format)
ECDSA signature parsing.
error_t
Error codes.
Definition: error.h:43
error_t ikeParseDsaSignature(const uint8_t *data, size_t length, DsaSignature *signature, IkeSignFormat format)
DSA signature parsing.
@ IKE_SIGN_ALGO_RSA_PSS
Definition: ike_sign_misc.h:62
error_t ikeDigestSignedOctets(IkeSaEntry *sa, const HashAlgo *hashAlgo, const uint8_t *id, size_t idLen, uint8_t *digest, bool_t initiator)
Digest signed octets.
@ IKE_SIGN_FORMAT_ASN1
Definition: ike_sign_misc.h:50
error_t ikeGetSignedOctets(IkeSaEntry *sa, const uint8_t *id, size_t idLen, uint8_t *macId, DataChunk *messageChunks, bool_t initiator)
Retrieve the octets to be signed using EdDSA.
uint8_t length
Definition: tcp.h:368
@ IKE_SIGN_ALGO_DSA
Definition: ike_sign_misc.h:63
IKEv2 (Internet Key Exchange Protocol)
IkeSignFormat
Signature format.
Definition: ike_sign_misc.h:48
Data chunk descriptor.
Definition: crypto.h:981
#define IkeSaEntry
Definition: ike.h:682
error_t ikeSelectSignAlgo(const X509SignAlgoId *signAlgoId, IkeSignAlgo *signAlgo, const HashAlgo **hashAlgo)
Select the signature and hash algorithms that match the specified identifier.
@ IKE_SIGN_FORMAT_RAW
Definition: ike_sign_misc.h:49
error_t ikeFormatEcdsaSignature(EcDomainParameters *params, const EcdsaSignature *signature, uint8_t *data, size_t *length, IkeSignFormat format)
ECDSA signature formatting.
const HashAlgo * ikeSelectSignHashAlgo(IkeSaEntry *sa, uint16_t preferredHashAlgoId)
Select the hash algorithm to be used for signing.
error_t ikeFormatDsaSignature(const DsaSignature *signature, uint8_t *data, size_t *length, IkeSignFormat format)
DSA signature formatting.
Definition: ike_sign_misc.c:55
@ IKE_SIGN_ALGO_ECDSA
Definition: ike_sign_misc.h:64
Common interface for hash algorithms.
Definition: crypto.h:1046
DSA signature.
Definition: dsa.h:84
error_t ikeSelectSignAlgoId(IkeCertType certType, const HashAlgo *hashAlgo, X509SignAlgoId *signAlgoId)
Select the algorithm identifier that matches the specified certificate type and hash algorithms.
@ IKE_SIGN_ALGO_ED25519
Definition: ike_sign_misc.h:65
Signature algorithm identifier.
Definition: x509_common.h:1040