and userspace. In userspace, this is accessed through #include <secure.h> In the kernel, this is access through #include <kern/secure.h> There is a unit test for this (hm1) that computes the hmac and compares it to the known value. The salted vesion tested offline. ----- Also, fixed usespace compile issue with not changing KERNEL_SECRET => SECRET.
17 lines
496 B
C
17 lines
496 B
C
#ifndef _SECURE_H
|
|
#define _SECURE_H
|
|
|
|
#define SHA256_BLOCK_SIZE 64
|
|
#define SHA256_OUTPUT_SIZE 32
|
|
|
|
#define TOHEX(n) n < 10 ? '0'+n : 'a' + (n-10)
|
|
|
|
// Compute the hex string from SHA256 hash output
|
|
void hex_from_hash(unsigned char hash[SHA256_OUTPUT_SIZE], char res[SHA256_OUTPUT_SIZE*2 + 1]);
|
|
|
|
// Compute the FIPS 198-1 complient HMAC of msg using SHA256
|
|
void hmac_sha256(const char *msg, size_t msg_len, char *key, size_t key_len,
|
|
unsigned char output[SHA256_OUTPUT_SIZE]);
|
|
|
|
#endif //_SECURE_H
|