~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file was automatically imported with 
 
2
   import_gcry.py. Please don't modify it */
 
3
/* camellia-glue.c - Glue for the Camellia cipher
 
4
 * Copyright (C) 2007 Free Software Foundation, Inc.
 
5
 *
 
6
 * This file is part of Libgcrypt.
 
7
 *
 
8
 * Libgcrypt is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU Lesser General Public License as
 
10
 * published by the Free Software Foundation; either version 2.1 of
 
11
 * the License, or (at your option) any later version.
 
12
 *
 
13
 * Libgcrypt is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
21
 * 02110-1301, USA.
 
22
 */
 
23
 
 
24
/* I put all the libgcrypt-specific stuff in this file to keep the
 
25
   camellia.c/camellia.h files exactly as provided by NTT.  If they
 
26
   update their code, this should make it easier to bring the changes
 
27
   in. - dshaw
 
28
 
 
29
   There is one small change which needs to be done: Include the
 
30
   following code at the top of camellia.h: */
 
31
#if 0
 
32
 
 
33
/* To use Camellia with libraries it is often useful to keep the name
 
34
 * space of the library clean.  The following macro is thus useful:
 
35
 *
 
36
 *     #define CAMELLIA_EXT_SYM_PREFIX foo_
 
37
 *  
 
38
 * This prefixes all external symbols with "foo_".
 
39
 */
 
40
#ifdef HAVE_CONFIG_H
 
41
#endif
 
42
#ifdef CAMELLIA_EXT_SYM_PREFIX
 
43
#define CAMELLIA_PREFIX1(x,y) x ## y
 
44
#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
 
45
#define CAMELLIA_PREFIX(x)    CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
 
46
#define Camellia_Ekeygen      CAMELLIA_PREFIX(Camellia_Ekeygen)
 
47
#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
 
48
#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
 
49
#define camellia_decrypt128   CAMELLIA_PREFIX(camellia_decrypt128)
 
50
#define camellia_decrypt256   CAMELLIA_PREFIX(camellia_decrypt256)
 
51
#define camellia_encrypt128   CAMELLIA_PREFIX(camellia_encrypt128)
 
52
#define camellia_encrypt256   CAMELLIA_PREFIX(camellia_encrypt256)
 
53
#define camellia_setup128     CAMELLIA_PREFIX(camellia_setup128)
 
54
#define camellia_setup192     CAMELLIA_PREFIX(camellia_setup192) 
 
55
#define camellia_setup256     CAMELLIA_PREFIX(camellia_setup256)
 
56
#endif /*CAMELLIA_EXT_SYM_PREFIX*/
 
57
 
 
58
#endif /* Code sample. */
 
59
 
 
60
 
 
61
#include "types.h"
 
62
#include "g10lib.h"
 
63
#include "cipher.h"
 
64
#include "camellia.h"
 
65
 
 
66
typedef struct
 
67
{
 
68
  int keybitlength;
 
69
  KEY_TABLE_TYPE keytable;
 
70
} CAMELLIA_context;
 
71
 
 
72
 
 
73
static gcry_err_code_t
 
74
camellia_setkey(void *c, const byte *key, unsigned keylen)
 
75
{
 
76
  CAMELLIA_context *ctx=c;
 
77
  static int initialized=0;
 
78
  static const char *selftest_failed=NULL;
 
79
 
 
80
  if(keylen!=16 && keylen!=24 && keylen!=32)
 
81
    return GPG_ERR_INV_KEYLEN;
 
82
 
 
83
  if(!initialized)
 
84
    {
 
85
      initialized=1;
 
86
      selftest_failed=selftest();
 
87
      if(selftest_failed)
 
88
        log_error("%s\n",selftest_failed);
 
89
    }
 
90
 
 
91
  if(selftest_failed)
 
92
    return GPG_ERR_SELFTEST_FAILED;
 
93
 
 
94
  ctx->keybitlength=keylen*8;
 
95
  Camellia_Ekeygen(ctx->keybitlength,key,ctx->keytable);
 
96
  _gcry_burn_stack
 
97
    ((19+34+34)*sizeof(u32)+2*sizeof(void*) /* camellia_setup256 */
 
98
     +(4+32)*sizeof(u32)+2*sizeof(void*)    /* camellia_setup192 */
 
99
     +0+sizeof(int)+2*sizeof(void*)         /* Camellia_Ekeygen */
 
100
     +3*2*sizeof(void*)                     /* Function calls.  */
 
101
     );  
 
102
 
 
103
  return 0;
 
104
}
 
