~ubuntu-branches/ubuntu/trusty/grub2/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
521
521
 * preprocessed through q0 and q1 respectively; for longer keys they are the
522
522
 * output of previous stages.  j is the index of the first key byte to use.
523
523
 * CALC_K computes a pair of subkeys for 128-bit Twofish, by calling CALC_K_2
524
 
 * twice, doing the Psuedo-Hadamard Transform, and doing the necessary
 
524
 * twice, doing the Pseudo-Hadamard Transform, and doing the necessary
525
525
 * rotations.  Its parameters are: a, the array to write the results into,
526
526
 * j, the index of the first output entry, k and l, the preprocessed indices
527
527
 * for index 2i, and m and n, the preprocessed indices for index 2i+1.
574
574
   * 128-bit keys use only sa through sh; 256-bit use all of them. */
575
575
  byte sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0;
576
576
  byte si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0;
577
 
  
 
577
 
578
578
  /* Temporary for CALC_S. */
579
579
  byte tmp;
580
 
  
 
580
 
581
581
  /* Flags for self-test. */
582
582
  static int initialized = 0;
583
583
  static const char *selftest_failed=0;
667
667
      CALC_K256 (k, 28, 0x84, 0x8A, 0x54, 0x00);
668
668
      CALC_K256 (k, 30, 0xDF, 0xBC, 0x23, 0x9D);
669
669
    }
670
 
  else 
 
670
  else
671
671
    {
672
672
      /* Compute the S-boxes. */
673
673
      for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 )
920
920
  timer = clock ();
921
921
 
922
922
  /* Encryption test. */
923
 
  for (i = 0; i < 125; i++) 
 
923
  for (i = 0; i < 125; i++)
924
924
    {
925
925
      twofish_setkey (&ctx, buffer[0], sizeof (buffer[0]));
926
926
      for (j = 0; j < 1000; j++)
938
938
    "encryption failure!\n" : "encryption OK!\n";
939
939
 
940
940
  /* Decryption test. */
941
 
  for (i = 0; i < 125; i++) 
 
941
  for (i = 0; i < 125; i++)
942
942
    {
943
943
      twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2);
944
944
      for (j = 0; j < 1000; j++) {