Commit c1ff2263 authored by Mike Hibler's avatar Mike Hibler

Fix nonce calculation.

Well, isn't that special. We had the arguments to memcpy backward (probably
dating from the time when we use bcopy instead). So instead of copying bytes
of goodness into the zeroed nonce buffer, we were copying bytes out.
Net result: a nonce of zeros.
parent f1308d88
......@@ -146,7 +146,7 @@ tmcd_tpm_generate_nonce(unsigned char *nonce)
pid_t pid;
int byte_count = 0;
memset(nonce,0,TPM_NONCE_BYTES);
memset(nonce, 0, TPM_NONCE_BYTES);
/*
* Nonce must be 160 bits (20 bytes) long, and we must be quite sure that
......@@ -167,7 +167,7 @@ tmcd_tpm_generate_nonce(unsigned char *nonce)
if (sizeof(time) + byte_count > TPM_NONCE_BYTES) {
return -1;
}
memcpy(&time, nonce, sizeof(time));
memcpy(nonce, &time, sizeof(time));
byte_count += sizeof(time);
// pid
......@@ -175,14 +175,14 @@ tmcd_tpm_generate_nonce(unsigned char *nonce)
if (sizeof(pid) + byte_count > TPM_NONCE_BYTES) {
return -1;
}
memcpy(&pid, nonce + byte_count, sizeof(pid));
memcpy(nonce + byte_count, &pid, sizeof(pid));
byte_count += sizeof(pid);
// counter
if (sizeof(nonce_counter) + byte_count > TPM_NONCE_BYTES) {
return -1;
}
memcpy(&nonce_counter, nonce + byte_count, sizeof(nonce_counter));
memcpy(nonce + byte_count, &nonce_counter, sizeof(nonce_counter));
byte_count += sizeof(nonce_counter);
nonce_counter++;
......
......@@ -5484,8 +5484,9 @@ COMMAND_PROTOTYPE(doquoteprep)
sprintf(nonce_hex + (i*2),"%.02x",nonce[i]);
}
nonce_hex[TPM_NONCE_BYTES*2] = '\0';
// XXX
info("NONCE: %s\n", nonce_hex);
if (debug)
info("%s: NONCE %s\n", reqp->nodeid, nonce_hex);
// Store the nonce in the database. It expires in one minute, and we
// overwrite any existing nonces for this node/state combo
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment