From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: Szymon Janc <szymon@janc.net.pl>,
The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] CRCR64
Date: Sat, 25 Jun 2011 00:43:58 +0200 [thread overview]
Message-ID: <4E05132E.2070709@gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 58 bytes --]
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: crc64.diff --]
[-- Type: text/x-diff; name="crc64.diff", Size: 4160 bytes --]
=== modified file 'Makefile.util.def'
--- Makefile.util.def 2011-06-24 20:16:05 +0000
+++ Makefile.util.def 2011-06-24 21:29:27 +0000
@@ -88,6 +88,7 @@
common = grub-core/lib/LzmaEnc.c;
common = grub-core/lib/pbkdf2.c;
common = grub-core/lib/crc.c;
+ common = grub-core/lib/crc64.c;
common = grub-core/normal/datetime.c;
common = grub-core/normal/misc.c;
common = grub-core/partmap/acorn.c;
=== modified file 'grub-core/Makefile.core.def'
--- grub-core/Makefile.core.def 2011-06-24 20:16:05 +0000
+++ grub-core/Makefile.core.def 2011-06-24 21:21:08 +0000
@@ -1637,3 +1637,8 @@
common = commands/keylayouts.c;
enable = videomodules;
};
+
+module = {
+ name = crc64;
+ common = lib/crc64.c;
+};
=== added file 'grub-core/lib/crc64.c'
--- grub-core/lib/crc64.c 1970-01-01 00:00:00 +0000
+++ grub-core/lib/crc64.c 2011-06-24 22:21:37 +0000
@@ -0,0 +1,111 @@
+/* crc64.c - crc64 function */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2011 Free Software Foundation, Inc.
+ *
+ * GRUB 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/crypto.h>
+
+static grub_uint64_t crc64_table [256];
+
+static void
+init_crc64_table (void)
+{
+ auto grub_uint64_t reflect (grub_uint64_t ref, int len);
+ grub_uint64_t reflect (grub_uint64_t ref, int len)
+ {
+ grub_uint64_t result = 0;
+ int i;
+
+ for (i = 1; i <= len; i++)
+ {
+ if (ref & 1)
+ result |= 1ULL << (len - i);
+ ref >>= 1;
+ }
+
+ return result;
+ }
+
+ grub_uint64_t polynomial = 0x42f0e1eba9ea3693ULL;
+ int i, j;
+
+ for(i = 0; i < 256; i++)
+ {
+ crc64_table[i] = reflect(i, 8) << 56;
+ for (j = 0; j < 8; j++)
+ {
+ crc64_table[i] = (crc64_table[i] << 1) ^
+ (crc64_table[i] & (1ULL << 63) ? polynomial : 0);
+ }
+ crc64_table[i] = reflect(crc64_table[i], 64);
+ }
+}
+
+static void
+crc64_init (void *context)
+{
+ if (! crc64_table[1])
+ init_crc64_table ();
+ *(grub_uint64_t *) context = 0;
+}
+
+static void
+crc64_write (void *context, const void *buf, grub_size_t size)
+{
+ unsigned i;
+ const grub_uint8_t *data = buf;
+ grub_uint64_t crc = ~grub_le_to_cpu64 (*(grub_uint64_t *) context);
+
+ for (i = 0; i < size; i++)
+ {
+ crc = (crc >> 8) ^ crc64_table[(crc & 0xFF) ^ *data];
+ data++;
+ }
+
+ *(grub_uint64_t *) context = grub_cpu_to_le64 (~crc);
+}
+
+static grub_uint8_t *
+crc64_read (void *context)
+{
+ return context;
+}
+
+static void
+crc64_final (void *context __attribute__ ((unused)))
+{
+}
+
+gcry_md_spec_t _gcry_digest_spec_crc64 =
+ {
+ "CRC64", 0, 0, 0, 8,
+ crc64_init, crc64_write, crc64_final, crc64_read,
+ sizeof (grub_uint64_t),
+ .blocksize = 64
+ };
+
+GRUB_MOD_INIT(crc64)
+{
+ grub_md_register (&_gcry_digest_spec_crc64);
+}
+
+GRUB_MOD_FINI(crc64)
+{
+ grub_md_unregister (&_gcry_digest_spec_crc64);
+}
=== modified file 'util/import_gcry.py'
--- util/import_gcry.py 2011-04-12 10:39:17 +0000
+++ util/import_gcry.py 2011-06-24 21:23:01 +0000
@@ -73,6 +73,8 @@
cryptolist.write ("AES-192: gcry_rijndael\n");
cryptolist.write ("AES-256: gcry_rijndael\n");
+cryptolist.write ("CRC64: crc64\n");
+
for cipher_file in cipher_files:
infile = os.path.join (cipher_dir_in, cipher_file)
outfile = os.path.join (cipher_dir_out, cipher_file)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
reply other threads:[~2011-06-24 22:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E05132E.2070709@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
--cc=szymon@janc.net.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.