aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-07-05 22:45:35 -0400
committerPaul Selkirk <paul@psgd.org>2016-07-05 22:45:35 -0400
commit30f8e4e85b6a337291b09d55d8edc15e422b6341 (patch)
tree19199dd47bb98e18a96281d34e35d1971565fc72 /tests
parente1c57eff41a57b8a3f16e5d652b5598d75887a21 (diff)
Attempt to add resource management, for multiple cores of the same type.
Find a suitable core, and mark it busy. Don't forget to release it as soon as you're done. This has a knock-on effect of un-const'ing core arguments and struct fields in a lot of places, and it moves some core checks around.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-aes-key-wrap.c4
-rw-r--r--tests/test-hash.c12
-rw-r--r--tests/test-mkmif.c12
-rw-r--r--tests/test-pbkdf2.c4
-rw-r--r--tests/test-rsa.c10
5 files changed, 21 insertions, 21 deletions
diff --git a/tests/test-aes-key-wrap.c b/tests/test-aes-key-wrap.c
index 1207acb..5ecd46d 100644
--- a/tests/test-aes-key-wrap.c
+++ b/tests/test-aes-key-wrap.c
@@ -109,7 +109,7 @@ static const char *format_hex(const uint8_t *bin, const size_t len, char *hex, c
return hex;
}
-static int run_test(const hal_core_t *core,
+static int run_test(hal_core_t *core,
const uint8_t * const K, const size_t K_len,
const uint8_t * const C, const size_t C_len)
{
@@ -169,7 +169,7 @@ int main (int argc, char *argv[])
printf("Testing whether AES core reports present...");
- const hal_core_t *core = hal_core_find(AES_CORE_NAME, NULL);
+ hal_core_t *core = hal_core_find(AES_CORE_NAME, NULL);
if (core == NULL) {
printf("no, skipping keywrap tests\n");
diff --git a/tests/test-hash.c b/tests/test-hash.c
index 65ddf15..4e78243 100644
--- a/tests/test-hash.c
+++ b/tests/test-hash.c
@@ -540,7 +540,7 @@ static const uint8_t hmac_sha2_tc_7_result_sha512[] = { /* 64 bytes */
0xfa, 0x8c, 0x6a, 0x58
};
-static int _test_hash(const hal_core_t *core,
+static int _test_hash(hal_core_t *core,
const hal_hash_descriptor_t * const descriptor,
const uint8_t * const data, const size_t data_len,
const uint8_t * const result, const size_t result_len,
@@ -588,7 +588,7 @@ static int _test_hash(const hal_core_t *core,
return 1;
}
-static int _test_hmac(const hal_core_t *core,
+static int _test_hmac(hal_core_t *core,
const hal_hash_descriptor_t * const descriptor,
const uint8_t * const key, const size_t key_len,
const uint8_t * const data, const size_t data_len,
@@ -643,7 +643,7 @@ static int _test_hmac(const hal_core_t *core,
#define test_hmac(_core_, _desc_, _key_, _data_, _result_, _label_) \
_test_hmac(_core_, _desc_, _key_, sizeof(_key_), _data_, sizeof(_data_), _result_, sizeof(_result_), _label_)
-static void show_core(const hal_core_t *core, const char *whinge)
+static void show_core(hal_core_t *core, const char *whinge)
{
const hal_core_info_t *core_info = hal_core_info(core);
if (core_info != NULL)
@@ -654,9 +654,9 @@ static void show_core(const hal_core_t *core, const char *whinge)
int main (int argc, char *argv[])
{
- const hal_core_t * const sha1_core = hal_core_find(SHA1_NAME, NULL);
- const hal_core_t * const sha256_core = hal_core_find(SHA256_NAME, NULL);
- const hal_core_t * const sha512_core = hal_core_find(SHA512_NAME, NULL);
+ hal_core_t * const sha1_core = hal_core_find(SHA1_NAME, NULL);
+ hal_core_t * const sha256_core = hal_core_find(SHA256_NAME, NULL);
+ hal_core_t * const sha512_core = hal_core_find(SHA512_NAME, NULL);
show_core(sha1_core, "sha-1");
show_core(sha256_core, "sha-256");
diff --git a/tests/test-mkmif.c b/tests/test-mkmif.c
index a382cf6..ab5801e 100644
--- a/tests/test-mkmif.c
+++ b/tests/test-mkmif.c
@@ -19,7 +19,7 @@ typedef union {
uint32_t word;
} byteword_t;
-static hal_error_t sclk_test(const hal_core_t *core, const uint32_t divisor)
+static hal_error_t sclk_test(hal_core_t *core, const uint32_t divisor)
{
uint32_t readback;
hal_error_t err;
@@ -41,7 +41,7 @@ static hal_error_t sclk_test(const hal_core_t *core, const uint32_t divisor)
return HAL_OK;
}
-static hal_error_t init_test(const hal_core_t *core)
+static hal_error_t init_test(hal_core_t *core)
{
hal_error_t err;
@@ -55,7 +55,7 @@ static hal_error_t init_test(const hal_core_t *core)
return HAL_OK;
}
-static hal_error_t write_test(const hal_core_t *core)
+static hal_error_t write_test(hal_core_t *core)
{
uint32_t write_data;
uint32_t write_address;
@@ -78,7 +78,7 @@ static hal_error_t write_test(const hal_core_t *core)
return HAL_OK;
}
-static hal_error_t read_test(const hal_core_t *core)
+static hal_error_t read_test(hal_core_t *core)
{
uint32_t read_data;
uint32_t read_address;
@@ -101,7 +101,7 @@ static hal_error_t read_test(const hal_core_t *core)
return HAL_OK;
}
-static hal_error_t write_read_test(const hal_core_t *core)
+static hal_error_t write_read_test(hal_core_t *core)
{
uint32_t data;
uint32_t readback;
@@ -131,7 +131,7 @@ static hal_error_t write_read_test(const hal_core_t *core)
int main(void)
{
- const hal_core_t *core = hal_core_find(MKMIF_NAME, NULL);
+ hal_core_t *core = hal_core_find(MKMIF_NAME, NULL);
if (core == NULL) {
printf("MKMIF core not present, not testing.\n");
diff --git a/tests/test-pbkdf2.c b/tests/test-pbkdf2.c
index 6de4b99..f3072a7 100644
--- a/tests/test-pbkdf2.c
+++ b/tests/test-pbkdf2.c
@@ -154,7 +154,7 @@ static void print_hex(const uint8_t * const val, const size_t len)
printf(" %02x", val[i]);
}
-static int _test_pbkdf2(const hal_core_t *core,
+static int _test_pbkdf2(hal_core_t *core,
const uint8_t * const pwd, const size_t pwd_len,
const uint8_t * const salt, const size_t salt_len,
const uint8_t * const dk, const size_t dk_len,
@@ -198,7 +198,7 @@ static int _test_pbkdf2(const hal_core_t *core,
int main (int argc, char *argv[])
{
- const hal_core_t *core = hal_core_find(SHA1_NAME, NULL);
+ hal_core_t *core = hal_core_find(SHA1_NAME, NULL);
int ok = 1;
if (core == NULL)
diff --git a/tests/test-rsa.c b/tests/test-rsa.c
index 60fe2a5..57037c0 100644
--- a/tests/test-rsa.c
+++ b/tests/test-rsa.c
@@ -49,7 +49,7 @@
* Run one modexp test.
*/
-static int test_modexp(const hal_core_t *core,
+static int test_modexp(hal_core_t *core,
const char * const kind,
const rsa_tc_t * const tc,
const rsa_tc_bn_t * const msg, /* Input message */
@@ -74,7 +74,7 @@ static int test_modexp(const hal_core_t *core,
* Run one RSA CRT test.
*/
-static int test_decrypt(const hal_core_t *core,
+static int test_decrypt(hal_core_t *core,
const char * const kind,
const rsa_tc_t * const tc)
{
@@ -115,7 +115,7 @@ static int test_decrypt(const hal_core_t *core,
* Run one RSA key generation + CRT test.
*/
-static int test_gen(const hal_core_t *core,
+static int test_gen(hal_core_t *core,
const char * const kind,
const rsa_tc_t * const tc)
{
@@ -277,7 +277,7 @@ static void _time_check(const struct timeval t0, const int ok)
* and try generating a signature with that.
*/
-static int test_rsa(const hal_core_t *core, const rsa_tc_t * const tc)
+static int test_rsa(hal_core_t *core, const rsa_tc_t * const tc)
{
int ok = 1;
@@ -298,7 +298,7 @@ static int test_rsa(const hal_core_t *core, const rsa_tc_t * const tc)
int main(int argc, char *argv[])
{
- const hal_core_t *core = hal_core_find(MODEXPS6_NAME, NULL);
+ hal_core_t *core = hal_core_find(MODEXPS6_NAME, NULL);
if (core == NULL)
core = hal_core_find(MODEXPA7_NAME, NULL);
const hal_core_info_t *core_info = hal_core_info(core);