ndn-lite
Data Structures | Typedefs | Functions
signature.h File Reference
#include "name.h"
#include "../ndn-constants.h"

Go to the source code of this file.

Data Structures

struct  ndn_validity_period
 The structure to represent the signature validity period. More...
 
struct  ndn_signature
 The structure to represent the Signature. More...
 

Typedefs

typedef struct ndn_validity_period ndn_validity_period_t
 The structure to represent the signature validity period. More...
 
typedef struct ndn_signature ndn_signature_t
 The structure to represent the Signature. More...
 

Functions

static int ndn_signature_init (ndn_signature_t *signature)
 Init a Signature structure. More...
 
static int ndn_signature_set_signature_type (ndn_signature_t *signature, uint8_t type)
 
static int ndn_signature_set_signature (ndn_signature_t *signature, const uint8_t *sig_value, size_t sig_size)
 Set signature value of the Signature. More...
 
static void ndn_signature_set_key_locator (ndn_signature_t *signature, const ndn_name_t *key_name)
 Set keylocator of the Signature. More...
 
static void ndn_signature_set_timestamp (ndn_signature_t *signature, uint64_t timestamp)
 Set Timestamp of the Signature. More...
 
static void ndn_signature_set_signature_nonce (ndn_signature_t *signature, uint32_t nonce)
 Set Nonce of the Signed Interest. More...
 
static void ndn_signature_set_seqnum (ndn_signature_t *signature, uint32_t seqnum)
 Set SeqNum of the Signed Interest. More...
 
static void ndn_signature_set_validity_period (ndn_signature_t *signature, const uint8_t *not_before, const uint8_t *not_after)
 Set validity period of the Signature. More...
 
static uint32_t ndn_signature_info_probe_block_size (const ndn_signature_t *signature)
 Probe the size of a Signature info TLV block before encoding it from a Signature structure. More...
 
static uint32_t ndn_signature_value_probe_block_size (const ndn_signature_t *signature)
 Probe the size of a Signature value TLV block before encoding it from a Signature structure. More...
 
int ndn_signature_info_tlv_encode (ndn_encoder_t *encoder, const ndn_signature_t *signature)
 Encode the Signature info into wire format (TLV block) from Signature structure. More...
 
int ndn_signature_value_tlv_encode (ndn_encoder_t *encoder, const ndn_signature_t *signature)
 Encode the Signature value into wire format (TLV block) from Signature structure. More...
 
int ndn_signature_info_tlv_decode (ndn_decoder_t *decoder, ndn_signature_t *signature)
 Decode an Signature info TLV block into an Signature structure. More...
 
int ndn_signature_value_tlv_decode (ndn_decoder_t *decoder, ndn_signature_t *signature)
 Decode an Signature value TLV block into an Signature structure. More...
 

Typedef Documentation

◆ ndn_signature_t

The structure to represent the Signature.

We don't support key digest as KeyLocator in ndn-lite.

◆ ndn_validity_period_t

The structure to represent the signature validity period.

This is designed for but not limited to the use of certificate.

Function Documentation

◆ ndn_signature_info_probe_block_size()

static uint32_t ndn_signature_info_probe_block_size ( const ndn_signature_t signature)
inlinestatic

Probe the size of a Signature info TLV block before encoding it from a Signature structure.

This function is used to check whether the output buffer size is enough or not.

Parameters
signature.Input. The signature structure to be probed.
Returns
the length of the expected Signature info TLV block.

◆ ndn_signature_info_tlv_decode()

int ndn_signature_info_tlv_decode ( ndn_decoder_t decoder,
ndn_signature_t signature 
)

Decode an Signature info TLV block into an Signature structure.

This function will do memory copy.

Parameters
decoder.Input. The decoder who keeps the decoding result and the state.
signature.Output. The Signature structure whose signature info to be decoded.
Returns
0 if decoding is successful.

◆ ndn_signature_info_tlv_encode()

int ndn_signature_info_tlv_encode ( ndn_encoder_t encoder,
const ndn_signature_t signature 
)

Encode the Signature info into wire format (TLV block) from Signature structure.

Parameters
encoder.Output. The encoder who keeps the encoding result and the state.
signature.Input. The Signature structure whose signature info to be encoded.
Returns
0 if there is no error.

◆ ndn_signature_init()

static int ndn_signature_init ( ndn_signature_t signature)
inlinestatic

Init a Signature structure.

set signature type, signature size, and disable keylocator and validity period by default.

Parameters
signature.Output. The Signature structure to be inited.
type.Input. The signature type.
Returns
0 if there is no error.

◆ ndn_signature_set_key_locator()

static void ndn_signature_set_key_locator ( ndn_signature_t signature,
const ndn_name_t key_name 
)
inlinestatic

Set keylocator of the Signature.

This function will do memory copy.

Note
This function is NOT recommended. Better to first init signature and init signature.keylocator_name and set enable_KeyLocator = 1.
Parameters
signature.Output. The Signature whose keylocator will be set.
key_name.Input. The input keylocator.

◆ ndn_signature_set_seqnum()

static void ndn_signature_set_seqnum ( ndn_signature_t signature,
uint32_t  seqnum 
)
inlinestatic

Set SeqNum of the Signed Interest.

Parameters
interest.Output. The Interest whose Nonce SeqNum be set.
SeqNum.Input. SeqNum value.

◆ ndn_signature_set_signature()

static int ndn_signature_set_signature ( ndn_signature_t signature,
const uint8_t *  sig_value,
size_t  sig_size 
)
inlinestatic

Set signature value of the Signature.

This function will do memory copy.

Parameters
signature.Output. The Signature whose signature value will be set.
sig_value.Input. The buffer which holds the input signature value.
sig_size.Input. Size of input buffer.
Returns
0 if there is no error.

◆ ndn_signature_set_signature_nonce()

static void ndn_signature_set_signature_nonce ( ndn_signature_t signature,
uint32_t  nonce 
)
inlinestatic

Set Nonce of the Signed Interest.

Parameters
interest.Output. The Interest whose Nonce will be set.
nonce.Input. Nonce value.

◆ ndn_signature_set_signature_type()

static int ndn_signature_set_signature_type ( ndn_signature_t signature,
uint8_t  type 
)
inlinestatic

◆ ndn_signature_set_timestamp()

static void ndn_signature_set_timestamp ( ndn_signature_t signature,
uint64_t  timestamp 
)
inlinestatic

Set Timestamp of the Signature.

A Timestamp should be set when using a signed Interest.

Parameters
signature.Output. The Signature whose Timestamp will be set.
timestamp.Input. Timestamp value.

◆ ndn_signature_set_validity_period()

static void ndn_signature_set_validity_period ( ndn_signature_t signature,
const uint8_t *  not_before,
const uint8_t *  not_after 
)
inlinestatic

Set validity period of the Signature.

This function will do memory copy. not before and not after must be ISO 8601 time format, which is 15 bytes long.

Parameters
signature.Output. The Signature whose validity period will be set.
not_before.Input. The input not_before time.
not_after.Input. The input not_after time.

◆ ndn_signature_value_probe_block_size()

static uint32_t ndn_signature_value_probe_block_size ( const ndn_signature_t signature)
inlinestatic

Probe the size of a Signature value TLV block before encoding it from a Signature structure.

This function is used to check whether the output buffer size is enough or not.

Parameters
signature.Input. The signature structure to be probed.
Returns
the length of the expected Signature value TLV block.

◆ ndn_signature_value_tlv_decode()

int ndn_signature_value_tlv_decode ( ndn_decoder_t decoder,
ndn_signature_t signature 
)

Decode an Signature value TLV block into an Signature structure.

This function will do memory copy.

Parameters
decoder.Input. The decoder who keeps the decoding result and the state.
signature.Output. The Signature structure whose signature value to be decoded.
Returns
0 if decoding is successful.

◆ ndn_signature_value_tlv_encode()

int ndn_signature_value_tlv_encode ( ndn_encoder_t encoder,
const ndn_signature_t signature 
)

Encode the Signature value into wire format (TLV block) from Signature structure.

Parameters
encoder.Output. The encoder who keeps the encoding result and the state.
signature.Input. The Signature structure whose signature value to be encoded.
Returns
0 if there is no error.