summaryrefslogtreecommitdiff
path: root/yarrow.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2001-10-07 23:11:05 +0200
committerNiels Möller <nisse@lysator.liu.se>2001-10-07 23:11:05 +0200
commitc4260b99b7ee425ca8dcc3c61713e27a7cb11d8f (patch)
tree2e5ef0af24376d42e98ada50eb8949210e774227 /yarrow.h
parent9d103c654318485f5ce3b4081e81ca68d84d3736 (diff)
downloadnettle-c4260b99b7ee425ca8dcc3c61713e27a7cb11d8f.tar.gz
* yarrow256.c: New file, implementing Yarrow.
Rev: src/nettle/yarrow.h:1.3 Rev: src/nettle/yarrow256.c:1.1
Diffstat (limited to 'yarrow.h')
-rw-r--r--yarrow.h46
1 files changed, 44 insertions, 2 deletions
diff --git a/yarrow.h b/yarrow.h
index 65486532..5dbb3be8 100644
--- a/yarrow.h
+++ b/yarrow.h
@@ -26,19 +26,22 @@
#ifndef NETTLE_YARROW_COMPAT_H_INCLUDED
#define NETTLE_YARROW_COMPAT_H_INCLUDED
-#include "sha1.h"
+#include "aes.h"
#include "des.h"
+#include "sha.h"
enum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 };
struct yarrow_source
{
- uint32_t estimate;
+ /* Indexed by yarrow_pool_id */
+ uint32_t estimate[2];
/* The pool next sample should go to. */
enum yarrow_pool_id next;
};
+/* Yarrow-160, based on SHA1 and DES3 */
struct yarrow160_ctx
{
/* Indexed by yarrow_pool_id */
@@ -67,5 +70,44 @@ yarrow160_random(struct yarrow160_ctx *ctx, unsigned length, uint8_t dst);
int
yarrow160_seeded(struct yarrow160_ctx *ctx);
+/* Yarrow-256, based on SHA-256 and AES-256 */
+struct yarrow256_ctx
+{
+ /* Indexed by yarrow_pool_id */
+ struct sha256_ctx pools[2];
+
+ int seeded;
+
+ /* The current key key and counter block */
+ struct aes_ctx key;
+ uint8_t counter[AES_BLOCK_SIZE];
+
+ uint8_t buffer[AES_BLOCK_SIZE];
+ unsigned index;
+
+ /* Number of block generated with the current key */
+ unsigned block_count;
+
+ /* The entropy sources */
+ unsigned nsources;
+ struct yarrow_source *sources;
+};
+
+void
+yarrow256_init(struct yarrow256_ctx *ctx,
+ int nsources,
+ struct yarrow_source *sources);
+
+void
+yarrow256_update(struct yarrow256_ctx *ctx,
+ unsigned source, unsigned entropy,
+ unsigned length, const uint8_t *data);
+
+void
+yarrow256_random(struct yarrow256_ctx *ctx, unsigned length, uint8_t *dst);
+
+int
+yarrow256_seeded(struct yarrow256_ctx *ctx);
+
#endif /* NETTLE_YARROW_COMPAT_H_INCLUDED */