tests/pkg_relic: update for bumped upstream
This commit is contained in:
parent
7151992b5c
commit
55d5cdea04
@ -32,11 +32,11 @@ CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(5*THREAD_STACKSIZE_DEFAULT\)
|
|||||||
USEPKG += relic
|
USEPKG += relic
|
||||||
USEMODULE += embunit
|
USEMODULE += embunit
|
||||||
|
|
||||||
# -DWORD=32 : Specifies the word width of the target system. This is
|
# -DWSIZE=32 : Specifies the word width of the target system. This is
|
||||||
# currently not automatically detected so adjusted to your target
|
# currently not automatically detected so adjusted to your target
|
||||||
# platform.
|
# platform.
|
||||||
|
|
||||||
# The rest of the parameters are configuration parameters for RELIC described in its documentation.
|
# The rest of the parameters are configuration parameters for RELIC described in its documentation.
|
||||||
export RELIC_CONFIG_FLAGS=-DARCH=NONE -DOPSYS=NONE -DQUIET=off -DWORD=32 -DFP_PRIME=255 -DWITH="BN;MD;DV;FP;EP;CP;BC;EC" -DSEED=RIOTRND
|
export RELIC_CONFIG_FLAGS=-DARCH=NONE -DOPSYS=NONE -DQUIET=off -DWSIZE=32 -DFP_PRIME=255 -DWITH="BN;MD;DV;FP;EP;CP;BC;EC" -DSEED=RIOTRND
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -4,6 +4,8 @@ BOARD_INSUFFICIENT_MEMORY := \
|
|||||||
nucleo-f030r8 \
|
nucleo-f030r8 \
|
||||||
nucleo-f031k6 \
|
nucleo-f031k6 \
|
||||||
nucleo-f042k6 \
|
nucleo-f042k6 \
|
||||||
|
nucleo-f303k8 \
|
||||||
|
nucleo-f334r8 \
|
||||||
nucleo-l011k4 \
|
nucleo-l011k4 \
|
||||||
nucleo-l031k6 \
|
nucleo-l031k6 \
|
||||||
nucleo-l053r8 \
|
nucleo-l053r8 \
|
||||||
|
|||||||
@ -28,7 +28,7 @@ void print_mem(void *mem, int len) {
|
|||||||
static void setUp(void)
|
static void setUp(void)
|
||||||
{
|
{
|
||||||
/* Initialize RELIC */
|
/* Initialize RELIC */
|
||||||
TEST_ASSERT_EQUAL_INT(STS_OK, core_init());
|
TEST_ASSERT_EQUAL_INT(RLC_OK, core_init());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tearDown(void)
|
static void tearDown(void)
|
||||||
@ -44,18 +44,18 @@ static void tests_relic_ecdh(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Select an elliptic curve configuration */
|
/* Select an elliptic curve configuration */
|
||||||
if (ec_param_set_any() == STS_OK) {
|
if (ec_param_set_any() == RLC_OK) {
|
||||||
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
||||||
ec_param_print();
|
ec_param_print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bn_t privateA;
|
bn_t privateA;
|
||||||
ec_t publicA;
|
ec_t publicA;
|
||||||
uint8_t sharedKeyA[MD_LEN];
|
uint8_t sharedKeyA[RLC_MD_LEN];
|
||||||
|
|
||||||
bn_t privateB;
|
bn_t privateB;
|
||||||
ec_t publicB;
|
ec_t publicB;
|
||||||
uint8_t sharedKeyB[MD_LEN];
|
uint8_t sharedKeyB[RLC_MD_LEN];
|
||||||
|
|
||||||
bn_null(privateA);
|
bn_null(privateA);
|
||||||
ec_null(publicA);
|
ec_null(publicA);
|
||||||
@ -70,7 +70,7 @@ static void tests_relic_ecdh(void)
|
|||||||
ec_new(publicB);
|
ec_new(publicB);
|
||||||
|
|
||||||
/* User A generates private/public key pair */
|
/* User A generates private/public key pair */
|
||||||
TEST_ASSERT_EQUAL_INT(STS_OK, cp_ecdh_gen(privateA, publicA));
|
TEST_ASSERT_EQUAL_INT(RLC_OK, cp_ecdh_gen(privateA, publicA));
|
||||||
|
|
||||||
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
||||||
printf("User A\n");
|
printf("User A\n");
|
||||||
@ -83,7 +83,7 @@ static void tests_relic_ecdh(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* User B generates private/public key pair */
|
/* User B generates private/public key pair */
|
||||||
TEST_ASSERT_EQUAL_INT(STS_OK, cp_ecdh_gen(privateB, publicB));
|
TEST_ASSERT_EQUAL_INT(RLC_OK, cp_ecdh_gen(privateB, publicB));
|
||||||
|
|
||||||
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
||||||
printf("User B\n");
|
printf("User B\n");
|
||||||
@ -98,23 +98,23 @@ static void tests_relic_ecdh(void)
|
|||||||
/* In a protocol you would exchange the public keys now */
|
/* In a protocol you would exchange the public keys now */
|
||||||
|
|
||||||
/* User A calculates shared secret */
|
/* User A calculates shared secret */
|
||||||
TEST_ASSERT_EQUAL_INT(STS_OK, cp_ecdh_key(sharedKeyA, MD_LEN, privateA, publicB));
|
TEST_ASSERT_EQUAL_INT(RLC_OK, cp_ecdh_key(sharedKeyA, RLC_MD_LEN, privateA, publicB));
|
||||||
|
|
||||||
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
||||||
printf("\nshared key computed by user A: ");
|
printf("\nshared key computed by user A: ");
|
||||||
print_mem(sharedKeyA, MD_LEN);
|
print_mem(sharedKeyA, RLC_MD_LEN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* User B calculates shared secret */
|
/* User B calculates shared secret */
|
||||||
TEST_ASSERT_EQUAL_INT(STS_OK, cp_ecdh_key(sharedKeyB, MD_LEN, privateB, publicA));
|
TEST_ASSERT_EQUAL_INT(RLC_OK, cp_ecdh_key(sharedKeyB, RLC_MD_LEN, privateB, publicA));
|
||||||
|
|
||||||
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
#if (TEST_RELIC_SHOW_OUTPUT == 1)
|
||||||
printf("\nshared key computed by user B: ");
|
printf("\nshared key computed by user B: ");
|
||||||
print_mem(sharedKeyB, MD_LEN);
|
print_mem(sharedKeyB, RLC_MD_LEN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The secrets should be the same now */
|
/* The secrets should be the same now */
|
||||||
TEST_ASSERT_EQUAL_INT(CMP_EQ, util_cmp_const(sharedKeyA, sharedKeyB, MD_LEN));
|
TEST_ASSERT_EQUAL_INT(RLC_EQ, util_cmp_const(sharedKeyA, sharedKeyB, RLC_MD_LEN));
|
||||||
|
|
||||||
bn_free(privateA);
|
bn_free(privateA);
|
||||||
ec_free(publicA);
|
ec_free(publicA);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user