2N/A/* This file was automatically imported with 2N/A import_gcry.py. Please don't modify it */ 2N/A/* Rijndael (AES) for GnuPG 2N/A * Copyright (C) 2000, 2001, 2002, 2003, 2007, 2N/A * 2008 Free Software Foundation, Inc. 2N/A * This file is part of Libgcrypt. 2N/A * Libgcrypt is free software; you can redistribute it and/or modify 2N/A * it under the terms of the GNU Lesser General Public License as 2N/A * published by the Free Software Foundation; either version 2.1 of 2N/A * the License, or (at your option) any later version. 2N/A * Libgcrypt is distributed in the hope that it will be useful, 2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A * GNU Lesser General Public License for more details. 2N/A * You should have received a copy of the GNU Lesser General Public 2N/A ******************************************************************* 2N/A * The code here is based on the optimized implementation taken from 2N/A * which carries this notice: 2N/A *------------------------------------------ 2N/A * Optimised ANSI C code 2N/A * authors: v1.0: Antoon Bosselaers 2N/A * v2.0: Vincent Rijmen 2N/A * v2.3: Paulo Barreto 2N/A * This code is placed in the public domain. 2N/A *------------------------------------------ 2N/A * The SP800-38a document is available at: 2N/A/* USE_PADLOCK indicates whether to compile the padlock specific 2N/A#
endif /*ENABLE_PADLOCK_SUPPORT*/ 2N/A int ROUNDS;
/* Key-length-dependent number of rounds. */ 2N/A /* The key as passed to the padlock engine. */ 2N/A/* All the numbers. */ 2N/A/* Perform the key setup. */ 2N/A /* The on-the-fly self tests are only run in non-fips mode. In fips 2N/A mode explicit self-tests are required. Actually the on-the-fly 2N/A self-tests are not fully thread-safe and it might happen that a 2N/A failed self-test won't get noticed in another thread. 2N/A FIXME: We might want to have a central registry of succeeded 2N/A /* Nothing to do as we support only hardware key generation for 2N/A#
endif /*USE_PADLOCK*/ 2N/A for (j =
KC-
1; j >= 0; j--)
2N/A /* Copy values into round key array. */ 2N/A for (; (j <
KC) && (t <
4); j++, t++)
2N/A /* While not enough round key material calculated calculate 2N/A for (j =
1; j <
KC/
2; j++)
2N/A /* Copy values into round key array. */ 2N/A for (; (j <
KC) && (t <
4); j++, t++)
2N/A/* Make a decryption key from an encryption key. */ 2N/A/* Encrypt one block. A and B need to be aligned on a 4 byte 2N/A boundary. A and B may be the same. */ 2N/A unsigned char *b,
const unsigned char *a)
2N/A /* Last round is special. */ 2N/A unsigned char *
bx,
const unsigned char *
ax)
2N/A /* BX and AX are not necessary correctly aligned. Thus we need to 2N/A/* Encrypt or decrypt one block using the padlock engine. A and B may 2N/A unsigned char *
bx,
const unsigned char *
ax)
2N/A /* BX and AX are not necessary correctly aligned. Thus we need to 2N/A /* The control word fields are: 2N/A 127:12 11:10 9 8 7 6 5 4 3:0 2N/A RESERVED KSIZE CRYPT INTER KEYGN CIPHR ALIGN DGEST ROUND */ 2N/A (
"pushfl\n\t" /* Force key reload. */ 2N/A "xchg %3, %%ebx\n\t" /* Load key. */ 2N/A "movl $1, %%ecx\n\t" /* Init counter for just one block. */ 2N/A ".byte 0xf3, 0x0f, 0xa7, 0xc8\n\t" /* REP XSTORE ECB. */ 2N/A "xchg %3, %%ebx\n" /* Restore GOT register. */ 2N/A :
"%ecx",
"cc",
"memory" 2N/A#
endif /*USE_PADLOCK*/ 2N/A#
endif /*USE_PADLOCK*/ 2N/A/* Bulk encryption of complete blocks in CFB mode. Caller needs to 2N/A make sure that IV is aligned on an unsigned long boundary. This 2N/A function is only intended for the bulk encryption feature of 2N/A/* Bulk encryption of complete blocks in CBC mode. Caller needs to 2N/A make sure that IV is aligned on an unsigned long boundary. This 2N/A function is only intended for the bulk encryption feature of 2N/A/* Decrypt one block. A and B need to be aligned on a 4 byte boundary 2N/A and the decryption must have been prepared. A and B may be the 2N/A unsigned char *b,
const unsigned char *a)
2N/A /* Last round is special. */ 2N/A/* Decrypt one block. AX and BX may be the same. */ 2N/A /* BX and AX are not necessary correctly aligned. Thus we need to 2N/A#
endif /*USE_PADLOCK*/ 2N/A/* Bulk decryption of complete blocks in CFB mode. Caller needs to 2N/A make sure that IV is aligned on an unisgned lonhg boundary. This 2N/A function is only intended for the bulk encryption feature of 2N/A/* Bulk decryption of complete blocks in CBC mode. Caller needs to 2N/A make sure that IV is aligned on an unsigned long boundary. This 2N/A function is only intended for the bulk encryption feature of 2N/A/* Run the self-tests for AES 128. Returns NULL on success. */ 2N/A/* Run the self-tests for AES 192. Returns NULL on success. */ 2N/A/* Run the self-tests for AES 256. Returns NULL on success. */ 2N/A/* Run all the self-tests and return NULL on success. This function 2N/A is used for the on-the-fly self-tests. */ 2N/A/* SP800-38a.pdf for AES-128. */ 2N/A/* Complete selftest for AES-128 with all modes and driver code. */ 2N/A/* Complete selftest for AES-192. */ 2N/A/* Complete selftest for AES-256. */ 2N/A/* Run a full self-test for ALGO and return 0 on success. */