|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
76 return (0==strncmp ((
char *) name0, (
char *)name1, len0));
111 u16 id = profile->
id;
120 if (profile && !profile->
in_use)
123 profile->
prime = prime;
138 if (profile && !profile->
in_use)
148 u64 secret_share,
u64 prime,
u64 lpc,
u64 pre_split,
double prime_inv)
150 u64 share_random = 0;
151 u64 cumulative_new = 0;
156 share_random =
add64_mod(pre_split, random, prime, prime_inv);
161 share_random =
add64_mod(share_random, secret_share, prime, prime_inv);
162 share_random =
mul64_mod(share_random, lpc, prime, prime_inv);
164 cumulative_new =
add64_mod(cumulative, share_random, prime, prime_inv);
166 return (cumulative_new);
171 if (profile && profile->
valid != 0)
181 u64 cumulative,
u64 random)
183 if (cumulative == (random + secret))
187 else if (cumulative ==
add64_mod(random, secret, prime, prime_inv))
202 profile->
primeinv, cumulative, random));
222 random = (
u64) time(NULL);
224 random &= 0xffffffff;
225 random = random << 32;
231 random |= second_half;
244 if (profile && !profile->
in_use)
246 sizeInBits =
sizeof(profile->
bit_mask) * 8;
249 sizeInBits ? (
u64) - 1 : (
u64) ((
u64) 1 << (
u64) bits) - 1);
271 .path =
"clear pot profile",
272 .short_help =
"clear pot profile [<index>|all]",
285 u64 lpc = 0, poly2 = 0;
287 u8 *profile_list_name = NULL;
294 &profile_list_name));
295 else if (
unformat(input,
"id %d", &profile_id))
297 else if (
unformat(input,
"validate-key 0x%Lx", &secret_key))
299 else if (
unformat(input,
"prime-number 0x%Lx", &prime))
301 else if (
unformat(input,
"secret_share 0x%Lx", &secret_share))
303 else if (
unformat(input,
"polynomial2 0x%Lx", &poly2))
305 else if (
unformat(input,
"lpc 0x%Lx", &lpc))
307 else if (
unformat(input,
"bits-in-random %d", &bits))
315 if (profile_list_name == 0)
335 .path =
"set pot profile",
336 .short_help =
"set pot profile name <string> id [0-1] [validator-key 0xu64] \
337 prime-number 0xu64 secret_share 0xu64 lpc 0xu64 \
338 polynomial2 0xu64 bits-in-random [0-64] ",
346 u8 *profile_list_name = NULL;
353 &profile_list_name));
354 else if (
unformat(input,
"id %d", &
id))
360 if (profile_list_name == 0)
378 .path =
"set pot profile-active",
379 .short_help =
"set pot profile-active name <string> id [0-1]",
393 s =
format(s,
"POT Profiles not configured\n");
403 s =
format(s,
"POT Profile at index: %d\n",
i);
405 s =
format(s,
" Validator : %s (%d)\n",
408 s =
format(s,
" Secret key : 0x%Lx (%Ld)\n",
410 s =
format(s,
" Secret share : 0x%Lx (%Ld)\n",
412 s =
format(s,
" Prime number : 0x%Lx (%Ld)\n",
414 s =
format(s,
"2nd polynomial(eval) : 0x%Lx (%Ld)\n",
418 s =
format(s,
" Bit mask : 0x%Lx (%Ld)\n",
426 s =
format(s,
"Pkts passed : 0x%Lx (%Ld)\n",
430 s =
format(s,
" This is Decap node. \n");
432 s =
format(s,
"\nProfile index in use: None\n");
442 .path =
"show pot profile",
443 .short_help =
"show pot profile",
u64 pot_generate_random(pot_profile *profile)
int pot_profile_list_is_enabled(u8 *name)
static u64 add64_mod(u64 a, u64 b, u64 p, double pi)
pot_profile * pot_profile_find(u8 id)
static void pot_profile_init(pot_profile *new, u8 id)
#define clib_error_return(e, args...)
clib_error_t * clear_pot_profile_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 pot_validate(pot_profile *profile, u64 cumulative, u64 random)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vlib_cli_command_t set_pot_profile_activate_command
(constructor) VLIB_CLI_COMMAND (set_pot_profile_activate_command)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_cli_command_t show_pot_profile_command
(constructor) VLIB_CLI_COMMAND (show_pot_profile_command)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
vlib_cli_command_t clear_pot_profile_command
(constructor) VLIB_CLI_COMMAND (clear_pot_profile_command)
static void pot_profile_cleanup(pot_profile *profile)
sll srl srl sll sra u16x4 i
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * show_pot_profile_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_cli_command_t set_pot_profile_command
(constructor) VLIB_CLI_COMMAND (set_pot_profile_command)
static u8 pot_validate_inline(u64 secret, u64 prime, double prime_inv, u64 cumulative, u64 random)
#define vec_free(V)
Free vector's memory (no header).
static int pot_profile_name_equal(u8 *name0, u8 *name1)
description fragment has unexpected format
void pot_profile_list_init(u8 *profile_list_name)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void pot_main_profiles_reset(void)
int pot_set_validator(pot_profile *profile, u64 key)
static u64 pot_update_cumulative_inline(u64 cumulative, u64 random, u64 secret_share, u64 prime, u64 lpc, u64 pre_split, double prime_inv)
static clib_error_t * set_pot_profile_activate_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u64 pot_update_cumulative(pot_profile *profile, u64 cumulative, u64 random)
static clib_error_t * set_pot_profile_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 pot_is_decap(pot_profile *p)
static u64 mul64_mod(u64 a, u64 b, u64 p, double pi)
static int pot_profile_set_active(u8 id)
u64 total_pkts_using_this_profile
int pot_profile_create(pot_profile *profile, u64 prime, u64 poly2, u64 lpc, u64 secret_share)
int pot_profile_set_bit_mask(pot_profile *profile, u16 bits)
pot_profile profile_list[MAX_POT_PROFILES]
void clear_pot_profiles()
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)