![]() |
ndn-lite
|
#include "ndn-lite-sec-utils.h"
#include <stddef.h>
#include <string.h>
#include "../ndn-constants.h"
#include "../ndn-error-code.h"
#include "../ndn-enums.h"
Functions | |
int | ndn_const_time_memcmp (const uint8_t *a, const uint8_t *b, uint32_t size) |
int | _probe_raw_integer_asn1_encoded_size (const uint8_t *val, uint32_t val_len) |
Get the length that a raw integer value will have if encoded in ASN.1 DER format. More... | |
int | _probe_asn1_encoded_integer_raw_size (const uint8_t *val, uint32_t val_len) |
Get the length that an ASN.1 encoded integer value will have if the raw value is extracted. More... | |
int | _write_asn1_integer (const uint8_t *val, uint32_t val_len, uint8_t *output) |
Write an integer in ASN.1 format. More... | |
int | _read_asn1_integer (const uint8_t *asn1_int, uint32_t asn1_int_len, uint8_t *output) |
Read an integer in ASN.1 format. More... | |
int | ndn_asn1_probe_ecdsa_signature_encoding_size (const uint8_t *raw_ecdsa_sig, uint32_t raw_ecdsa_sig_len, uint32_t *encoded_ecdsa_sig_len) |
Probe the size that an ecdsa signature in the same format used by the micro-ecc library will have if it is encoded in ASN.1 DER format. More... | |
int | ndn_asn1_encode_ecdsa_signature (uint8_t *sig_buf, uint32_t raw_ecdsa_sig_len, uint32_t sig_buf_len) |
Encode a signature in the format used by the micro-ecc format; final encoding will be in ASN.1, DER format. More... | |
int | ndn_asn1_decode_ecdsa_signature (const uint8_t *encoded_ecdsa_sig, uint32_t encoded_ecdsa_sig_len, uint8_t *decoded_ecdsa_sig, uint32_t decoded_ecdsa_sig_buf_len, uint32_t *raw_ecdsa_sig_len) |
Decode a signature in ASN.1, DER format into the format used by the micro-ecc library. More... | |
int _probe_asn1_encoded_integer_raw_size | ( | const uint8_t * | val, |
uint32_t | val_len | ||
) |
Get the length that an ASN.1 encoded integer value will have if the raw value is extracted.
This means that asn1 integer tlv type and length, as well as any padding bytes, are excluded.
val. | Input. This is the pointer to the ASN.1 encoded integer. Note that this is a pointer to the integer within the ASN.1 integer tlv block, not to the ASN.1 tlv block tlv type. |
val_len. | Input. This is the tlv length of the ASN1. integer tlv block. |
int _probe_raw_integer_asn1_encoded_size | ( | const uint8_t * | val, |
uint32_t | val_len | ||
) |
Get the length that a raw integer value will have if encoded in ASN.1 DER format.
Does not include tlv type or length fields.
int _read_asn1_integer | ( | const uint8_t * | asn1_int, |
uint32_t | asn1_int_len, | ||
uint8_t * | output | ||
) |
Read an integer in ASN.1 format.
Assumes that the output buffer is long enough to hold the raw integer (without the possible zero padding byte).
int _write_asn1_integer | ( | const uint8_t * | val, |
uint32_t | val_len, | ||
uint8_t * | output | ||
) |
Write an integer in ASN.1 format.
Assumes that the output buffer is long enough to hold the ASN.1 integer tlv type, tlv length, and the value of the integer (plus the extra 0 padding bit if the integer started with a 1 bit). The original value and the destination can overlap.
int ndn_asn1_decode_ecdsa_signature | ( | const uint8_t * | encoded_ecdsa_sig, |
uint32_t | encoded_ecdsa_sig_len, | ||
uint8_t * | decoded_ecdsa_sig, | ||
uint32_t | decoded_ecdsa_sig_buf_len, | ||
uint32_t * | raw_ecdsa_sig_len | ||
) |
Decode a signature in ASN.1, DER format into the format used by the micro-ecc library.
The curve type of signature will be inferred from the length of the signature passed in.
encoded_ecdsa_sig. | Input. Signature to be decoded, in ASN.1 DER format. |
encoded_ecdsa_sig_len. | Input. Length of the encoded signature. |
decoded_ecdsa_sig. | Output. Length of the buffer to store decoded signature. Should be long enough to hold final decoding. |
decoded_ecdsa_sig_buf_len. | Input. Length of buffer to hold decoded signature. |
raw_ecdsa_sig_len. | Output. Length of the decoded signature, in the same format used by the micro-ecc library. |
int ndn_asn1_encode_ecdsa_signature | ( | uint8_t * | raw_ecdsa_sig, |
uint32_t | raw_ecdsa_sig_len, | ||
uint32_t | raw_ecdsa_sig_buf_len | ||
) |
Encode a signature in the format used by the micro-ecc format; final encoding will be in ASN.1, DER format.
The curve type of signature will be inferred from the length of the signature passed in.
raw_ecdsa_sig. | Input. Signature to be encoded, in the format used by the micro-ecc library. |
raw_ecdsa_sig_len. | Input. Length of the signature. Should be even. |
raw_ecdsa_sig_buf_len. | Input. Length of the buffer containing the signature. Should be long enough to hold final encoding. |
int ndn_asn1_probe_ecdsa_signature_encoding_size | ( | const uint8_t * | raw_ecdsa_sig, |
uint32_t | raw_ecdsa_sig_len, | ||
uint32_t * | encoded_ecdsa_sig_len | ||
) |
Probe the size that an ecdsa signature in the same format used by the micro-ecc library will have if it is encoded in ASN.1 DER format.
The curve type of signature will be inferred from the length of the signature passed in.
raw_ecdsa_sig. | Input. Signature to check the ASN.1 encoded length of, in the format used by the micro-ecc library. |
raw_ecdsa_sig_len. | Input. Length of the signature. Should be even. |
encoded_ecdsa_sig_len. | Output. Length that signature will be if ASN.1 encoded. Will only be populated if there is no error. |
int ndn_const_time_memcmp | ( | const uint8_t * | a, |
const uint8_t * | b, | ||
uint32_t | size | ||
) |