summaryrefslogtreecommitdiff
path: root/cipher
diff options
context:
space:
mode:
Diffstat (limited to 'cipher')
-rw-r--r--cipher/sha1.c38
-rw-r--r--cipher/sha1.h3
2 files changed, 41 insertions, 0 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c
index 19e75b23..d15c2a29 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -130,6 +130,17 @@ sha1_init (void *context, unsigned int flags)
(void)features;
}
+/*
+ * Initialize the context HD. This is used to prepare the use of
+ * _gcry_sha1_mixblock. WARNING: This is a special purpose function
+ * for exclusive use by random-csprng.c.
+ */
+void
+_gcry_sha1_mixblock_init (SHA1_CONTEXT *hd)
+{
+ sha1_init (hd, 0);
+}
+
/* Round function macros. */
#define K1 0x5A827999L
@@ -354,6 +365,33 @@ transform (void *ctx, const unsigned char *data, size_t nblks)
}
+/*
+ * Apply the SHA-1 transform function on the buffer BLOCKOF64BYTE
+ * which must have a length 64 bytes. BLOCKOF64BYTE must be 32-bit
+ * aligned. Updates the 20 bytes in BLOCKOF64BYTE with its mixed
+ * content. Returns the number of bytes which should be burned on the
+ * stack. You need to use _gcry_sha1_mixblock_init to initialize the
+ * context.
+ * WARNING: This is a special purpose function for exclusive use by
+ * random-csprng.c.
+ */
+unsigned int
+_gcry_sha1_mixblock (SHA1_CONTEXT *hd, void *blockof64byte)
+{
+ u32 *p = blockof64byte;
+ unsigned int nburn;
+
+ nburn = transform (hd, blockof64byte, 1);
+ p[0] = hd->h0;
+ p[1] = hd->h1;
+ p[2] = hd->h2;
+ p[3] = hd->h3;
+ p[4] = hd->h4;
+
+ return nburn;
+}
+
+
/* The routine final terminates the computation and
* returns the digest.
* The handle is prepared for a new cycle, but adding bytes to the
diff --git a/cipher/sha1.h b/cipher/sha1.h
index c023e15c..6b87631c 100644
--- a/cipher/sha1.h
+++ b/cipher/sha1.h
@@ -33,4 +33,7 @@ typedef struct
} SHA1_CONTEXT;
+void _gcry_sha1_mixblock_init (SHA1_CONTEXT *hd);
+unsigned int _gcry_sha1_mixblock (SHA1_CONTEXT *hd, void *blockof64byte);
+
#endif /*GCRY_SHA1_H*/