I am trying to define a struct and trying to perform XOR encryption on it using a key of 2 bytes.
static __always_inline long int encrypt_decrypt(struct ipv6_destopt_pdmv2_unencrypted *pdm)
{
// xor all fields after flip bit with a key of size 2 bytes
__u16 key = 0x1234;
__u32 key1 = key << 16 | key;
// get first 8 bits of key
__u8 key2 = key >> 8;
__u8 key3 = key & 0xFF;
example_struct->a = example_struct->a ^ key2;
example_struct->b = example_struct->b ^ key3;
example_struct->c = example_struct->c ^ key1;
example_struct->d = example_struct->d ^ key;
example_struct->e = example_struct->e ^ key;
example_struct->f = example_struct->f ^ key;
example_struct->g = example_struct->g ^ key;
return 0;
}
The struct example_struct is given by,
struct example_struct
{
__u8 u;
__u8 v;
__u16 x;
__u16 y;
// following fields are encrypted
__u8 a;
__u8 b;
__u32 c;
__u16 d;
__u16 e;
__u16 f;
__u16 g;
__uint128_t more_stuff_1;
__u8 more_stuff_2;
__u8 more_stuff_3;
};
When I comment out the line example_struct->a = example_struct->a ^ key2;
, the verifier does not throw any error, but when I include this one line, the verifier throws the error processed 1000001 instructions, bpf program too large. The number of instructions it shows when it throws this error in the bpf program itself is 534. Why is this happening?