diff --git a/common/libtest161/secure.c b/common/libtest161/secure.c index 1aabe7d..fdc9a2c 100644 --- a/common/libtest161/secure.c +++ b/common/libtest161/secure.c @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include #endif #include @@ -35,6 +38,10 @@ static const unsigned char opad[SHA256_BLOCK_SIZE] = { [0 ... SHA256_BLOCK_SIZE- static char temp_buffers[NUM_BUFFERS][BUFFER_LEN]; static int buf_num = 0; +#ifndef _KERNEL +static int did_random = 0; +#endif + static void * _alloc(size_t size) { #ifdef _KERNEL @@ -133,6 +140,15 @@ static void array_to_hex(unsigned char *a, size_t len, char *res) static void make_salt(char *salt_str) { +#ifndef _KERNEL + if (!did_random) { + did_random = 1; + time_t t; + time(&t); + srandom(t); + } +#endif + // Compute salt value uint32_t salt[SALT_BYTES/sizeof(uint32_t)]; diff --git a/common/libtest161/test161.c b/common/libtest161/test161.c index a3152df..3fed769 100644 --- a/common/libtest161/test161.c +++ b/common/libtest161/test161.c @@ -58,6 +58,13 @@ success(int status, const char * secret, const char * name) { } } +int +partial_credit(const char *secret, const char *name, int scored, int total) +{ + char buffer[128]; + snprintf(buffer, 128, "PARTIAL CREDIT %d OF %d", scored, total); + return secprintf(secret, buffer, name); +} #ifndef _KERNEL // Borrowed from parallelvm. We need atomic console writes so our diff --git a/kern/include/kern/test161.h b/kern/include/kern/test161.h index 2e77009..e159e13 100644 --- a/kern/include/kern/test161.h +++ b/kern/include/kern/test161.h @@ -37,5 +37,6 @@ int success(int, const char *, const char *); int secprintf(const char *secret, const char *msg, const char *name); +int partial_credit(const char *secret, const char *name, int scored, int total); #endif /* _KERN_TEST161_H_ */