diff options
author | Haren Myneni <haren@linux.vnet.ibm.com> | 2015-10-08 23:45:51 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-14 17:23:17 +0300 |
commit | ea0b3984c1cc8b28de27a3bec285102b4e366a4c (patch) | |
tree | b0134466a5b790d4091dc16065257a00ea24bf00 /lib/842/842_compress.c | |
parent | f5128432b08c3e263e1a7ce709d686b1ded51131 (diff) | |
download | linux-ea0b3984c1cc8b28de27a3bec285102b4e366a4c.tar.xz |
crypto: 842 - Add CRC and validation support
This patch adds CRC generation and validation support for nx-842.
Add CRC flag so that nx842 coprocessor includes CRC during compression
and validates during decompression.
Also changes in 842 SW compression to append CRC value at the end
of template and checks during decompression.
Signed-off-by: Haren Myneni <haren@us.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/842/842_compress.c')
-rw-r--r-- | lib/842/842_compress.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/842/842_compress.c b/lib/842/842_compress.c index 7ce68948e68c..4051339bdfbd 100644 --- a/lib/842/842_compress.c +++ b/lib/842/842_compress.c @@ -490,6 +490,7 @@ int sw842_compress(const u8 *in, unsigned int ilen, int ret; u64 last, next, pad, total; u8 repeat_count = 0; + u32 crc; BUILD_BUG_ON(sizeof(*p) > SW842_MEM_COMPRESS); @@ -580,6 +581,18 @@ skip_comp: if (ret) return ret; + /* + * crc(0:31) is appended to target data starting with the next + * bit after End of stream template. + * nx842 calculates CRC for data in big-endian format. So doing + * same here so that sw842 decompression can be used for both + * compressed data. + */ + crc = crc32_be(0, in, ilen); + ret = add_bits(p, crc, CRC_BITS); + if (ret) + return ret; + if (p->bit) { p->out++; p->olen--; |