Added sha256 hash function and hmac functions (with and without salt) to the kernel
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.
This commit is contained in:
18
kern/include/kern/secure.h
Normal file
18
kern/include/kern/secure.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _KERN_SECURE_H_
|
||||
#define _KERN_SECURE_H_
|
||||
|
||||
/*
|
||||
* Compute the FIPS 198-1 complient HMAC of msg using SHA256.
|
||||
*
|
||||
* hmac_with_salt uses a salted key and sets salt_str to this value (in hex).
|
||||
* Both functions below create hash_str with the hex readable version of the hash.
|
||||
*
|
||||
* Callers need to free hash_str (and salt_str) when done.
|
||||
*/
|
||||
int hmac(const char *msg, size_t msg_len, const char *key, size_t key_len,
|
||||
char **hash_str);
|
||||
|
||||
int hmac_salted(const char *msg, size_t msg_len, const char *key, size_t key_len,
|
||||
char **hash_str, char **salt_str);
|
||||
|
||||
#endif //_KERN_SECURE_H_
|
@@ -96,6 +96,9 @@ int longstress(int, char **);
|
||||
int createstress(int, char **);
|
||||
int printfile(int, char **);
|
||||
|
||||
/* HMAC/hash tests */
|
||||
int hmacu1(int, char**);
|
||||
|
||||
/* other tests */
|
||||
int kmalloctest(int, char **);
|
||||
int kmallocstress(int, char **);
|
||||
|
Reference in New Issue
Block a user