summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/cipher.c')
-rw-r--r--src/crypto/cipher.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/crypto/cipher.c b/src/crypto/cipher.c
new file mode 100644
index 00000000..9c392009
--- /dev/null
+++ b/src/crypto/cipher.c
@@ -0,0 +1,24 @@
+#include <stdint.h>
+#include <errno.h>
+#include <gpxe/crypto.h>
+
+int cipher_encrypt ( struct crypto_algorithm *crypto,
+ void *ctx, const void *src, void *dst,
+ size_t len ) {
+ if ( ( len & ( crypto->blocksize - 1 ) ) ) {
+ return -EINVAL;
+ }
+ crypto->encode ( ctx, src, dst, len );
+ return 0;
+}
+
+int cipher_decrypt ( struct crypto_algorithm *crypto,
+ void *ctx, const void *src, void *dst,
+ size_t len ) {
+ if ( ( len & ( crypto->blocksize - 1 ) ) ) {
+ return -EINVAL;
+ }
+ crypto->decode ( ctx, src, dst, len );
+ return 0;
+}
+