Changed the hashed signed message to be in line with what test161 is expecting (id: message)
This commit is contained in:
parent
3bab32f407
commit
b9b2924ccf
@ -35,18 +35,26 @@ ksecprintf(const char * secret, const char * msg, const char * name)
|
|||||||
int
|
int
|
||||||
ksecprintf(const char * secret, const char * msg, const char * name)
|
ksecprintf(const char * secret, const char * msg, const char * name)
|
||||||
{
|
{
|
||||||
char *hash;
|
char *hash, *salt, *fullmsg;
|
||||||
char *salt;
|
|
||||||
int res;
|
int res;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
res = hmac_salted(msg, strlen(msg), secret, strlen(secret), &hash, &salt);
|
hash = salt = fullmsg = NULL;
|
||||||
if (res)
|
|
||||||
return -res;
|
// test161 expects "name: msg"
|
||||||
|
len = strlen(name) + strlen(msg) + 3; // +3 for " :" and null terminator
|
||||||
|
fullmsg = (char *)kmalloc(len);
|
||||||
|
KASSERT(fullmsg != NULL);
|
||||||
|
snprintf(fullmsg, len, "%s: %s", name, msg);
|
||||||
|
|
||||||
|
res = hmac_salted(fullmsg, len-1, secret, strlen(secret), &hash, &salt);
|
||||||
|
KASSERT(res == 0);
|
||||||
|
|
||||||
res = kprintf("(%s, %s, %s, %s: %s)\n", name, hash, salt, name, msg);
|
res = kprintf("(%s, %s, %s, %s: %s)\n", name, hash, salt, name, msg);
|
||||||
|
|
||||||
kfree(hash);
|
kfree(hash);
|
||||||
kfree(salt);
|
kfree(salt);
|
||||||
|
kfree(fullmsg);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user