RTRlib
Loading...
Searching...
No Matches
bgpsec_utils_private.h File Reference
#include "rtrlib/bgpsec/bgpsec.h"
#include "rtrlib/lib/alloc_utils_private.h"
#include "rtrlib/lib/log_private.h"
#include "rtrlib/rtrlib_export_private.h"
#include <arpa/inet.h>
#include <openssl/x509.h>
#include <string.h>

Go to the source code of this file.

Macros

#define BGPSEC_DBG(fmt, ...)   lrtr_dbg("BGPSEC: " fmt, ##__VA_ARGS__)
 
#define BGPSEC_DBG1(a)   lrtr_dbg("BGPSEC: " a)
 
#define SECURE_PATH_SEG_SIZE   6
 The length of a rtr_secure_path_seg without the next pointer: pcount(1) + flags(1) + asn(4)
 
#define SKI_STR_LEN   61
 The string length of a SKI, including spaces.
 
#define PRIVATE_KEY_LENGTH   121L
 The total length of a private key in bytes.
 

Enumerations

enum  align_type { VALIDATION , SIGNING }
 Control flag, validation and signing procedures for aligning data differs. More...
 

Functions

struct stream * init_stream (uint16_t size)
 
struct stream * copy_stream (struct stream *s)
 
void free_stream (struct stream *s)
 
void write_stream (struct stream *s, void *data, uint16_t len)
 
uint8_t * get_stream_start (struct stream *s)
 
size_t get_stream_size (struct stream *s)
 
uint8_t read_stream (struct stream *s)
 
void read_n_bytes_stream (uint8_t *buff, struct stream *s, uint16_t len)
 
void read_stream_at (uint8_t *buff, struct stream *s, uint16_t start, uint16_t len)
 
size_t req_stream_size (const struct rtr_bgpsec *data, enum align_type type)
 
int get_sig_seg_size (const struct rtr_signature_seg *sig_segs, enum align_type type)
 
int check_router_keys (const struct rtr_signature_seg *sig_segs, struct spki_table *table)
 
int bgpsec_segment_to_str (char *buffer, struct rtr_signature_seg *sig_seg, struct rtr_secure_path_seg *sec_path)
 
int byte_sequence_to_str (char *buffer, uint8_t *bytes, unsigned int bytes_len, unsigned int tabstops)
 
void ski_to_char (char *ski_str, uint8_t *ski)
 
int align_byte_sequence (const struct rtr_bgpsec *data, struct stream *s, enum align_type type)
 
int hash_byte_sequence (uint8_t *bytes, size_t bytes_len, uint8_t alg_suite_id, unsigned char **result_buffer)
 
int validate_signature (const unsigned char *hash, const struct rtr_signature_seg *sig, struct spki_record *record)
 
int load_private_key (EC_KEY **priv_key, uint8_t *bytes_key)
 
int load_public_key (EC_KEY **pub_key, uint8_t *spki)
 
int sign_byte_sequence (uint8_t *hash_result, EC_KEY *priv_key, uint8_t alg, struct rtr_signature_seg *new_signature)
 
int ski_is_empty (uint8_t *ski)
 

Macro Definition Documentation

◆ BGPSEC_DBG

#define BGPSEC_DBG (   fmt,
  ... 
)    lrtr_dbg("BGPSEC: " fmt, ##__VA_ARGS__)

◆ BGPSEC_DBG1

#define BGPSEC_DBG1 (   a)    lrtr_dbg("BGPSEC: " a)

◆ PRIVATE_KEY_LENGTH

#define PRIVATE_KEY_LENGTH   121L

The total length of a private key in bytes.

◆ SECURE_PATH_SEG_SIZE

#define SECURE_PATH_SEG_SIZE   6

The length of a rtr_secure_path_seg without the next pointer: pcount(1) + flags(1) + asn(4)

◆ SKI_STR_LEN

#define SKI_STR_LEN   61

The string length of a SKI, including spaces.

Enumeration Type Documentation

◆ align_type

enum align_type

Control flag, validation and signing procedures for aligning data differs.

Enumerator
VALIDATION 
SIGNING 

Function Documentation

◆ align_byte_sequence()

int align_byte_sequence ( const struct rtr_bgpsec data,
struct stream *  s,
enum align_type  type 
)

◆ bgpsec_segment_to_str()

int bgpsec_segment_to_str ( char *  buffer,
struct rtr_signature_seg sig_seg,
struct rtr_secure_path_seg sec_path 
)

◆ byte_sequence_to_str()

int byte_sequence_to_str ( char *  buffer,
uint8_t *  bytes,
unsigned int  bytes_len,
unsigned int  tabstops 
)

◆ check_router_keys()

int check_router_keys ( const struct rtr_signature_seg sig_segs,
struct spki_table table 
)

◆ copy_stream()

struct stream * copy_stream ( struct stream *  s)

◆ free_stream()

void free_stream ( struct stream *  s)

◆ get_sig_seg_size()

int get_sig_seg_size ( const struct rtr_signature_seg sig_segs,
enum align_type  type 
)

◆ get_stream_size()

size_t get_stream_size ( struct stream *  s)

◆ get_stream_start()

uint8_t * get_stream_start ( struct stream *  s)

◆ hash_byte_sequence()

int hash_byte_sequence ( uint8_t *  bytes,
size_t  bytes_len,
uint8_t  alg_suite_id,
unsigned char **  result_buffer 
)

◆ init_stream()

struct stream * init_stream ( uint16_t  size)

◆ load_private_key()

int load_private_key ( EC_KEY **  priv_key,
uint8_t *  bytes_key 
)

◆ load_public_key()

int load_public_key ( EC_KEY **  pub_key,
uint8_t *  spki 
)

◆ read_n_bytes_stream()

void read_n_bytes_stream ( uint8_t *  buff,
struct stream *  s,
uint16_t  len 
)

◆ read_stream()

uint8_t read_stream ( struct stream *  s)

◆ read_stream_at()

void read_stream_at ( uint8_t *  buff,
struct stream *  s,
uint16_t  start,
uint16_t  len 
)

◆ req_stream_size()

size_t req_stream_size ( const struct rtr_bgpsec data,
enum align_type  type 
)

◆ sign_byte_sequence()

int sign_byte_sequence ( uint8_t *  hash_result,
EC_KEY *  priv_key,
uint8_t  alg,
struct rtr_signature_seg new_signature 
)

◆ ski_is_empty()

int ski_is_empty ( uint8_t *  ski)

◆ ski_to_char()

void ski_to_char ( char *  ski_str,
uint8_t *  ski 
)

◆ validate_signature()

int validate_signature ( const unsigned char *  hash,
const struct rtr_signature_seg sig,
struct spki_record record 
)

◆ write_stream()

void write_stream ( struct stream *  s,
void *  data,
uint16_t  len 
)