Commit ce057297 authored by Krzysztof Hałasa's avatar Krzysztof Hałasa

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: default avatarKrzysztof Hałasa <khc@pm.waw.pl>
Acked-by: default avatarChristian Hohnstaedt <chohnstaedt@innominate.com>
parent 62763429
...@@ -97,8 +97,13 @@ ...@@ -97,8 +97,13 @@
struct buffer_desc { struct buffer_desc {
u32 phys_next; u32 phys_next;
#ifdef __ARMEB__
u16 buf_len; u16 buf_len;
u16 pkt_len; u16 pkt_len;
#else
u16 pkt_len;
u16 buf_len;
#endif
u32 phys_addr; u32 phys_addr;
u32 __reserved[4]; u32 __reserved[4];
struct buffer_desc *next; struct buffer_desc *next;
...@@ -106,17 +111,30 @@ struct buffer_desc { ...@@ -106,17 +111,30 @@ struct buffer_desc {
}; };
struct crypt_ctl { struct crypt_ctl {
#ifdef __ARMEB__
u8 mode; /* NPE_OP_* operation mode */ u8 mode; /* NPE_OP_* operation mode */
u8 init_len; u8 init_len;
u16 reserved; u16 reserved;
#else
u16 reserved;
u8 init_len;
u8 mode; /* NPE_OP_* operation mode */
#endif
u8 iv[MAX_IVLEN]; /* IV for CBC mode or CTR IV for CTR mode */ u8 iv[MAX_IVLEN]; /* IV for CBC mode or CTR IV for CTR mode */
u32 icv_rev_aes; /* icv or rev aes */ u32 icv_rev_aes; /* icv or rev aes */
u32 src_buf; u32 src_buf;
u32 dst_buf; u32 dst_buf;
#ifdef __ARMEB__
u16 auth_offs; /* Authentication start offset */ u16 auth_offs; /* Authentication start offset */
u16 auth_len; /* Authentication data length */ u16 auth_len; /* Authentication data length */
u16 crypt_offs; /* Cryption start offset */ u16 crypt_offs; /* Cryption start offset */
u16 crypt_len; /* Cryption data length */ u16 crypt_len; /* Cryption data length */
#else
u16 auth_len; /* Authentication data length */
u16 auth_offs; /* Authentication start offset */
u16 crypt_len; /* Cryption data length */
u16 crypt_offs; /* Cryption start offset */
#endif
u32 aadAddr; /* Additional Auth Data Addr for CCM mode */ u32 aadAddr; /* Additional Auth Data Addr for CCM mode */
u32 crypto_ctx; /* NPE Crypto Param structure address */ u32 crypto_ctx; /* NPE Crypto Param structure address */
...@@ -652,6 +670,9 @@ static int setup_auth(struct crypto_tfm *tfm, int encrypt, unsigned authsize, ...@@ -652,6 +670,9 @@ static int setup_auth(struct crypto_tfm *tfm, int encrypt, unsigned authsize,
/* write cfg word to cryptinfo */ /* write cfg word to cryptinfo */
cfgword = algo->cfgword | ( authsize << 6); /* (authsize/4) << 8 */ cfgword = algo->cfgword | ( authsize << 6); /* (authsize/4) << 8 */
#ifndef __ARMEB__
cfgword ^= 0xAA000000; /* change the "byte swap" flags */
#endif
*(u32*)cinfo = cpu_to_be32(cfgword); *(u32*)cinfo = cpu_to_be32(cfgword);
cinfo += sizeof(cfgword); cinfo += sizeof(cfgword);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment