diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/crc32.h | 2 | ||||
-rw-r--r-- | include/ouroboros/hash.h | 17 | ||||
-rw-r--r-- | include/ouroboros/ipcp.h | 4 |
3 files changed, 19 insertions, 4 deletions
diff --git a/include/ouroboros/crc32.h b/include/ouroboros/crc32.h index dccdf7cb..800d6c4f 100644 --- a/include/ouroboros/crc32.h +++ b/include/ouroboros/crc32.h @@ -27,6 +27,8 @@ #include <stdint.h> #include <stddef.h> +#define CRC32_HASH_LEN 4 + void crc32(uint32_t * crc, const void * buf, size_t len); diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h index a94b37ee..60bfbe30 100644 --- a/include/ouroboros/hash.h +++ b/include/ouroboros/hash.h @@ -28,6 +28,15 @@ #include <ouroboros/md5.h> #include <ouroboros/sha3.h> +enum hash_algo { + HASH_CRC32 = 0, + HASH_MD5, + HASH_SHA3_224, + HASH_SHA3_256, + HASH_SHA3_384, + HASH_SHA3_512 +}; + #define HASH_FMT "%02x%02x%02x%02x" #define HASH_VAL(hash) \ ((*(unsigned int *) hash) & 0xFF000000) >> 24, \ @@ -35,8 +44,10 @@ ((*(unsigned int *) hash) & 0x0000FF00) >> 8, \ ((*(unsigned int *) hash) & 0x000000FF) -/* FIXME: Implement specifying algorithm */ -void get_hash(uint8_t buf[], - const char * name); +uint16_t hash_len(enum hash_algo algo); + +void str_hash(enum hash_algo algo, + void * buf, + const char * str); #endif /* OUROBOROS_LIB_HASH_H */ diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index f439f29b..4c815b83 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -24,6 +24,8 @@ #ifndef OUROBOROS_IPCP_H #define OUROBOROS_IPCP_H +#include <ouroboros/hash.h> + #include <stdint.h> #include <unistd.h> #include <stdbool.h> @@ -51,7 +53,7 @@ enum pol_gam { struct ipcp_config { char * dif_name; enum ipcp_type type; - uint16_t dir_hash_len; + enum hash_algo dir_hash_algo; /* Normal DIF */ uint8_t addr_size; |