63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/**
|
|
* @file tests/crypt_ivsi.c
|
|
* Test IVSI
|
|
* @todo use test library and verify against expected digest
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include <di/crypt/ivsi.h>
|
|
#include <di/misc/hexstr.h>
|
|
|
|
void di_crypt_ivsi_scramble(void)
|
|
{
|
|
char *iv_str = "2a947add5ea5d898b69a57e862012ac4";
|
|
char *iv_exp_str = "c823fff8f41a3151e84ba418b591e173";
|
|
|
|
uint8_t iv[16];
|
|
uint8_t iv_scrambled[16];
|
|
char iv_out_str[33];
|
|
|
|
di_hexstr_to_bin((void *)iv, 16, iv_str, (uint16_t)strlen(iv_str));
|
|
|
|
ivsi_scramble_iv(iv, iv_scrambled);
|
|
|
|
di_hexstr_from_bin((void *)iv_out_str, sizeof(iv_out_str), iv_scrambled, 16);
|
|
|
|
printf("=== %s ===\n", __func__);
|
|
printf("iv: 0x%s\n", iv_str);
|
|
printf("iv_exp: 0x%s\n", iv_exp_str);
|
|
printf("iv_out: 0x%s\n", iv_out_str);
|
|
};
|
|
|
|
void di_crypt_ivsi_unscramble(void)
|
|
{
|
|
char *iv_str = "c823fff8f41a3151e84ba418b591e173";
|
|
char *iv_exp_str = "2a947add5ea5d898b69a57e862012ac4";
|
|
|
|
uint8_t iv[16];
|
|
uint8_t iv_scrambled[16];
|
|
char iv_out_str[33];
|
|
|
|
di_hexstr_to_bin((void *)iv, 16, iv_str, (uint16_t)strlen(iv_str));
|
|
|
|
ivsi_unscramble_iv(iv, iv_scrambled);
|
|
|
|
di_hexstr_from_bin((void *)iv_out_str, sizeof(iv_out_str), iv_scrambled, 16);
|
|
|
|
printf("=== %s ===\n", __func__);
|
|
printf("iv: 0x%s\n", iv_str);
|
|
printf("iv_exp: 0x%s\n", iv_exp_str);
|
|
printf("iv_out: 0x%s\n", iv_out_str);
|
|
};
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
di_crypt_ivsi_scramble();
|
|
di_crypt_ivsi_unscramble();
|
|
|
|
return 0;
|
|
}
|