aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2009-02-19 01:20:09 +0000
committerMichael Brown <mcb30@etherboot.org>2009-02-19 01:23:50 +0000
commite950dc04bafed590c02ee2ac8a51e54ed7d8dbd0 (patch)
treeff8a5afa34442e583e0b76c0749c350f35b6739b /src/include
parentb4d3d686cc67c2503976ec4c854efc3a20519203 (diff)
downloadipxe-e950dc04bafed590c02ee2ac8a51e54ed7d8dbd0.tar.gz
[crypto] Add our own general-purpose cipher-block chaining routines
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/cbc.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/include/gpxe/cbc.h b/src/include/gpxe/cbc.h
new file mode 100644
index 000000000..e2d57764e
--- /dev/null
+++ b/src/include/gpxe/cbc.h
@@ -0,0 +1,50 @@
+#ifndef _GPXE_CBC_H
+#define _GPXE_CBC_H
+
+/** @file
+ *
+ * Cipher-block chaining
+ *
+ */
+
+#include <gpxe/crypto.h>
+
+/**
+ * Set key
+ *
+ * @v ctx Context
+ * @v key Key
+ * @v keylen Key length
+ * @v cipher Underlying cipher algorithm
+ * @v cbc_ctx CBC context
+ * @ret rc Return status code
+ */
+static inline int cbc_setkey ( void *ctx, const void *key, size_t keylen,
+ struct cipher_algorithm *cipher,
+ void *cbc_ctx __unused ) {
+
+ return cipher_setkey ( cipher, ctx, key, keylen );
+}
+
+/**
+ * Set initialisation vector
+ *
+ * @v ctx Context
+ * @v iv Initialisation vector
+ * @v cipher Underlying cipher algorithm
+ * @v cbc_ctx CBC context
+ */
+static inline void cbc_setiv ( void *ctx __unused, const void *iv,
+ struct cipher_algorithm *cipher,
+ void *cbc_ctx ) {
+ memcpy ( cbc_ctx, iv, cipher->blocksize );
+}
+
+extern void cbc_encrypt ( void *ctx, const void *src, void *dst,
+ size_t len, struct cipher_algorithm *cipher,
+ void *cbc_ctx );
+extern void cbc_decrypt ( void *ctx, const void *src, void *dst,
+ size_t len, struct cipher_algorithm *cipher,
+ void *cbc_ctx );
+
+#endif /* _GPXE_CBC_H */