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

Cracker Handbook 1.0 part 396 potx

6 60 1
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Chksum/Crc Operations
Tác giả Clay Haapala
Trường học University of Minnesota
Chuyên ngành Cryptography
Thể loại bài luận
Năm xuất bản 2004
Thành phố Minneapolis
Định dạng
Số trang 6
Dung lượng 18,66 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The structure of it is based wholly on the existing digest md5 routines, the main difference being that chksums are often used in an "accumulator" fashion, effectively requiring one to s

Trang 1

crypto routines The structure of it is based wholly on the existing

digest (md5) routines, the main difference being that chksums are

often used in an "accumulator" fashion, effectively requiring one to

set the seed, and the digest algorithms don't do that

CRC32C is a 32-bit CRC variant used by the iSCSI protocol and in other

drivers iSCSI uses scatterlists, so it was strongly suggested by the

SCSI maintainers during reviews of Version 4 of the linux-iscsi driver

that the code be added to the crypto routines, which operate on

scatterlists

Test routines have been added to tcrypt.c

The linux-iscsi project can be found on SourceForge:

http://sourceforge.net/projects/linux-iscsi/

diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/Kconfig linux/crypto/Kconfig

- linux-2.6.1.orig/crypto/KconfigFri Jan 9 01:00:03 2004

+++ linux/crypto/KconfigMon Jan 12 10:33:59 2004

@@ -22,6 +22,14 @@

help

These are 'Null' algorithms, used by IPsec, which do nothing

+config CRYPTO_CRC32C

+tristate "CRC32c CRC algorithm"

+depends on CRYPTO

+help

+ Castagnoli, et al Cyclic Redundancy-Check Algorithm Used

+ by iSCSI for header and data digests and by others

+ See Castagnoli93

+

config CRYPTO_MD4

tristate "MD4 digest algorithm"

depends on CRYPTO

diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/Makefile linux/crypto/Makefile

Trang 2

- linux-2.6.1.orig/crypto/MakefileFri Jan 9 01:00:04 2004

+++ linux/crypto/MakefileMon Jan 12 10:33:59 2004

@@ -4,11 +4,12 @@

proc-crypto-$(CONFIG_PROC_FS) = proc.o

-obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o \

+obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o chksum.o \ $(proc-crypto-y)

obj-$(CONFIG_CRYPTO_HMAC) += hmac.o

obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o

+obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o

obj-$(CONFIG_CRYPTO_MD4) += md4.o

obj-$(CONFIG_CRYPTO_MD5) += md5.o

obj-$(CONFIG_CRYPTO_SHA1) += sha1.o

diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/api.c linux/crypto/api.c

- linux-2.6.1.orig/crypto/api.cFri Jan 9 01:00:04 2004

+++ linux/crypto/api.cMon Jan 12 10:33:59 2004

@@ -68,6 +68,9 @@

case CRYPTO_ALG_TYPE_COMPRESS:

return crypto_init_compress_flags(tfm, flags);

+case CRYPTO_ALG_TYPE_CHKSUM:

+return crypto_init_chksum_flags(tfm, flags);

+

default:

break;

}

@@ -88,6 +91,9 @@

case CRYPTO_ALG_TYPE_COMPRESS:

return crypto_init_compress_ops(tfm);

+case CRYPTO_ALG_TYPE_CHKSUM:

+return crypto_init_chksum_ops(tfm);

+

default:

Trang 3

break;

}

@@ -111,6 +117,10 @@

crypto_exit_compress_ops(tfm);

break;

+case CRYPTO_ALG_TYPE_CHKSUM:

+crypto_exit_chksum_ops(tfm);

+break;

+

default:

BUG();

diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/chksum.c linux/crypto/chksum.c

- linux-2.6.1.orig/crypto/chksum.cWed Dec 31 18:00:00 1969

+++ linux/crypto/chksum.cMon Jan 12 10:33:59 2004

@@ -0,0 +1,89 @@

+/*

+ * Cryptographic API

+ *

+ * Chksum/CRC operations

+ *

+ * Copyright (c) 2003 Clay Haapala (clay@haapi.mn.org)

+ * cribbed from digest code by James Morris <jmorris@intercode.com.au> + *

+ * This program is free software; you can redistribute it and/or modify it

+ * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version

+ *

+ */

+#include <linux/crypto.h>

+#include <linux/mm.h>

+#include <linux/errno.h>

+#include <linux/highmem.h>

+#include <asm/scatterlist.h>

+#include "internal.h"

Trang 4

+

+static void init(struct crypto_tfm *tfm)

+{

+tfm-> crt_alg->cra_chksum.cha_init(crypto_tfm_ctx(tfm));

+}

+

+static void setseed(struct crypto_tfm *tfm, const u32 seed)

+{

+tfm-> crt_alg->cra_chksum.cha_setseed(crypto_tfm_ctx(tfm), seed); +}

+

+static void update(struct crypto_tfm *tfm,

+ struct scatterlist *sg, unsigned int nsg)

+{

+unsigned int i;

+

+for (i = 0; i < nsg; i++) {

+char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;

+tfm-> crt_alg->cra_chksum.cha_update(crypto_tfm_ctx(tfm),

+ p, sg[i].length);

+crypto_kunmap(p, 0);

+crypto_yield(tfm);

+}

+}

+

+static void final(struct crypto_tfm *tfm, u32 *out)

+{

+tfm-> crt_alg->cra_chksum.cha_final(crypto_tfm_ctx(tfm), out); +}

+

+static void digest(struct crypto_tfm *tfm,

+ struct scatterlist *sg, unsigned int nsg, u32 *out)

+{

+unsigned int i;

+

+tfm->crt_chksum.cht_init(tfm);

+

+for (i = 0; i < nsg; i++) {

+char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;

Trang 5

+tfm-> crt_alg->cra_chksum.cha_update(crypto_tfm_ctx(tfm),

+ p, sg[i].length);

+crypto_kunmap(p, 0);

+crypto_yield(tfm);

+}

+crypto_chksum_final(tfm, out);

+}

+

+int crypto_init_chksum_flags(struct crypto_tfm *tfm, u32 flags)

+{

+return flags ? -EINVAL : 0;

+}

+

+int crypto_init_chksum_ops(struct crypto_tfm *tfm)

+{

+struct chksum_tfm *ops = &tfm->crt_chksum;

+

+ops->cht_init= init;

+ops->cht_setseed = setseed;

+ops->cht_update= update;

+ops->cht_final= final;

+ops->cht_digest= digest;

+

+return 0;

+}

+

+void crypto_exit_chksum_ops(struct crypto_tfm *tfm)

+{

+return;

+}

diff -urN exclude '*.ko' exclude '*.mod.*' exclude '*~' exclude '*.o*' exclude '.*' exclude '*.cmd' exclude drivers linux-2.6.1.orig/crypto/crc32c.c linux/crypto/crc32c.c

- linux-2.6.1.orig/crypto/crc32c.cWed Dec 31 18:00:00 1969

+++ linux/crypto/crc32c.cWed Jan 14 11:40:25 2004

@@ -0,0 +1,203 @@

+/*

+ * Cryptographic API

+ *

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

TỪ KHÓA LIÊN QUAN