ndn-lite
Functions
sign-on-basic-client.c File Reference
#include "sign-on-basic-client.h"
#include "sign-on-basic-sec-intf-setter.h"
#include <string.h>
#include "../../ndn-error-code.h"
#include "../../ndn-constants.h"
#include "../../encode/tlv.h"
#include "../../encode/decoder.h"
#include "sign-on-basic-consts.h"
#include "security/sign-on-basic-sec-consts.h"
#include "sign-on-basic-impl-consts.h"
#include "variants/ecc_256/sign-on-basic-ecc-256-consts.h"

Functions

int sign_on_basic_client_init (uint8_t variant, sign_on_basic_client_t *sign_on_basic_client, const uint8_t *device_identifier_p, uint32_t device_identifier_len, const uint8_t *device_capabilities_p, uint32_t device_capabilities_len, const uint8_t *secure_sign_on_code_p, const uint8_t *KS_pub_p, uint32_t KS_pub_len, const uint8_t *KS_pri_p, uint32_t KS_pri_len)
 Initialize state for a sign_on_basic_client_t. More...
 
int cnstrct_btstrp_rqst (uint8_t *buf_p, uint32_t buf_len, uint32_t *output_len_p, sign_on_basic_client_t *sign_on_basic_client)
 Construct a bootstrapping request. More...
 
int prcs_btstrp_rqst_rspns (const uint8_t *btstrp_rqst_rspns_buf_p, uint32_t btstrp_rqst_rspns_buf_len, sign_on_basic_client_t *sign_on_basic_client)
 Process a bootstrapping request response. More...
 
int cnstrct_cert_rqst (uint8_t *buf_p, uint32_t buf_len, uint32_t *output_len_p, sign_on_basic_client_t *sign_on_basic_client)
 Construct a certificate request. More...
 
int prcs_cert_rqst_rspns (const uint8_t *cert_rqst_rspns_buf_p, uint32_t cert_rqst_rspns_buf_len, sign_on_basic_client_t *sign_on_basic_client)
 Process a certificate request response. More...
 
int cnstrct_fin_msg (uint8_t *buf_p, uint32_t buf_len, uint32_t *output_len_p, sign_on_basic_client_t *sign_on_basic_client)
 Construct a sign-on basic finish message (this lets the controller know sign-on was completed successfully. More...
 

Function Documentation

◆ cnstrct_btstrp_rqst()

int cnstrct_btstrp_rqst ( uint8_t *  buf_p,
uint32_t  buf_len,
uint32_t *  output_len_p,
sign_on_basic_client_t sign_on_basic_client 
)

Construct a bootstrapping request.

For a given sign on exchange: Should be called after sign_on_basic_client_init. Should be called before prcs_btstrp_rqst_rspns, cnstrct_cert_rqst, and prcs_cert_rqst_rspns.

Parameters
[in]buf_pPre allocated buffer to use in generating bootstrapping request.
[in]buf_lenLength of pre allocated buffer.
[in]output_len_pPointer to variable that will be filled with length of generated bootstrapping request upon successful construction.
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to use in construction.
Returns
Returns NDN_SUCCESS upon success.

◆ cnstrct_cert_rqst()

int cnstrct_cert_rqst ( uint8_t *  buf_p,
uint32_t  buf_len,
uint32_t *  output_len_p,
sign_on_basic_client_t sign_on_basic_client 
)

Construct a certificate request.

For a given sign on exchange: Should be called after sign_on_basic_client_init, and prcs_btstrp_rqst_rspns. Should be called before prcs_cert_rqst_rspns.

Parameters
[in]buf_pPre allocated buffer to use in generating certificate request.
[in]buf_lenLength of pre allocated buffer.
[in]output_len_pPointer to variable that will be filled with length of generated certificate request upon successful construction.
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to use in construction.
Returns
Returns NDN_SUCCESS upon success.

◆ cnstrct_fin_msg()

int cnstrct_fin_msg ( uint8_t *  buf_p,
uint32_t  buf_len,
uint32_t *  output_len_p,
sign_on_basic_client_t sign_on_basic_client 
)

Construct a sign-on basic finish message (this lets the controller know sign-on was completed successfully.

For a given sign on exchange: Should be called after sign_on_basic_client_init, prcs_btstrp_rqst_rspns, cnstrct_cert_rqst, and prcs_cert_rqst_rspns. Should be called last in the sign-on process.

Parameters
[in]buf_pPre allocated buffer to use in generating finish message.
[in]buf_lenLength of pre allocated buffer.
[in]output_len_pPointer to variable that will be filled with length of generated finish message upon successful construction.
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to use in construction.
Returns
Returns NDN_SUCCESS upon success.

◆ prcs_btstrp_rqst_rspns()

int prcs_btstrp_rqst_rspns ( const uint8_t *  btstrp_rqst_rspns_buf_p,
uint32_t  btstrp_rqst_rspns_buf_len,
sign_on_basic_client_t sign_on_basic_client 
)

Process a bootstrapping request response.

For a given sign on exchange: Should be called after sign_on_basic_client_init and prcs_btstrp_rqst_rspns. Should be called before cnstrct_cert_rqst, and prcs_cert_rqst_rspns.

Note
Calling this function will not modify any state of the sign on basic client that it is passed until after it successfully processes the entire bootstrapping request response.
Parameters
[in]btstrp_rqst_rspns_buf_pBuffer that holds the bootstrapping request response.
[in]btstrp_rqst_rspns_buf_lenLength of the bootstrapping request response.
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to modify while processing.
Returns
Returns NDN_SUCCESS upon success.

◆ prcs_cert_rqst_rspns()

int prcs_cert_rqst_rspns ( const uint8_t *  cert_rqst_rspns_buf_p,
uint32_t  cert_rqst_rspns_buf_len,
sign_on_basic_client_t sign_on_basic_client 
)

Process a certificate request response.

For a given sign on exchange: Should be called after sign_on_basic_client_init, prcs_btstrp_rqst_rspns, and cnstrct_cert_rqst. Should be called before cnstrct_fin_msg.

Note
Calling this function will not modify any state of the sign on basic client that it is passed until after it successfully processes the entire certificate request response.
Parameters
[in]cert_rqst_rspns_buf_pBuffer that holds the certificate request response.
[in]cert_rqst_rspns_buf_lenLength of the certificate request response.
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to modify while processing.
Returns
Returns NDN_SUCCESS upon success.

◆ sign_on_basic_client_init()

int sign_on_basic_client_init ( uint8_t  variant,
sign_on_basic_client_t sign_on_basic_client,
const uint8_t *  device_identifier_p,
uint32_t  device_identifier_len,
const uint8_t *  device_capabilities_p,
uint32_t  device_capabilities_len,
const uint8_t *  secure_sign_on_code_p,
const uint8_t *  KS_pub_p,
uint32_t  KS_pub_len,
const uint8_t *  KS_pri_p,
uint32_t  KS_pri_len 
)

Initialize state for a sign_on_basic_client_t.

All buffers passed in will be copied into the sign_on_basic_client basic client.

Parameters
[in]variantThis is the variant of the Sign-On basic protocol that you want to initialize. This will change the function pointers that are passed to sign_on_basic_sec_intf to do security related operations, like signature generation. See secure-sign-on-basic-consts.h for all of the variants, as

well as descriptions.

Parameters
[in]sign_on_basic_clientReference to the sign_on_basic_client_t to be initialized.
[in]device_identifier_pSee the sign_on_basic_client_t documentation.
[in]device_identifier_len" "
[in]device_capabilities_p" "
[in]device_capabilities_len" "
[in]secure_sign_on_code_p" "
[in]KS_pub_p" "
[in]KS_pub_len" "
[in]KS_pri_p" "
[in]KS_pri_len" "
Returns
Returns NDN_SUCCESS upon success.