aboutsummaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/capability.c6
-rw-r--r--sw/configure-fpga.sh6
-rw-r--r--sw/modexps6_tester.c224
-rw-r--r--sw/novena-eim.c16
-rw-r--r--sw/tc_eim.c6
-rw-r--r--sw/tc_i2c.c6
6 files changed, 132 insertions, 132 deletions
diff --git a/sw/capability.c b/sw/capability.c
index 9b29c98..051b23a 100644
--- a/sw/capability.c
+++ b/sw/capability.c
@@ -1,11 +1,11 @@
-/*
+/*
* capability.c
* ------------
* This module contains code to probe the FPGA for its installed cores.
- *
+ *
* Author: Paul Selkirk
* Copyright (c) 2015, NORDUnet A/S All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
diff --git a/sw/configure-fpga.sh b/sw/configure-fpga.sh
index 7ebfb6b..c355066 100644
--- a/sw/configure-fpga.sh
+++ b/sw/configure-fpga.sh
@@ -4,10 +4,10 @@ echo "Setting export of reset pin"
echo 135 > /sys/class/gpio/export
echo "setting reset pin to out"
echo out > /sys/class/gpio/gpio135/direction
-echo "flipping reset"
+echo "flipping reset"
echo 0 > /sys/class/gpio/gpio135/value
echo 1 > /sys/class/gpio/gpio135/value
-echo "configuring FPGA"
+echo "configuring FPGA"
dd if=${bitfile} of=/dev/spidev2.0 bs=128
-echo "turning on clock to FPGA"
+echo "turning on clock to FPGA"
devmem3 0x020c8160 w 0x00000D2B
diff --git a/sw/modexps6_tester.c b/sw/modexps6_tester.c
index a9e3b74..b76a6b3 100644
--- a/sw/modexps6_tester.c
+++ b/sw/modexps6_tester.c
@@ -23,10 +23,10 @@ int repeat = 0;
int tc_width(off_t offset, uint32_t length)
{
length = htonl(length); // !
-
+
uint8_t width[4];
memcpy(width, &length, 4);
-
+
return tc_write(offset, width, sizeof(width));
}
@@ -79,7 +79,7 @@ int TC0(void)
int TC1(void)
{
int ret;
-
+
if (!quiet)
printf("TC1: Sign 1024-bit message (fast & unsafe public mode).\n");
@@ -93,37 +93,37 @@ int TC1(void)
/*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/
uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};
tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -131,7 +131,7 @@ int TC1(void)
int TC2(void)
{
int ret;
-
+
if (!quiet)
printf("TC2: Sign 1024-bit message (slow & secure private mode).\n");
@@ -145,37 +145,37 @@ int TC2(void)
uint8_t mode_slow_secure[] = {0, 0, 0, 0};
/*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/
tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -183,7 +183,7 @@ int TC2(void)
int TC3(void)
{
int ret;
-
+
if (!quiet)
printf("TC3: Sign 2048-bit message (fast & unsafe public mode).\n");
@@ -197,37 +197,37 @@ int TC3(void)
/*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/
uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};
tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -235,7 +235,7 @@ int TC3(void)
int TC4(void)
{
int ret;
-
+
if (!quiet)
printf("TC4: Sign 2048-bit message (slow & secure private mode).\n");
@@ -249,37 +249,37 @@ int TC4(void)
uint8_t mode_slow_secure[] = {0, 0, 0, 0};
/*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/
tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -287,7 +287,7 @@ int TC4(void)
int TC5(void)
{
int ret;
-
+
if (!quiet)
printf("TC5: Sign 4096-bit message (fast & unsafe public mode).\n");
@@ -301,37 +301,37 @@ int TC5(void)
/*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/
uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};
tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -339,7 +339,7 @@ int TC5(void)
int TC6(void)
{
int ret;
-
+
if (!quiet)
printf("TC6: Sign 4096-bit message (slow & secure private mode).\n");
@@ -353,37 +353,37 @@ int TC6(void)
uint8_t mode_slow_secure[] = {0, 0, 0, 0};
/*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/
tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
@@ -391,7 +391,7 @@ int TC6(void)
int TC7(void)
{
int ret;
-
+
if (!quiet)
printf("TC7: Sign several 1024-bit messages (without pre-calculation every time).\n");
@@ -406,40 +406,40 @@ int TC7(void)
clone_reversed(result_1, s_1024_1);
clone_reversed(result_2, s_1024_2);
clone_reversed(result_3, s_1024_3);
-
+
/* Set fast mode */
/*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/
uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};
tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Set new exponent length */
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits
/* Write new exponent */
- tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
+
{
/* Write new message #0 */
tc_write(MODEXPS6_ADDR_MESSAGE, message_0, sizeof(message_0));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result_0, sizeof(result_0));
if (ret) return 1;
@@ -447,13 +447,13 @@ int TC7(void)
{
/* Write new message #1 */
tc_write(MODEXPS6_ADDR_MESSAGE, message_1, sizeof(message_1));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result_1, sizeof(result_1));
if (ret) return 1;
@@ -461,13 +461,13 @@ int TC7(void)
{
/* Write new message #2 */
tc_write(MODEXPS6_ADDR_MESSAGE, message_2, sizeof(message_2));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result_2, sizeof(result_2));
if (ret) return 1;
@@ -475,18 +475,18 @@ int TC7(void)
{
/* Write new message #3 */
tc_write(MODEXPS6_ADDR_MESSAGE, message_3, sizeof(message_3));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result_3, sizeof(result_3));
if (ret) return 1;
}
-
+
return 0;
}
@@ -494,7 +494,7 @@ int TC7(void)
int TC8(void)
{
int ret;
-
+
if (!quiet)
printf("TC8: Verify 4096-bit message (fast mode using public exponent).\n");
@@ -503,46 +503,46 @@ int TC8(void)
clone_reversed(message, s_4096);
clone_reversed(exponent, e_4096);
clone_reversed(result, m_4096);
-
+
/* Set fast mode */
/*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/
uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};
tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe));
-
+
/* Set new modulus size */
tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits
-
+
/* Write new modulus */
tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus));
-
+
/* Pre-calculate speed-up coefficient */
tc_init(MODEXPS6_ADDR_CTRL);
/* Wait while core is calculating */
tc_wait_ready(MODEXPS6_ADDR_STATUS);
-
+
/* Write new message */
tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message));
-
+
/* Set new exponent length */
#if 1
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, 18); // number of bits
#else
tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, 24); // number of bits
#endif
-
+
/* Write new exponent */
tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent));
-
+
/* Start calculation */
tc_next(MODEXPS6_ADDR_CTRL);
-
+
/* Wait while core is calculating */
- tc_wait_valid(MODEXPS6_ADDR_STATUS);
-
+ tc_wait_valid(MODEXPS6_ADDR_STATUS);
+
/* Compare actual result with expected value */
ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result));
-
+
return ret;
}
diff --git a/sw/novena-eim.c b/sw/novena-eim.c
index 85bfac0..424fcd7 100644
--- a/sw/novena-eim.c
+++ b/sw/novena-eim.c
@@ -1,12 +1,12 @@
-/*
+/*
* novena-eim.c
* ------------
* This module contains the userland magic to set up and use the EIM bus.
*
- *
+ *
* Author: Pavel Shatov
* Copyright (c) 2014-2015, NORDUnet A/S All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -118,9 +118,9 @@ enum IMX6DQ_REGISTER_OFFSET
IOMUXC_SW_PAD_CTL_PAD_EIM_AD15 = 0x020E0464,
IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_B = 0x020E0468,
IOMUXC_SW_PAD_CTL_PAD_EIM_BCLK = 0x020E046C,
-
+
CCM_CCGR6 = 0x020C4080,
-
+
EIM_CS0GCR1 = 0x021B8000,
EIM_CS0GCR2 = 0x021B8004,
EIM_CS0RCR1 = 0x021B8008,
@@ -166,17 +166,17 @@ struct CCM_CCGR6
unsigned int cg1_usdhc1 : 2;
unsigned int cg2_usdhc2 : 2;
unsigned int cg3_usdhc3 : 2;
-
+
unsigned int cg3_usdhc4 : 2;
unsigned int cg5_eim_slow : 2;
unsigned int cg6_vdoaxiclk : 2;
unsigned int cg7_vpu : 2;
-
+
unsigned int cg8_reserved : 2;
unsigned int cg9_reserved : 2;
unsigned int cg10_reserved : 2;
unsigned int cg11_reserved : 2;
-
+
unsigned int cg12_reserved : 2;
unsigned int cg13_reserved : 2;
unsigned int cg14_reserved : 2;
diff --git a/sw/tc_eim.c b/sw/tc_eim.c
index 87e90d1..76972cd 100644
--- a/sw/tc_eim.c
+++ b/sw/tc_eim.c
@@ -1,11 +1,11 @@
-/*
+/*
* tc_eim.c
* --------
* This module contains common code to talk to the FPGA over the EIM bus.
- *
+ *
* Author: Paul Selkirk
* Copyright (c) 2014-2015, NORDUnet A/S All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
diff --git a/sw/tc_i2c.c b/sw/tc_i2c.c
index bcc6be9..c49c5a8 100644
--- a/sw/tc_i2c.c
+++ b/sw/tc_i2c.c
@@ -1,11 +1,11 @@
-/*
+/*
* tc_i2c.c
* --------
* This module contains common code to talk to the FPGA over the I2C bus.
- *
+ *
* Author: Paul Selkirk
* Copyright (c) 2014-2015, NORDUnet A/S All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: