|
@@ -370,26 +370,23 @@ static void
|
|
test_encoding(void *arg)
|
|
test_encoding(void *arg)
|
|
{
|
|
{
|
|
(void) arg;
|
|
(void) arg;
|
|
- int ret, duper_rand = 42;
|
|
|
|
|
|
+ int ret;
|
|
/* Random number is 32 bytes. */
|
|
/* Random number is 32 bytes. */
|
|
char raw_rand[32];
|
|
char raw_rand[32];
|
|
time_t ts = 1454333590;
|
|
time_t ts = 1454333590;
|
|
char hashed_rand[DIGEST256_LEN], hashed_reveal[DIGEST256_LEN];
|
|
char hashed_rand[DIGEST256_LEN], hashed_reveal[DIGEST256_LEN];
|
|
sr_commit_t parsed_commit;
|
|
sr_commit_t parsed_commit;
|
|
|
|
|
|
- /* Encoded commit is: base64-encode( 1454333590 || H(H(42)) ). Remember
|
|
|
|
- * that we do no expose the raw bytes of our PRNG to the network thus
|
|
|
|
- * explaining the double H(). */
|
|
|
|
- static const char *encoded_commit =
|
|
|
|
- "AAAAAFavXpZbx2LRneYFSLPCP8DLp9BXfeH5FXzbkxM4iRXKGeA54g==";
|
|
|
|
- /* Encoded reveal is: base64-encode( 1454333590 || H(42) ). */
|
|
|
|
|
|
+ /* Those values were generated by sr_commit_calc_ref.py where the random
|
|
|
|
+ * value is 32 'A' and timestamp is the one in ts. */
|
|
static const char *encoded_reveal =
|
|
static const char *encoded_reveal =
|
|
- "AAAAAFavXpYk9x9kTjiQWUqjHwSAEOdPAfCaurXgjPy173SzYjeC2g==";
|
|
|
|
|
|
+ "AAAAAFavXpZJxbwTupvaJCTeIUCQmOPxAMblc7ChL5H2nZKuGchdaA==";
|
|
|
|
+ static const char *encoded_commit =
|
|
|
|
+ "AAAAAFavXpbkBMzMQG7aNoaGLFNpm2Wkk1ozXhuWWqL//GynltxVAg==";
|
|
|
|
|
|
/* Set up our raw random bytes array. */
|
|
/* Set up our raw random bytes array. */
|
|
- memset(raw_rand, 0, sizeof(raw_rand));
|
|
|
|
- memcpy(raw_rand, &duper_rand, sizeof(duper_rand));
|
|
|
|
- /* Hash random number. */
|
|
|
|
|
|
+ memset(raw_rand, 'A', sizeof(raw_rand));
|
|
|
|
+ /* Hash random number because we don't expose bytes of the RNG. */
|
|
ret = crypto_digest256(hashed_rand, raw_rand,
|
|
ret = crypto_digest256(hashed_rand, raw_rand,
|
|
sizeof(raw_rand), SR_DIGEST_ALG);
|
|
sizeof(raw_rand), SR_DIGEST_ALG);
|
|
tt_int_op(0, ==, ret);
|
|
tt_int_op(0, ==, ret);
|