2003-08-27 18:23:25 +04:00
|
|
|
/* $NetBSD: rijndael.c,v 1.6 2003/08/27 14:23:27 itojun Exp $ */
|
2003-07-26 01:12:39 +04:00
|
|
|
|
2003-08-26 18:24:05 +04:00
|
|
|
/**
|
|
|
|
* rijndael-alg-fst.c
|
|
|
|
*
|
2003-07-26 01:12:39 +04:00
|
|
|
* @version 3.0 (December 2000)
|
|
|
|
*
|
|
|
|
* Optimised ANSI C code for the Rijndael cipher (now AES)
|
|
|
|
*
|
|
|
|
* @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
|
|
|
|
* @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
|
|
|
|
* @author Paulo Barreto <paulo.barreto@terra.com.br>
|
2003-08-26 18:24:05 +04:00
|
|
|
*
|
|
|
|
* This code is hereby placed in the public domain.
|
|
|
|
*
|
2003-07-26 01:12:39 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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.
|
|
|
|
*/
|
2003-08-26 18:24:05 +04:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2003-08-27 18:23:25 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: rijndael.c,v 1.6 2003/08/27 14:23:27 itojun Exp $");
|
2003-08-26 18:24:05 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <crypto/rijndael/rijndael.h>
|
|
|
|
|
|
|
|
void
|
2003-08-27 18:23:25 +04:00
|
|
|
rijndael_set_key(rijndael_ctx *ctx, const u_char *key, int bits)
|
2003-08-26 18:24:05 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
ctx->Nr = rijndaelKeySetupEnc(ctx->ek, key, bits);
|
2003-08-27 18:23:25 +04:00
|
|
|
rijndaelKeySetupDec(ctx->dk, key, bits);
|
2003-08-26 18:24:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-27 00:07:59 +04:00
|
|
|
rijndael_decrypt(const rijndael_ctx *ctx, const u_char *src, u_char *dst)
|
2003-08-26 18:24:05 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
rijndaelDecrypt(ctx->dk, ctx->Nr, src, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-27 00:07:59 +04:00
|
|
|
rijndael_encrypt(const rijndael_ctx *ctx, const u_char *src, u_char *dst)
|
2003-08-26 18:24:05 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
rijndaelEncrypt(ctx->ek, ctx->Nr, src, dst);
|
|
|
|
}
|