1. Trang chủ
  2. » Công Nghệ Thông Tin

Cracker Handbook 1.0 part 398 pot

6 63 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 17,85 KB

Nội dung

+module_exit(fini); + +MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>"); +MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations"); +MODULE_LICENSE("GPL and additional rights"); diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/internal.h linux/crypto/internal.h linux-2.6.1.orig/crypto/internal.hFri Jan 9 00:59:04 2004 +++ linux/crypto/internal.hMon Jan 12 10:33:59 2004 @@ -79,14 +79,17 @@ int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags); +int crypto_init_chksum_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_digest_ops(struct crypto_tfm *tfm); int crypto_init_cipher_ops(struct crypto_tfm *tfm); int crypto_init_compress_ops(struct crypto_tfm *tfm); +int crypto_init_chksum_ops(struct crypto_tfm *tfm); void crypto_exit_digest_ops(struct crypto_tfm *tfm); void crypto_exit_cipher_ops(struct crypto_tfm *tfm); void crypto_exit_compress_ops(struct crypto_tfm *tfm); +void crypto_exit_chksum_ops(struct crypto_tfm *tfm); #endif/* _CRYPTO_INTERNAL_H */ diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/tcrypt.c linux/crypto/tcrypt.c linux-2.6.1.orig/crypto/tcrypt.cFri Jan 9 00:59:56 2004 +++ linux/crypto/tcrypt.cWed Jan 14 11:43:12 2004 @@ -61,7 +61,7 @@ static char *check[] = { "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", -"deflate", NULL +"deflate", "crc32c", NULL }; static void @@ -492,6 +492,102 @@ } static void +test_crc32c(void) +{ +#define NUMVEC 6 +#define VECSIZE 40 + +int i, j, pass; +u32 crc; +u8 b, test_vec[NUMVEC][VECSIZE]; +static u32 vec_results[NUMVEC] = { +0x0e2c157f, 0xe980ebf6, 0xde74bded, +0xd579c862, 0xba979ad0, 0x2b29d913 +}; +static u32 tot_vec_results = 0x24c5d375; + +struct scatterlist sg[NUMVEC]; +struct crypto_tfm *tfm; +char *fmtdata = "testing crc32c initted to %08x: %s\n"; +#define SEEDTESTVAL 0xedcba987 + +printk("\ntesting crc32c\n"); + +tfm = crypto_alloc_tfm("crc32c", 0); +if (tfm == NULL) { +printk("failed to load transform for crc32c\n"); +return; +} + +crypto_chksum_init(tfm); +crypto_chksum_final(tfm, &crc); +printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR"); + +/* + * stuff test_vec with known values, simple incrementing + * byte values. + */ +b = 0; +for (i = 0; i < NUMVEC; i++) { +for (j = 0; j < VECSIZE; j++) +test_vec[i][j] = ++b; +sg[i].page = virt_to_page(test_vec[i]); +sg[i].offset = offset_in_page(test_vec[i]); +sg[i].length = VECSIZE; +} + +crypto_chksum_setseed(tfm, SEEDTESTVAL); +crypto_chksum_final(tfm, &crc); +printk("testing crc32c setseed returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? + "pass" : "ERROR"); + +printk("testing crc32c using update/final:\n"); + +pass = 1; /* assume all is well */ + +for (i = 0; i < NUMVEC; i++) { +crypto_chksum_setseed(tfm, ~(u32)0); +crypto_chksum_update(tfm, &sg[i], 1); +crypto_chksum_final(tfm, &crc); +if (crc == vec_results[i]) { +printk(" %08x:OK", crc); +} else { +printk(" %08x:BAD, wanted %08x\n", crc, vec_results[i]); +pass = 0; +} +} + +printk("\ntesting crc32c using incremental accumulator:\n"); +crc = 0; +for (i = 0; i < NUMVEC; i++) { +crypto_chksum_setseed(tfm, (crc ^ ~(u32)0)); +crypto_chksum_update(tfm, &sg[i], 1); +crypto_chksum_final(tfm, &crc); +} +if (crc == tot_vec_results) { +printk(" %08x:OK", crc); +} else { +printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); +pass = 0; +} + +printk("\ntesting crc32c using digest:\n"); +crypto_chksum_setseed(tfm, ~(u32)0); +crypto_chksum_digest(tfm, sg, NUMVEC, &crc); +if (crc == tot_vec_results) { +printk(" %08x:OK", crc); +} else { +printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); +pass = 0; +} + +printk("\n%s\n", pass ? "pass" : "ERROR"); + +crypto_free_tfm(tfm); +printk("crc32c test complete\n"); +} + +static void test_available(void) { char **name = check; @@ -558,7 +654,8 @@ test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); -test_deflate(); +test_deflate(); +test_crc32c(); #ifdef CONFIG_CRYPTO_HMAC test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); @@ -638,6 +735,10 @@ test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS); break; +case 16: +test_crc32c(); +break; + #ifdef CONFIG_CRYPTO_HMAC case 100: test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux- 2.6.1.orig/include/linux/crypto.h linux/include/linux/crypto.h linux-2.6.1.orig/include/linux/crypto.hFri Jan 9 00:59:19 2004 +++ linux/include/linux/crypto.hWed Jan 14 11:26:39 2004 @@ -30,7 +30,7 @@ #define CRYPTO_ALG_TYPE_CIPHER0x00000001 #define CRYPTO_ALG_TYPE_DIGEST0x00000002 #define CRYPTO_ALG_TYPE_COMPRESS0x00000004 - +#define CRYPTO_ALG_TYPE_CHKSUM0x00000008 /* * Transform masks and values (for crt_flags). */ @@ -87,9 +87,18 @@ u8 *dst, unsigned int *dlen); }; +struct chksum_alg { +unsigned int cha_digestsize; +void (*cha_init)(void *ctx); +void (*cha_setseed)(void *ctx, const u32 seed); +void (*cha_update)(void *ctx, const u8 *data, unsigned int len); +void (*cha_final)(void *ctx, u32 *out); +}; + #define cra_ciphercra_u.cipher . - 30, 7 + 30, 7 @@ #define CRYPTO_ALG_TYPE_CIPHER0x 000 000 01 #define CRYPTO_ALG_TYPE_DIGEST0x 000 000 02 #define CRYPTO_ALG_TYPE_COMPRESS0x 000 000 04 - +#define CRYPTO_ALG_TYPE_CHKSUM0x 000 000 08 . drivers linux-2.6 .1. orig/crypto/tcrypt.c linux/crypto/tcrypt.c linux-2.6 .1. orig/crypto/tcrypt.cFri Jan 9 00 :59:56 200 4 +++ linux/crypto/tcrypt.cWed Jan 14 11 :43 :12 200 4 @@ - 61, 7 + 61, 7 @@ static. linux-2.6 .1. orig/crypto/internal.h linux/crypto/internal.h linux-2.6 .1. orig/crypto/internal.hFri Jan 9 00 :59 :04 200 4 +++ linux/crypto/internal.hMon Jan 12 10 :33:59 200 4 @@ -79 ,14 +79 ,17 @@

Ngày đăng: 03/07/2014, 18:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN