aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/camellia/cmll_misc.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2006-12-02 10:38:40 +0000
committerAndy Polyakov <appro@openssl.org>2006-12-02 10:38:40 +0000
commit20da8b8f90a0fb58e7e4d0862b8d57765e0f3672 (patch)
tree6f2a26eaa0ef7f900730ab4cb61edec54280451c /crypto/camellia/cmll_misc.c
parentae93dc13abdb281080c0808d1ce1a0f4129348f0 (diff)
downloadopenssl-20da8b8f90a0fb58e7e4d0862b8d57765e0f3672.tar.gz
Camellia portability fixes.
Submitted by: Masashi Fujita, NTT
Diffstat (limited to 'crypto/camellia/cmll_misc.c')
-rw-r--r--crypto/camellia/cmll_misc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/camellia/cmll_misc.c b/crypto/camellia/cmll_misc.c
index 3c4ec36662..c9c26e248a 100644
--- a/crypto/camellia/cmll_misc.c
+++ b/crypto/camellia/cmll_misc.c
@@ -91,20 +91,26 @@ int Camellia_set_key(const unsigned char *userKey, const int bits,
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
const CAMELLIA_KEY *key)
{
- uint32_t tmp[UNITSIZE];
+ u32 tmp[UNITSIZE];
+ const union { long one; char little; } camellia_endian = {1};
memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
+ if (camellia_endian.little) SWAP4WORD(tmp);
key->enc(key->rd_key, tmp);
+ if (camellia_endian.little) SWAP4WORD(tmp);
memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
}
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
const CAMELLIA_KEY *key)
{
- uint32_t tmp[UNITSIZE];
+ u32 tmp[UNITSIZE];
+ const union { long one; char little; } camellia_endian = {1};
memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
+ if (camellia_endian.little) SWAP4WORD(tmp);
key->dec(key->rd_key, tmp);
+ if (camellia_endian.little) SWAP4WORD(tmp);
memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
}