]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - hashfunction_descriptor.h
new hash function abstraction layer + shavs + dump util + ...
[avr-crypto-lib.git] / hashfunction_descriptor.h
diff --git a/hashfunction_descriptor.h b/hashfunction_descriptor.h
new file mode 100644 (file)
index 0000000..3440cd0
--- /dev/null
@@ -0,0 +1,45 @@
+/* hashfunction_descriptor.h */
+
+#ifndef HASHFUNCTION_DESCRIPTOR_H_
+#define HASHFUNCTION_DESCRIPTOR_H_
+#include <stdint.h>
+#include <avr/pgmspace.h>
+
+#ifndef VOID_FPT
+#define VOID_FPT
+typedef void(*void_fpt)(void);
+#endif
+
+typedef void(*hf_init_fpt)(void*);
+typedef void(*hf_nextBlock_fpt)(void*, const void*);
+typedef void(*hf_lastBlock_fpt)(void*, const void*, uint16_t);
+typedef void(*hf_ctx2hash_fpt)(void*, void*);
+typedef void(*hf_free_fpt)(void*);
+typedef void(*hf_mem_fpt)(void*, void*, uint32_t);
+
+
+#define HFDESC_TYPE_HASHFUNCTION 0x02
+
+typedef struct {
+       uint8_t  type; /* 2 == hashfunction */
+       uint8_t  flags;
+       PGM_P    name;
+       uint16_t ctxsize_B;
+       uint16_t blocksize_b;
+       uint16_t hashsize_b;
+       
+       hf_init_fpt init;
+       hf_nextBlock_fpt  nextBlock;
+       hf_lastBlock_fpt  lastBlock;
+       hf_ctx2hash_fpt   ctx2hash;
+       hf_free_fpt free;
+       hf_mem_fpt mem;
+} hfdesc_t; /* blockcipher descriptor type */
+
+typedef struct{
+       hfdesc_t* desc_ptr;
+       void*     ctx;
+} hfgen_ctx_t;
+
+#endif /* HASHFUNCTION_DESCRIPTOR_H_ */
+