aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/ixp4xx_crypto.c
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khc@pm.waw.pl>2010-01-10 08:20:10 -0500
committerKrzysztof Hałasa <khc@pm.waw.pl>2010-05-27 07:02:42 -0400
commitce057297fdab808d9a071c084b7405bc6c8d14c5 (patch)
tree2cd70e246e45408454107e3d73658683331532f7 /drivers/crypto/ixp4xx_crypto.c
parent627634293ae7f4ec864cecd4282650ceae7a5067 (diff)
IXP4xx: Fix ixp4xx_crypto little-endian operation.
Fixes the following on IXP425 little-endian: NPE-C: firmware functionality 0x5, revision 0x2:1 alg: skcipher: Test 1 failed on encryption for ecb(des)-ixp4xx 00000000: 01 23 45 67 89 ab cd e7 alg: skcipher: Test 1 failed on encryption for ecb(des3_ede)-ixp4xx 00000000: 73 6f 6d 65 64 61 74 61 alg: skcipher: Test 1 failed on encryption for ecb(aes)-ixp4xx 00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Acked-by: Christian Hohnstaedt <chohnstaedt@innominate.com>
Diffstat (limited to 'drivers/crypto/ixp4xx_crypto.c')
-rw-r--r--drivers/crypto/ixp4xx_crypto.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index f17ddf37a1e..0d662213c06 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -97,8 +97,13 @@
97 97
98struct buffer_desc { 98struct buffer_desc {
99 u32 phys_next; 99 u32 phys_next;
100#ifdef __ARMEB__
100 u16 buf_len; 101 u16 buf_len;
101 u16 pkt_len; 102 u16 pkt_len;
103#else
104 u16 pkt_len;
105 u16 buf_len;
106#endif
102 u32 phys_addr; 107 u32 phys_addr;
103 u32 __reserved[4]; 108 u32 __reserved[4];
104 struct buffer_desc *next; 109 struct buffer_desc *next;
@@ -106,17 +111,30 @@ struct buffer_desc {
106}; 111};
107 112
108struct crypt_ctl { 113struct crypt_ctl {
114#ifdef __ARMEB__
109 u8 mode; /* NPE_OP_* operation mode */ 115 u8 mode; /* NPE_OP_* operation mode */
110 u8 init_len; 116 u8 init_len;
111 u16 reserved; 117 u16 reserved;
118#else
119 u16 reserved;
120 u8 init_len;
121 u8 mode; /* NPE_OP_* operation mode */
122#endif
112 u8 iv[MAX_IVLEN]; /* IV for CBC mode or CTR IV for CTR mode */ 123 u8 iv[MAX_IVLEN]; /* IV for CBC mode or CTR IV for CTR mode */
113 u32 icv_rev_aes; /* icv or rev aes */ 124 u32 icv_rev_aes; /* icv or rev aes */
114 u32 src_buf; 125 u32 src_buf;
115 u32 dst_buf; 126 u32 dst_buf;
127#ifdef __ARMEB__
116 u16 auth_offs; /* Authentication start offset */ 128 u16 auth_offs; /* Authentication start offset */
117 u16 auth_len; /* Authentication data length */ 129 u16 auth_len; /* Authentication data length */
118 u16 crypt_offs; /* Cryption start offset */ 130 u16 crypt_offs; /* Cryption start offset */
119 u16 crypt_len; /* Cryption data length */ 131 u16 crypt_len; /* Cryption data length */
132#else
133 u16 auth_len; /* Authentication data length */
134 u16 auth_offs; /* Authentication start offset */
135 u16 crypt_len; /* Cryption data length */
136 u16 crypt_offs; /* Cryption start offset */
137#endif
120 u32 aadAddr; /* Additional Auth Data Addr for CCM mode */ 138 u32 aadAddr; /* Additional Auth Data Addr for CCM mode */
121 u32 crypto_ctx; /* NPE Crypto Param structure address */ 139 u32 crypto_ctx; /* NPE Crypto Param structure address */
122 140
@@ -652,6 +670,9 @@ static int setup_auth(struct crypto_tfm *tfm, int encrypt, unsigned authsize,
652 670
653 /* write cfg word to cryptinfo */ 671 /* write cfg word to cryptinfo */
654 cfgword = algo->cfgword | ( authsize << 6); /* (authsize/4) << 8 */ 672 cfgword = algo->cfgword | ( authsize << 6); /* (authsize/4) << 8 */
673#ifndef __ARMEB__
674 cfgword ^= 0xAA000000; /* change the "byte swap" flags */
675#endif
655 *(u32*)cinfo = cpu_to_be32(cfgword); 676 *(u32*)cinfo = cpu_to_be32(cfgword);
656 cinfo += sizeof(cfgword); 677 cinfo += sizeof(cfgword);
657 678