aboutsummaryrefslogtreecommitdiffstats
path: root/libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_CryptoSuite.h
blob: 68e90749b22b90d0e7c0fa3e0a54e11bc2af9255 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file ccnxCodecSchemaV1_CryptoSuite.h
 * @brief Translates between PARC CryptoSuite values and the wire encoding
 *
 * <#Detailed Description#>
 *
 */

#include <stdbool.h>
#include <parc/security/parc_CryptoHashType.h>
#include <parc/security/parc_SigningAlgorithm.h>
#include <ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_TlvDictionary.h>

/**
 * Converts a PARC Crypto Suite to its TLV value
 *
 * Looks up the PARC cryptosuite value and returns the corresponding TLV wire format value.
 * If no match is found, returns false and outputSuite is not modified.
 *
 *
 * @param [in] parcSuite The PARC cryptosuite
 * @param [out] outputValue The wire encoding equivalent
 *
 * @retval true if supported suite and outputValue set.
 * @retval false if not supported.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool ccnxCodecSchemaV1CryptoSuite_ParcToTlv(PARCCryptoSuite parcSuite, CCNxCodecSchemaV1TlvDictionary_CryptoSuite *outputValue);

/**
 * Converts a wire format cryptosuite value to the PARC cryptosuite
 *
 * Looks up the TLV wire format value and returns the corresponding PARC cryptosuite.
 * If no match is found, returns false and outputSuite is not modified.
 *
 * @param [in] tlvValue The wire format value
 * @param [out] outputValue The PARC equivalent
 *
 * @return true if match found and parcSuite set.
 * @return false if no match found.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool ccnxCodecSchemaV1CryptoSuite_TlvToParc(CCNxCodecSchemaV1TlvDictionary_CryptoSuite tlvValue, PARCCryptoSuite *outputSuite);

/**
 * Lookup a signing algorithm and hash type and convert to a wire format value
 *
 * Based on a PARCSigner's algorithm and hash type, find the corresponding wire format crypto suite.
 *
 * @param [in] signAlgorithm The signing algorithm
 * @param [in] hashType The hash used by the signing algorithm
 * @param [out] outputValue The wire format value
 *
 * @retval true if supported suite and outputValue set.
 * @retval false if not supported.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool ccnxCodecSchemaV1CryptoSuite_SignAndHashToTlv(PARCSigningAlgorithm signAlgorithm, PARCCryptoHashType hashType, CCNxCodecSchemaV1TlvDictionary_CryptoSuite *outputValue);