diff options
author | Andy Polyakov <appro@openssl.org> | 2011-04-20 08:13:58 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2011-04-20 08:13:58 +0000 |
commit | daaf5088fd20fe7c00a96a1cbae05e47b5dd2fc5 (patch) | |
tree | 2a5a06f64a093f4ee87e29e8470803152441878e /crypto/modes/xts128.c | |
parent | e382e4e603079bec1c565b08fdaa2b3c5bd70b49 (diff) | |
download | openssl-daaf5088fd20fe7c00a96a1cbae05e47b5dd2fc5.zip openssl-daaf5088fd20fe7c00a96a1cbae05e47b5dd2fc5.tar.gz openssl-daaf5088fd20fe7c00a96a1cbae05e47b5dd2fc5.tar.bz2 |
xts128.c: minor optimization and clarified prototype.
Diffstat (limited to 'crypto/modes/xts128.c')
-rw-r--r-- | crypto/modes/xts128.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/modes/xts128.c b/crypto/modes/xts128.c index aaa44e0..6859ab6 100644 --- a/crypto/modes/xts128.c +++ b/crypto/modes/xts128.c @@ -58,7 +58,7 @@ #endif #include <assert.h> -int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char *iv, +int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], const unsigned char *inp, unsigned char *out, size_t len, int enc) { @@ -84,9 +84,14 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char *iv, scratch.u[1] = ((u64*)inp)[1]^tweak.u[1]; #endif (*ctx->block1)(scratch.c,scratch.c,ctx->key1); +#if defined(STRICT_ALIGNMENT) scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; memcpy(out,scratch.c,16); +#else + ((u64*)out)[0] = scratch.u[0]^tweak.u[0]; + ((u64*)out)[1] = scratch.u[1]^tweak.u[1]; +#endif inp += 16; out += 16; len -= 16; @@ -166,9 +171,14 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char *iv, scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; (*ctx->block1)(scratch.c,scratch.c,ctx->key1); +#if defined(STRICT_ALIGNMENT) scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; memcpy (out,scratch.c,16); +#else + ((u64*)out)[0] = scratch.u[0]^tweak.u[0]; + ((u64*)out)[1] = scratch.u[1]^tweak.u[1]; +#endif } return 0; |