aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-02-20 21:26:23 +0000
committerMichael Brown <mcb30@ipxe.org>2012-02-21 12:42:46 +0000
commit4e0effc6ad3b9f39859e259dd8f1f8af91c5b480 (patch)
tree2bf6c739f1e82bbb59d12010f0844734dd19e645 /src/include/ipxe
parentc6b0b3424bd703aa0c15ae5397d3da0234b61c41 (diff)
downloadipxe-4e0effc6ad3b9f39859e259dd8f1f8af91c5b480.zip
ipxe-4e0effc6ad3b9f39859e259dd8f1f8af91c5b480.tar.gz
ipxe-4e0effc6ad3b9f39859e259dd8f1f8af91c5b480.tar.bz2
[rng] Add ANS X9.82 RBG wrapper functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/rbg.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/include/ipxe/rbg.h b/src/include/ipxe/rbg.h
new file mode 100644
index 0000000..9689142
--- /dev/null
+++ b/src/include/ipxe/rbg.h
@@ -0,0 +1,43 @@
+#ifndef _IPXE_RBG_H
+#define _IPXE_RBG_H
+
+/** @file
+ *
+ * RBG mechanism
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <ipxe/drbg.h>
+
+/** An RBG */
+struct random_bit_generator {
+ /** DRBG state */
+ struct drbg_state state;
+};
+
+extern struct random_bit_generator rbg;
+
+/**
+ * Generate bits using RBG
+ *
+ * @v additional Additional input
+ * @v additional_len Length of additional input
+ * @v prediction_resist Prediction resistance is required
+ * @v data Output buffer
+ * @v len Length of output buffer
+ * @ret rc Return status code
+ *
+ * This is the RBG_Generate function defined in ANS X9.82 Part 4
+ * (April 2011 Draft) Section 9.1.2.2.
+ */
+static inline int rbg_generate ( const void *additional, size_t additional_len,
+ int prediction_resist, void *data,
+ size_t len ) {
+ return drbg_generate ( &rbg.state, additional, additional_len,
+ prediction_resist, data, len );
+}
+
+#endif /* _IPXE_RBG_H */