summaryrefslogtreecommitdiffstats
path: root/thirdparty/mbedtls/library/padlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/mbedtls/library/padlock.c')
-rw-r--r--thirdparty/mbedtls/library/padlock.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/thirdparty/mbedtls/library/padlock.c b/thirdparty/mbedtls/library/padlock.c
index 0b4b610f96..1f006910c2 100644
--- a/thirdparty/mbedtls/library/padlock.c
+++ b/thirdparty/mbedtls/library/padlock.c
@@ -15,16 +15,10 @@
#if defined(MBEDTLS_PADLOCK_C)
-#include "mbedtls/padlock.h"
+#include "padlock.h"
#include <string.h>
-/* *INDENT-OFF* */
-#ifndef asm
-#define asm __asm
-#endif
-/* *INDENT-ON* */
-
#if defined(MBEDTLS_VIA_PADLOCK_HAVE_CODE)
/*
@@ -71,7 +65,12 @@ int mbedtls_padlock_xcryptecb(mbedtls_aes_context *ctx,
uint32_t *ctrl;
unsigned char buf[256];
- rk = ctx->rk;
+ rk = ctx->buf + ctx->rk_offset;
+
+ if (((long) rk & 15) != 0) {
+ return MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED;
+ }
+
blk = MBEDTLS_PADLOCK_ALIGN16(buf);
memcpy(blk, input, 16);
@@ -97,6 +96,7 @@ int mbedtls_padlock_xcryptecb(mbedtls_aes_context *ctx,
return 0;
}
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
/*
* PadLock AES-CBC buffer en(de)cryption
*/
@@ -114,12 +114,14 @@ int mbedtls_padlock_xcryptcbc(mbedtls_aes_context *ctx,
uint32_t *ctrl;
unsigned char buf[256];
+ rk = ctx->buf + ctx->rk_offset;
+
if (((long) input & 15) != 0 ||
- ((long) output & 15) != 0) {
+ ((long) output & 15) != 0 ||
+ ((long) rk & 15) != 0) {
return MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED;
}
- rk = ctx->rk;
iw = MBEDTLS_PADLOCK_ALIGN16(buf);
memcpy(iw, iv, 16);
@@ -148,6 +150,7 @@ int mbedtls_padlock_xcryptcbc(mbedtls_aes_context *ctx,
return 0;
}
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
#endif /* MBEDTLS_VIA_PADLOCK_HAVE_CODE */