![]() |
ndn-lite
|
#include "data.h"
#include "../security/ndn-lite-hmac.h"
#include "../security/ndn-lite-sha.h"
#include "../security/ndn-lite-aes.h"
#include "../security/ndn-lite-ecc.h"
#include "encoder.h"
#include "../ndn-error-code.h"
Functions | |
static int | _ndn_data_prepare_unsigned_block (ndn_encoder_t *encoder, const ndn_data_t *data) |
static void | _prepare_signature_info (ndn_data_t *data, uint8_t signature_type, const ndn_name_t *producer_identity, uint32_t key_id) |
int | ndn_data_tlv_encode_digest_sign (ndn_encoder_t *encoder, ndn_data_t *data) |
Use Digest (SHA256) to sign the Data and encode the Data into wire format. More... | |
int | ndn_data_tlv_encode_ecdsa_sign (ndn_encoder_t *encoder, ndn_data_t *data, const ndn_name_t *producer_identity, const ndn_ecc_prv_t *prv_key) |
Use ECDSA Algorithm to sign the Data and encode the Data into wire format. More... | |
int | ndn_data_tlv_encode_hmac_sign (ndn_encoder_t *encoder, ndn_data_t *data, const ndn_name_t *producer_identity, const ndn_hmac_key_t *hmac_key) |
Use HMAC Algorithm to sign the Data and encode the Data into wire format. More... | |
int | ndn_data_tlv_decode_no_verify (ndn_data_t *data, const uint8_t *block_value, uint32_t block_size) |
Simply decode the encoded Data into a ndn_data_t without signature verification. More... | |
int | ndn_data_tlv_decode_digest_verify (ndn_data_t *data, const uint8_t *block_value, uint32_t block_size) |
Decode the encoded Data into a ndn_data_t and verify the Digest (SHA256) signature. More... | |
int | ndn_data_tlv_decode_ecdsa_verify (ndn_data_t *data, const uint8_t *block_value, uint32_t block_size, const ndn_ecc_pub_t *pub_key) |
Decode the encoded Data into a ndn_data_t and verify the ECDSA signature. More... | |
int | ndn_data_tlv_decode_hmac_verify (ndn_data_t *data, const uint8_t *block_value, uint32_t block_size, const ndn_hmac_key_t *hmac_key) |
Decode the encoded Data into a ndn_data_t and verify the HMAC signature. More... | |
int | ndn_data_set_encrypted_content (ndn_data_t *data, const uint8_t *content_value, uint32_t content_size, const ndn_name_t *key_id, const uint8_t *aes_iv, const ndn_aes_key_t *key) |
Set the Data content with the encrypted content. More... | |
int | ndn_data_parse_encrypted_content (const ndn_data_t *data, uint8_t *content_value, uint32_t *content_used_size, ndn_name_t *key_id, uint8_t *aes_iv, const ndn_aes_key_t *key) |
Parse the Data encrypted content and get the decrypted content. More... | |
|
static |
|
static |
int ndn_data_parse_encrypted_content | ( | const ndn_data_t * | data, |
uint8_t * | content_value, | ||
uint32_t * | content_used_size, | ||
ndn_name_t * | key_id, | ||
uint8_t * | aes_iv, | ||
const ndn_aes_key_t * | key | ||
) |
Parse the Data encrypted content and get the decrypted content.
The content payload will be decrypted with AES CBC without padding.
data. | Input. The data whose content will be set. |
content_value. | Output. The decrypted content buffer (Content Value only, no T(type) and L(length)). |
content_used_size. | Output. The size of the decrypted content buffer. |
key_id. | Output. The encryption key name. |
aes_iv. | Output. The IV used for AES decryption. |
key. | Input. The AES key used for AES decryption. |
int ndn_data_set_encrypted_content | ( | ndn_data_t * | data, |
const uint8_t * | content_value, | ||
uint32_t | content_size, | ||
const ndn_name_t * | key_id, | ||
const uint8_t * | aes_iv, | ||
const ndn_aes_key_t * | key | ||
) |
Set the Data content with the encrypted content.
The content payload will be encrypted with AES CBC without padding.
data. | Output. The data whose content will be set. |
content_value. | Input. The content buffer (Content Value only, no T(type) and L(length)). |
content_size. | Input. The size of the content buffer. |
key_id. | Input. The encryption key name. |
aes_iv. | Input. The IV used for AES encryption. |
key. | Input. The AES key used for AES encryption. |
int ndn_data_tlv_decode_digest_verify | ( | ndn_data_t * | data, |
const uint8_t * | block_value, | ||
uint32_t | block_size | ||
) |
Decode the encoded Data into a ndn_data_t and verify the Digest (SHA256) signature.
data. | Output. The data to which the wired block will be decoded. |
block_value. | Input. The wire format Data buffer. |
block_size. | Input. The size of the wire format Data buffer. |
int ndn_data_tlv_decode_ecdsa_verify | ( | ndn_data_t * | data, |
const uint8_t * | block_value, | ||
uint32_t | block_size, | ||
const ndn_ecc_pub_t * | pub_key | ||
) |
Decode the encoded Data into a ndn_data_t and verify the ECDSA signature.
data. | Output. The data to which the wired block will be decoded. |
block_value. | Input. The wire format Data buffer. |
block_size. | Input. The size of the wire format Data buffer. |
pub_key. | Input. The ECC public key used to verify the Data signature. |
int ndn_data_tlv_decode_hmac_verify | ( | ndn_data_t * | data, |
const uint8_t * | block_value, | ||
uint32_t | block_size, | ||
const ndn_hmac_key_t * | hmac_key | ||
) |
Decode the encoded Data into a ndn_data_t and verify the HMAC signature.
data. | Output. The data to which the wired block will be decoded. |
block_value. | Input. The wire format Data buffer. |
block_size. | Input. The size of the wire format Data buffer. |
hmac_key. | Input. The HMAC key used to verify the Data signature. |
int ndn_data_tlv_decode_no_verify | ( | ndn_data_t * | data, |
const uint8_t * | block_value, | ||
uint32_t | block_size | ||
) |
Simply decode the encoded Data into a ndn_data_t without signature verification.
data. | Output. The data to which the wired block will be decoded. |
block_value. | Input. The wire format Data buffer. |
block_size. | Input. The size of the wire format Data buffer. |
int ndn_data_tlv_encode_digest_sign | ( | ndn_encoder_t * | encoder, |
ndn_data_t * | data | ||
) |
Use Digest (SHA256) to sign the Data and encode the Data into wire format.
This function will automatically set signature info and signature value.
encoder | Output. The encoder to keep the encoded Data. The encoder should be inited to proper output buffer. |
data | Input. The data to be encoded. |
int ndn_data_tlv_encode_ecdsa_sign | ( | ndn_encoder_t * | encoder, |
ndn_data_t * | data, | ||
const ndn_name_t * | producer_identity, | ||
const ndn_ecc_prv_t * | prv_key | ||
) |
Use ECDSA Algorithm to sign the Data and encode the Data into wire format.
This function will automatically set signature info and signature value.
encoder. | Output. The encoder to keep the encoded Data. The encoder should be inited to proper output buffer. |
data. | Input. The data to be encoded. |
producer_identity. | Input. The producer's identity name. |
prv_key. | Input. The private ECC key used to generate the signature. |
int ndn_data_tlv_encode_hmac_sign | ( | ndn_encoder_t * | encoder, |
ndn_data_t * | data, | ||
const ndn_name_t * | producer_identity, | ||
const ndn_hmac_key_t * | hmac_key | ||
) |
Use HMAC Algorithm to sign the Data and encode the Data into wire format.
This function will automatically set signature info and signature value.
encoder. | Output. The encoder to keep the encoded Data. The encoder should be inited to proper output buffer. |
data. | Input. The data to be encoded. |
producer_identity. | Input. The producer's identity name. |
prv_key. | Input. The HMAC key used to generate the signature. |