[gs-cvs] rev 8872 - trunk/gs/src
giles at ghostscript.com
giles at ghostscript.com
Wed Jul 23 17:42:06 PDT 2008
Author: giles
Date: 2008-07-23 17:42:06 -0700 (Wed, 23 Jul 2008)
New Revision: 8872
Modified:
trunk/gs/src/aes.c
trunk/gs/src/aes.h
Log:
Change the XYSSL AES implementation to better match our conventions.
Modified: trunk/gs/src/aes.c
===================================================================
--- trunk/gs/src/aes.c 2008-07-24 00:42:04 UTC (rev 8871)
+++ trunk/gs/src/aes.c 2008-07-24 00:42:06 UTC (rev 8872)
@@ -36,10 +36,12 @@
* http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
*/
+/* $Id:$ */
+/* AES block cipher implementation from XYSSL */
+
+#include "string_.h" /* memcmp() */
#include "aes.h"
-#include <string.h>
-
/*
* 32-bit integer manipulation macros (little endian)
*/
@@ -334,10 +336,10 @@
* Forward S-box & tables
*/
static unsigned char FSb[256];
-static unsigned long FT0[256];
-static unsigned long FT1[256];
-static unsigned long FT2[256];
-static unsigned long FT3[256];
+static unsigned long FT0[256];
+static unsigned long FT1[256];
+static unsigned long FT2[256];
+static unsigned long FT3[256];
/*
* Reverse S-box & tables
@@ -443,7 +445,7 @@
/*
* AES key schedule (encryption)
*/
-void aes_setkey_enc( aes_context *ctx, unsigned char *key, int keysize )
+void aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize )
{
int i;
unsigned long *RK;
@@ -546,7 +548,7 @@
/*
* AES key schedule (decryption)
*/
-void aes_setkey_dec( aes_context *ctx, unsigned char *key, int keysize )
+void aes_setkey_dec( aes_context *ctx, const unsigned char *key, int keysize )
{
int i, j;
aes_context cty;
@@ -645,7 +647,7 @@
*/
void aes_crypt_ecb( aes_context *ctx,
int mode,
- unsigned char input[16],
+ const unsigned char input[16],
unsigned char output[16] )
{
int i;
@@ -740,7 +742,7 @@
int mode,
int length,
unsigned char iv[16],
- unsigned char *input,
+ const unsigned char *input,
unsigned char *output )
{
int i;
@@ -796,7 +798,7 @@
int length,
int *iv_off,
unsigned char iv[16],
- unsigned char *input,
+ const unsigned char *input,
unsigned char *output )
{
int c, n = *iv_off;
Modified: trunk/gs/src/aes.h
===================================================================
--- trunk/gs/src/aes.h 2008-07-24 00:42:04 UTC (rev 8871)
+++ trunk/gs/src/aes.h 2008-07-24 00:42:06 UTC (rev 8872)
@@ -1,5 +1,33 @@
-/**
- * \file aes.h
+/*
+ * FIPS-197 compliant AES implementation
+ *
+ * Copyright (C) 2006-2007 Christophe Devine
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code _must_ retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form may or may not reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of XySSL nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef XYSSL_AES_H
#define XYSSL_AES_H
@@ -29,7 +57,8 @@
* \param key encryption key
* \param keysize must be 128, 192 or 256
*/
-void aes_setkey_enc( aes_context *ctx, unsigned char *key, int keysize );
+void aes_setkey_enc( aes_context *ctx, const unsigned char *key,
+ int keysize );
/**
* \brief AES key schedule (decryption)
@@ -38,7 +67,8 @@
* \param key decryption key
* \param keysize must be 128, 192 or 256
*/
-void aes_setkey_dec( aes_context *ctx, unsigned char *key, int keysize );
+void aes_setkey_dec( aes_context *ctx, const unsigned char *key,
+ int keysize );
/**
* \brief AES-ECB block encryption/decryption
@@ -50,7 +80,7 @@
*/
void aes_crypt_ecb( aes_context *ctx,
int mode,
- unsigned char input[16],
+ const unsigned char input[16],
unsigned char output[16] );
/**
@@ -67,7 +97,7 @@
int mode,
int length,
unsigned char iv[16],
- unsigned char *input,
+ const unsigned char *input,
unsigned char *output );
/**
@@ -86,7 +116,7 @@
int length,
int *iv_off,
unsigned char iv[16],
- unsigned char *input,
+ const unsigned char *input,
unsigned char *output );
/**
More information about the gs-cvs
mailing list