From d18ae43123fcd7604d1c36a1ec8450dbe6071824 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 23 Feb 2017 20:44:26 +0100 Subject: Initial commit: ccnxlibs. Change-Id: I1b376527a7dd01a6b9e083a6cb646955902f45c0 Signed-off-by: Luca Muscariello --- .../ccnxCodecSchemaV1_ValidationEncoder.h | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_ValidationEncoder.h (limited to 'libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_ValidationEncoder.h') diff --git a/libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_ValidationEncoder.h b/libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_ValidationEncoder.h new file mode 100755 index 00000000..3897a053 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_ValidationEncoder.h @@ -0,0 +1,79 @@ +/* + * 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_ValidationEncoder.h + * @brief Encode the Validation Algorithm and Payload + * + * Encodes the validation algorithm and payload from the dictionary. Optionally computes + * a signature if one is not specified in the dictionary and the encoder has a signer. + * + */ + +#ifndef __CCNx_Common__ccnxCodecSchemaV1_ValidationEncoder__ +#define __CCNx_Common__ccnxCodecSchemaV1_ValidationEncoder__ + +#include +#include + +/** + * Appends the Validation Algorithm to the packet encoder + * + * If the dictionary has a CryptoSuite specified, we will create a ValidationAlgorithm section + * and fill it in as per the CryptoSuite and supplied validation algorithm arguments, such as + * a KeyId, KeyName, Cert, etc. For most signatures, only the KeyId is mandatory, the other + * fields will only be specified if the user put something in the dictionary. + * + * the caller is responsible for writing the ValidationAlgorithm TL container. + * + * @param [in] encoder An allocated encoder to append to + * @param [in] packetDictionary The dictionary containing the optional headers + * + * @return non-negative Total bytes appended to encoder + * @return -1 An error + * + * Example: + * @code + * <#example#> + * @endcode + */ +ssize_t ccnxCodecSchemaV1ValidationEncoder_EncodeAlg(CCNxCodecTlvEncoder *encoder, CCNxTlvDictionary *packetDictionary); + +/** + * Appends the Validation Payload to the packet encoder + * + * This will append the Valdiation Payload from the dictionary, or if it is missing and the + * encoder has a signer, will create a signature. + * + * the caller is responsible for writing the ValidationPayload TL container. + * + * To create the signature, the caller must have used ccnxCodecTlvEncoder_MarkSignatureStart() and + * ccnxCodecTlvEncoder_MarkSignatureEnd() functions to specify the byte locations of the start and + * stop of the protected region. + * + * @param [in] encoder An allocated encoder to append to + * @param [in] packetDictionary The dictionary containing the optional headers + * + * @return non-negative Total bytes appended to encoder + * @return -1 An error + * + * Example: + * @code + * <#example#> + * @endcode + */ +ssize_t ccnxCodecSchemaV1ValidationEncoder_EncodePayload(CCNxCodecTlvEncoder *encoder, CCNxTlvDictionary *packetDictionary); + +#endif /* defined(__CCNx_Common__ccnxCodecSchemaV1_ValidationEncoder__) */ -- cgit 1.2.3-korg