aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/crypto.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2009-02-18 22:27:34 +0000
committerMichael Brown <mcb30@etherboot.org>2009-02-19 00:06:41 +0000
commitb4d3d686cc67c2503976ec4c854efc3a20519203 (patch)
treec194d6d6a4b6fb93fae56bc6ac9a81607048861d /src/include/gpxe/crypto.h
parenta3219b24a8ea4699e7b04cf1f1131aade9fcd855 (diff)
downloadipxe-b4d3d686cc67c2503976ec4c854efc3a20519203.tar.gz
[crypto] Change cipher_{en,de}crypt() to void functions
It is a programming error, not a runtime error, if we attempt to use block ciphers with an incorrect blocksize, so use an assert() rather than an error status return.
Diffstat (limited to 'src/include/gpxe/crypto.h')
-rw-r--r--src/include/gpxe/crypto.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/include/gpxe/crypto.h b/src/include/gpxe/crypto.h
index 42860a9e0..10882d37e 100644
--- a/src/include/gpxe/crypto.h
+++ b/src/include/gpxe/crypto.h
@@ -70,7 +70,6 @@ struct cipher_algorithm {
* @v src Data to encrypt
* @v dst Buffer for encrypted data
* @v len Length of data
- * @ret rc Return status code
*
* @v len is guaranteed to be a multiple of @c blocksize.
*/
@@ -82,7 +81,6 @@ struct cipher_algorithm {
* @v src Data to decrypt
* @v dst Buffer for decrypted data
* @v len Length of data
- * @ret rc Return status code
*
* @v len is guaranteed to be a multiple of @c blocksize.
*/
@@ -123,17 +121,30 @@ static inline void cipher_setiv ( struct cipher_algorithm *cipher,
cipher->setiv ( ctx, iv );
}
+static inline void cipher_encrypt ( struct cipher_algorithm *cipher,
+ void *ctx, const void *src, void *dst,
+ size_t len ) {
+ cipher->encrypt ( ctx, src, dst, len );
+}
+#define cipher_encrypt( cipher, ctx, src, dst, len ) do { \
+ assert ( ( len & ( (cipher)->blocksize - 1 ) ) == 0 ); \
+ cipher_encrypt ( (cipher), (ctx), (src), (dst), (len) ); \
+ } while ( 0 )
+
+static inline void cipher_decrypt ( struct cipher_algorithm *cipher,
+ void *ctx, const void *src, void *dst,
+ size_t len ) {
+ cipher->decrypt ( ctx, src, dst, len );
+}
+#define cipher_decrypt( cipher, ctx, src, dst, len ) do { \
+ assert ( ( len & ( (cipher)->blocksize - 1 ) ) == 0 ); \
+ cipher_decrypt ( (cipher), (ctx), (src), (dst), (len) ); \
+ } while ( 0 )
+
static inline int is_stream_cipher ( struct cipher_algorithm *cipher ) {
return ( cipher->blocksize == 1 );
}
-extern int cipher_encrypt ( struct cipher_algorithm *cipher,
- void *ctx, const void *src, void *dst,
- size_t len );
-extern int cipher_decrypt ( struct cipher_algorithm *cipher,
- void *ctx, const void *src, void *dst,
- size_t len );
-
extern struct digest_algorithm digest_null;
extern struct cipher_algorithm cipher_null;
extern struct pubkey_algorithm pubkey_null;