105
 
 
106
static void
 
107
camellia_encrypt(void *c, byte *outbuf, const byte *inbuf)
 
108
{
 
109
  CAMELLIA_context *ctx=c;
 
110
 
 
111
  Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
 
112
  _gcry_burn_stack
 
113
    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
 
114
     +4*sizeof(u32)
 
115
     +2*sizeof(u32*)+4*sizeof(u32)
 
116
     +2*2*sizeof(void*) /* Function calls.  */
 
117
    );
 
118
}
 
119
 
 
120
static void
 
121
camellia_decrypt(void *c, byte *outbuf, const byte *inbuf)
 
122
{
 
123
  CAMELLIA_context *ctx=c;
 
124
 
 
125
  Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
 
126
  _gcry_burn_stack
 
127
    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
 
128
     +4*sizeof(u32)
 
129
     +2*sizeof(u32*)+4*sizeof(u32)
 
130
     +2*2*sizeof(void*) /* Function calls.  */
 
131
    );
 
132
}
 
133
 
 
134
 
 
135
/* These oids are from
 
136
   <http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications_oid.html>,
 
137
   retrieved May 1, 2007. */
 
138
 
 
139
static gcry_cipher_oid_spec_t camellia128_oids[] =
 
140
  {
 
141
    {"1.2.392.200011.61.1.1.1.2", GCRY_CIPHER_MODE_CBC},
 
142
    {"0.3.4401.5.3.1.9.1", GCRY_CIPHER_MODE_ECB},
 
143
    {"0.3.4401.5.3.1.9.3", GCRY_CIPHER_MODE_OFB},
 
144
    {"0.3.4401.5.3.1.9.4", GCRY_CIPHER_MODE_CFB},
 
145
    { NULL }
 
146
  };
 
147
 
 
148
static gcry_cipher_oid_spec_t camellia192_oids[] =
 
149
  {
 
150
    {"1.2.392.200011.61.1.1.1.3", GCRY_CIPHER_MODE_CBC},
 
151
    {"0.3.4401.5.3.1.9.21", GCRY_CIPHER_MODE_ECB},
 
152
    {"0.3.4401.5.3.1.9.23", GCRY_CIPHER_MODE_OFB},
 
153
    {"0.3.4401.5.3.1.9.24", GCRY_CIPHER_MODE_CFB},
 
154
    { NULL }
 
155
  };
 
156
 
 
157
static gcry_cipher_oid_spec_t camellia256_oids[] =
 
158
  {
 
159
    {"1.2.392.200011.61.1.1.1.4", GCRY_CIPHER_MODE_CBC},
 
160
    {"0.3.4401.5.3.1.9.41", GCRY_CIPHER_MODE_ECB},
 
161
    {"0.3.4401.5.3.1.9.43", GCRY_CIPHER_MODE_OFB},
 
162
    {"0.3.4401.5.3.1.9.44", GCRY_CIPHER_MODE_CFB},
 
163
    { NULL }
 
164
  };
 
165
 
 
166
gcry_cipher_spec_t _gcry_cipher_spec_camellia128 =
 
167
  {
 
168
    "CAMELLIA128",NULL,camellia128_oids,CAMELLIA_BLOCK_SIZE,128,
 
169
    sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
 
170
  };
 
171
 
 
172
gcry_cipher_spec_t _gcry_cipher_spec_camellia192 =
 
173
  {
 
174
    "CAMELLIA192",NULL,camellia192_oids,CAMELLIA_BLOCK_SIZE,192,
 
175
    sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
 
176
  };
 
177
 
 
178
gcry_cipher_spec_t _gcry_cipher_spec_camellia256 =
 
179
  {
 
180
    "CAMELLIA256",NULL,camellia256_oids,CAMELLIA_BLOCK_SIZE,256,
 
181
    sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
 
182
  };
 
183
 
 
184
 
 
185
GRUB_MOD_INIT(gcry_camellia)
 
186
{
 
187
  grub_cipher_register (&_gcry_cipher_spec_camellia128);
 
188
  grub_cipher_register (&_gcry_cipher_spec_camellia192);
 
189
  grub_cipher_register (&_gcry_cipher_spec_camellia256);
 
190
}
 
191
 
 
192
GRUB_MOD_FINI(gcry_camellia)
 
193
{
 
194
  grub_cipher_unregister (&_gcry_cipher_spec_camellia128);
 
195
  grub_cipher_unregister (&_gcry_cipher_spec_camellia192);
 
196
  grub_cipher_unregister (&_gcry_cipher_spec_camellia256);
 
197
}