AES_Linux_LX_02.01.0100/ 0000755 0112057 0000024 00000000000 10337204063 014357 5 ustar pmccumbe dialout AES_Linux_LX_02.01.0100/README.eeprom 0000444 0112057 0000024 00000001713 10337203713 016526 0 ustar pmccumbe dialout This details the interface for the /dev/eeprom device exposed by the
geodeaes module.
/dev/eeprom (char 10,157) is a full featured read/write device. Up to
232 bytes of storage may be available to the user. To read or write from
the eeprom standard storage, use it like you would any other device file.
For example:
fd = open("/dev/eeprom", O_RDWR);
lseek(fd, 0, SEEK_SET);
write(fd, "Hello EEPROM!", 13);
lseek(fd, 128, SEEK_SET);
read(fd, buffer, sizeof(buffer));
printf("The eeprom says: %s\n", buffer);
close(fd);
In addition, the EEPROM has a hidden key storage and permissions
that can be set or read via ioctl() calls:
EIOSKEYOFF - Disable the usage of the hardware key till reboot
EIOSLOKUP - Lock the upper range of bytes (96-232) (this is permanent!)
EIOSLOKLW - Lock the lower range of bytes (0 - 96) and the key storage
this is permanent
EIOSKEY - Set the key in the hidden storage
EIOGPERMS - Query the permissions on the sections
AES_Linux_LX_02.01.0100/Makefile 0000444 0112057 0000024 00000001153 10337203713 016016 0 ustar pmccumbe dialout SUBDIRS=modules
subdirs-build=$(patsubst %,%-build,$(SUBDIRS))
subdirs-clean=$(patsubst %,%-clean,$(SUBDIRS))
subdirs-install=$(patsubst %,%-install,$(SUBDIRS))
subdirs-distclean=$(patsubst %,%-distclean,$(SUBDIRS))
all: $(subdirs-build)
clean: $(subdirs-clean)
install: $(subdirs-install)
distclean: $(subdirs-distclean)
@ rm -rf config.* autom4te.cache
$(subdirs-build):
@ make -C $(patsubst %-build,%,$@) all
$(subdirs-clean):
@ make -C $(patsubst %-clean,%,$@) clean
$(subdirs-install):
@ make -C $(patsubst %-install,%,$@) install
$(subdirs-distclean):
@ make -C $(patsubst %-distclean,%,$@) distclean
AES_Linux_LX_02.01.0100/README 0000644 0112057 0000024 00000012354 10337203713 015245 0 ustar pmccumbe dialout AMD Geode(TM) LX Processor Linux AES Encryption Module Driver - Release Notes
Version: 02.01.0100, General Release
Release Date: November 8, 2005
--------------------------------------------------------------------------------
PRODUCT INFORMATION
--------------------------------------------------------------------------------
The AMD Geode(TM) LX processor's AES module is a hardware based encryption device
based on the standard AES specification. The primary features are hardware
based encryption and keys that are hidden from the processor. The Linux
driver is a module developed to use and exercise the AES module.
Features
--------
The GEODEAES driver offers a standard device driver interface for user
applications to use the encryption facilities. It also offers an internal
hook to the kernel CryptoAPI interface for encrypted filesystems and IPSec.
This tarball includes the following documentation files:
-README.AES.txt (this file)
-README.api
-README.eeprom
For bugs, patches, and info requests, please subscribe to:
info-linux@geode.amd.com
To subscribe, send a blank message to: info-linux-subscribe@geode.amd.com
Dependencies
------------
- Linux Kernel 2.6.11
- (recommended) Linux 2.6.11 Kernel Patch for Geode LX/GX processors
Patches_Linux2.6.11_Common_02.02.0102.patch
Functional Changes
------------------
None
Defects Corrected
-----------------
PBZ#4081 AES test tools should be removed from driver release
PBZ#4553 AES does not build with Linux-2.6 +cryptoAPI
PBZ#5175 aestress can't allocate memory for 1 MB block size test.
Known Errata
------------
None
--------------------------------------------------------------------------------
VALIDATION ENVIRONMENT
--------------------------------------------------------------------------------
Validated on AMD Geode(TM) Norwich Development Board - Rev 2 Rework H and
Rev 3 Rework E with:
Processor: AMD Geode(TM) LX processor, silicon rev. C0 @ 433 MHz
Chipset: AMD Geode(TM) CS5535 companion device, silicon rev. A3
Memory: 512 MB DDR RAM @ 333 MHz
PCI Bus Speed: PCI @ 66 MHz
Operating System: Gentoo Linux 2004.3
Kernel: Kernel v2.6.11
Kernel Patch: LX 2.6.11 Kernel Patch v02.00.0100
Graphics Driver: LX Xorg Graphics driver v01.02.1001
Video4Linux2 Driver: LX 2.6.11 Video4Linux2 driver v03.01.0501
Audio Driver: CS5535 2.6.11 ALSA Audio driver v01.00.0500
ACCESS.bus Driver: LX 2.6.11 ACCESS.bus Driver v01.00.0401
AES Driver: LX 2.6.11 AES Driver v02.00.0601
--------------------------------------------------------------------------------
INSTALLATION INSTRUCTIONS
--------------------------------------------------------------------------------
1) Patch Linux 2.6.11 kernel with the Geode LX kernel patch, configure, and
build the kernel.
2) Configure the utilities and the drivers
./configure --with-kernel-path="path to your kernel source" \
--with-module-path="path to your *target* lib/modules"
3) Build the tree:
make
4) Install the tree:
make install
-----------------------------------------------------------------------------
RELEASE HISTORY (Previous Release)
-----------------------------------------------------------------------------
Version: 02.00.0500
Release Date: May 26, 2005
Dependencies
------------
- Linux Kernel 2.6.11
- (recommended) Linux 2.6.11 Kernel Patch for Geode LX/GX processors
Patches_Linux2.6.11_LX_1.00.0201.patch
Functional Changes
------------------
- First release
Defects Corrected
-----------------
- First release
Known Errata
------------
None
================================================================================
Copyright
---------
Copyright 2005 Advanced Micro Devices, Inc. All rights reserved.
The contents of this document are provided in connection with Advanced Micro
Devices, Inc. ("AMD") products. AMD makes no representations or warranties
with respect to the accuracy or completeness of the contents of this
publication and reserves the right to make changes to specifications and
product descriptions at any time without notice. No license, whether express,
implied, arising by estoppel or otherwise, to any intellectual property rights
is granted by this publication. Except as set forth in AMD's Standard Terms
and Conditions of Sale, AMD assumes no liability whatsoever, and disclaims any
express or implied warranty, relating to its products including, but not
limited to, the implied warranty of merchantability, fitness for a particular
purpose, or infringement of any intellectual property right. AMD's products
are not designed, intended, authorized or warranted for use as components in
systems intended for surgical implant into the body, or in other applications
intended to support or sustain life, or in any other application in which the
failure of AMD's product could create a situation where personal injury, death,
or severe property or environmental damage may occur. AMD reserves the right
to discontinue or make changes to its products at any time without notice.
Trademarks
----------
AMD, the AMD Arrow logo, and combinations thereof, and Geode are trademarks
of Advanced Micro Devices, Inc.
Other product names used in this publication are for identification purposes
only and may be trademarks of their respective companies.
================================================================================
AES_Linux_LX_02.01.0100/configure.ac 0000444 0112057 0000024 00000000670 10337203713 016647 0 ustar pmccumbe dialout AC_INIT(configure.ac)
AC_PROG_CC
AC_CHECK_TOOL(LD, ld, :)
AC_ARG_WITH(kernel-path, [ --with-kernel-path Specify the kernel path],
KERNEL_SRC=$withval, KERNEL_SRC="/usr/src/linux")
AC_ARG_WITH(module-path, [ --with-module-path Specify where to install the modules], INSTALL_MOD_PATH=$withval, INSTALL_MOD_PATH=/lib/modules)
CFLAGS="$CFLAGS -Wall"
AC_SUBST(KERNEL_SRC)
AC_SUBST(INSTALL_MOD_PATH)
AC_OUTPUT([
modules/Makefile
])
AES_Linux_LX_02.01.0100/modules/ 0000755 0112057 0000024 00000000000 10337203736 016035 5 ustar pmccumbe dialout AES_Linux_LX_02.01.0100/modules/geode_crypto.c 0000444 0112057 0000024 00000043771 10337203736 020676 0 ustar pmccumbe dialout /*
* Copyright (c) 2003-2005 Advanced Micro Devices, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* The full GNU General Public License is included in this distribution in the
* file called COPYING
* */
/*
* */
/*
* */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include
#endif
#ifdef CONFIG_CRYPTO
#include
#endif
#include "geode_crypto.h"
#include "build_num.h"
#define ERROR(str,args...) printk(KERN_ERR "GEODECRYPTO: " str, ##args)
#define WARNING(str,args...) printk(KERN_INFO "GEODECRYPTO: " str, ##args)
/* The PCI id of the device */
#define PCI_DEVICE_ID_GEODE_AES 0x2082
#define GEODE_AES_IRQ 10
#define MAX_BLK_ORDER 9
/* reserve max_blksz memory preallocated at module init */
static int rsvd_mem = 0;
/* The master driver (kmalloed to save bss space) */
struct geode_crypt_driver *geode_crypto_driver = 0;
static struct geode_crypt_ksession *
get_session(struct geode_crypt_driver *driver, int id) {
struct crypt_slist *slist = driver->session_list;
for( ; slist; slist = slist->next)
if (slist->id == id) return &slist->session;
return 0;
}
static void
aes_write_field(struct geode_crypt_driver *driver, u32 offset, void *value) {
u32 *v = (u32 *) value;
/* Don't forget, its little endian */
writel(v[0], driver->base + offset);
writel(v[1], driver->base + offset + 0x04);
writel(v[2], driver->base + offset + 0x08);
writel(v[3], driver->base + offset + 0x0C);
}
#define SET_KEY(driver, key) aes_write_field(driver, AES_WRITEKEY0_REG, key)
#define SET_IV(driver, iv) aes_write_field(driver, AES_WRITEIV0_REG, iv)
void
aes_crypt_block(struct geode_crypt_driver *driver,
struct geode_crypt_ksession *session,
int flags) {
u32 ctrl = AES_CTRL_START;
u32 intr = readl(driver->base + AES_INTERRUPT_REG);
/* If we are polling, then make sure the interrupts are disabled */
/* Otherwise, enable interrupt A for service */
if (session->flags & CRYPTO_SESSION_POLL)
writel(intr | AES_INTR_MASK, driver->base + AES_INTERRUPT_REG);
else
writel(intr & ~AES_INTR_A_MASK, driver->base + AES_INTERRUPT_REG);
writel(__pa(session->src), driver->base + AES_SOURCEA_REG);
writel(__pa(session->dest), driver->base + AES_DSTA_REG);
writel(session->blocksize, driver->base + AES_LENA_REG);
if (session->flags & CRYPTO_SESSION_CBC)
ctrl |= AES_CTRL_CBCA;
if (!(session->flags & CRYPTO_SESSION_HWKEY))
ctrl |= AES_CTRL_WRKEY;
/* Coherency is the default, the flags need to disable it */
if (!(session->flags & CRYPTO_SESSION_NOCOHERENCY))
ctrl |= AES_CTRL_SCA | AES_CTRL_DCA;
if (flags & CRYPTO_FLAG_ENCRYPT)
ctrl |= AES_CTRL_ENCRYPT;
/* Start the operation */
writel(ctrl, driver->base + AES_CONTROLA_REG);
/* If we are polling, then sit around and wait for the response */
if (session->flags & CRYPTO_SESSION_POLL) {
u32 status = readl(driver->base + AES_INTERRUPT_REG);
while(!(status & AES_INTR_A_PENDING)) {
udelay(10);
status = readl(driver->base + AES_INTERRUPT_REG);
}
writel(AES_INTR_A_PENDING | intr, driver->base + AES_INTERRUPT_REG);
}
}
static void
geode_aes_wait_for_op(struct geode_crypt_driver *driver,
struct geode_crypt_ksession *session,
int flags) {
DECLARE_COMPLETION(complete);
if (session->flags & CRYPTO_SESSION_POLL) {
aes_crypt_block(driver, session, flags);
return;
}
session->done_data = &complete;
driver->session_ptr = session;
aes_crypt_block(driver, session, flags);
wait_for_completion(&complete);
driver->session_ptr = NULL;
session->done_data = NULL;
}
static int
aes_crypt_operation(struct geode_crypt_driver *driver, struct geode_crypt_op *crypt) {
struct geode_crypt_ksession *session = get_session(driver, crypt->id);
u32 rem = crypt->len, pos = 0;
if (session == NULL)
return -1;
if (down_interruptible(&driver->engine_mutex))
return -EINTR;
if (!(session->flags & CRYPTO_SESSION_HWKEY))
SET_KEY(driver, (u8 *) session->key);
/* FIXME: set crypt->iv attribute __user */
if ((session->flags & CRYPTO_SESSION_CBC) && crypt->iv) {
u32 iv[4];
if (copy_from_user((u8 *) iv, crypt->iv, CRYPTO_KEY_LEN))
return -EFAULT;
SET_IV(driver, (u8 *) iv);
}
while(rem) {
int bsize = session->blocksize;
int copy = (rem < bsize) ? rem : bsize;
if (copy_from_user(session->src, crypt->src + pos, copy))
return -EFAULT;
if (copy < bsize)
memset(session->src + copy, 0, bsize - copy);
/* Clear the destination just to make sure */
memset(session->dest, 0, session->blocksize);
geode_aes_wait_for_op(driver, session, crypt->flags);
if (copy_to_user(crypt->dst + pos, session->dest, copy))
return -EFAULT;
rem -= copy;
pos += copy;
}
up(&driver->engine_mutex);
return 0;
}
static
irqreturn_t geode_aes_irq(int irq, void *devid, struct pt_regs *regs) {
struct geode_crypt_driver *driver = (struct geode_crypt_driver *) devid;
u32 ret = readl(driver->base + AES_INTERRUPT_REG);
if ((ret & AES_INTR_A_PENDING) && driver->session_ptr) {
complete(((struct geode_crypt_ksession *) driver->session_ptr)->done_data);
/* Acknowledge the interrupt and disable further interrupts */
writel(AES_INTR_PENDING | AES_INTR_MASK, driver->base + AES_INTERRUPT_REG);
return IRQ_HANDLED;
}
return IRQ_NONE;
}
static void
geode_free_session(struct geode_crypt_driver *driver, int id) {
struct crypt_slist *prev = 0, *slist = driver->session_list;
for( ; slist; prev = slist, slist = slist->next) {
struct geode_crypt_ksession *s = &slist->session;
if (slist->id != id) continue;
if (prev) prev->next = slist->next;
else driver->session_list = slist->next;
if (slist->rsvd_src_bfr == 0 && s->src != 0 )
free_pages((u32) s->src, get_order(s->blocksize));
if (slist->rsvd_dest_bfr == 0 && s->dest != 0 )
free_pages((u32) s->dest, get_order(s->blocksize));
kfree(slist);
break;
}
}
static int
geode_create_session(struct geode_crypt_driver *driver,
struct geode_crypt_ksession *session) {
struct crypt_slist **ccur = 0;
struct crypt_slist *cur = 0;
struct geode_crypt_ksession *s = 0;
int order = 0;
if (session->blocksize % 16) {
printk(KERN_ERR "GEODECRYPTO: Block size %d is invalid.\n",
session->blocksize);
return -EINVAL;
}
order = get_order(session->blocksize);
if (order > MAX_BLK_ORDER) {
printk(KERN_ERR "GEODECRYPTO: Block size of %d is too big\n",
session->blocksize);
return -EINVAL;
}
if (!(cur = kmalloc(sizeof(*cur), GFP_KERNEL)))
return -ENOMEM;
s = &cur->session;
cur->id = driver->session_index++;
cur->next = 0;
cur->rsvd_src_bfr = 0;
cur->rsvd_dest_bfr = 0;
memcpy(s, session, sizeof(*session));
s->src = driver->rsvd_src_bfr == 0 ?
(void *)__get_free_pages(GFP_KERNEL, order) :
(void *)(cur->rsvd_src_bfr = driver->rsvd_src_bfr);
s->dest = driver->rsvd_dest_bfr == 0 ?
(void *)__get_free_pages(GFP_KERNEL, order) :
(void *)(cur->rsvd_dest_bfr = driver->rsvd_dest_bfr);
if (!s->src || !s->dest) {
if (driver->rsvd_src_bfr == 0 && s->src != 0)
free_pages((u32) s->src, order);
if (driver->rsvd_dest_bfr == 0 && s->dest != 0)
free_pages((u32) s->dest, order);
kfree(cur);
printk(KERN_ERR "GEODECRYPTO: Unable to allocate memory pages\n");
return -ENOMEM;
}
if (!(session->flags & CRYPTO_SESSION_NOCOHERENCY)) {
change_page_attr(virt_to_page(s->src), 1<dest), 1<session_list;
while( *ccur != 0 ) ccur = &(*ccur)->next;
*ccur = cur;
return cur->id;
}
static int
geode_crypt_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) filp->private_data;
switch(cmd) {
case CIOCGSESSION: {
struct geode_crypt_ksession session;
memset(&session, 0, sizeof(session));
if (copy_from_user(&session, (void *) arg,
sizeof(struct geode_crypt_session)))
return -EFAULT;
session.id = geode_create_session(driver, &session);
if (session.id < 0) return session.id;
if (copy_to_user((void *) arg, &session,
sizeof(struct geode_crypt_session)))
return -EFAULT;
return 0;
}
case CIOCFSESSION:
geode_free_session(driver, (int) arg);
return 0;
case CIOCSKEY: {
struct geode_crypt_key key;
struct geode_crypt_ksession *session;
if (copy_from_user(&key, (void *) arg, sizeof(key)))
return -EFAULT;
session = get_session(driver, key.id);
if (!session) return -EINVAL;
memcpy(session->key, key.key, CRYPTO_KEY_LEN);
return 0;
}
case CIOCCRYPT: {
struct geode_crypt_op crypt;
if (copy_from_user(&crypt, (void *) arg, sizeof(crypt)))
return -EFAULT;
/* Sanity check */
if (!crypt.src || !crypt.dst)
return -EFAULT;
return aes_crypt_operation(driver, &crypt);
}
}
return -EINVAL;
}
static int
geode_crypt_open(struct inode * inode, struct file * filp) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) geode_crypto_driver;
filp->private_data = driver;
if (down_trylock(&driver->dev_mutex))
return -EBUSY; /* Only one at a time please */
if (driver->session_list) BUG();
return 0;
}
static int
geode_crypt_release(struct inode * inode, struct file * filp) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) filp->private_data;
/* FIXME: Should sessions survive through a close? */
if (driver->session_list) {
struct crypt_slist *slist = driver->session_list;
while(slist) {
struct crypt_slist *cur = slist;
struct geode_crypt_ksession *s = &cur->session;
slist = cur->next;
if (cur->rsvd_src_bfr == 0 && s->src != 0 )
free_pages((u32) s->src, get_order(s->blocksize));
if (cur->rsvd_dest_bfr == 0 && s->dest != 0 )
free_pages((u32) s->dest, get_order(s->blocksize));
kfree(cur);
}
driver->session_list = NULL;
}
up(&driver->dev_mutex);
return 0;
}
static struct file_operations geode_crypt_fops = {
owner: THIS_MODULE,
ioctl: geode_crypt_ioctl,
open: geode_crypt_open,
release: geode_crypt_release,
};
static struct miscdevice geode_crypt_device = {
GEODE_CRYPT_MINOR_DEV,
"geodecrypto",
&geode_crypt_fops
};
/* Defined in eeprom.c */
extern struct miscdevice geode_eeprom_device;
#ifdef CONFIG_CRYPTO
#define GEODE_AES_BLOCK_SIZE 16
#define GEODE_AES_KEY_SIZE CRYPTO_KEY_LEN
static struct geode_crypt_ksession cryptoapi_session = {
id: 0,
blocksize: GEODE_AES_BLOCK_SIZE,
flags: CRYPTO_SESSION_ECB
};
static int geode_aes_setkey(void *data, const u8 *key, unsigned int len, u32 *flags) {
if (len != GEODE_AES_KEY_SIZE) {
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
memcpy(&cryptoapi_session.key, key, GEODE_AES_KEY_SIZE);
return 0;
}
/* aes_crypto_encrypt()
encrypt the specified data from the crypto API
*/
static void geode_aes_encrypt(void *ctx, u8 *out, const u8 *in) {
if ((out == NULL) || (in == NULL))
return;
cryptoapi_session.src = (void *) in;
cryptoapi_session.dest = (void *) out;
geode_aes_wait_for_op(geode_crypto_driver, &cryptoapi_session, CRYPTO_FLAG_ENCRYPT);
}
static void geode_aes_decrypt(void *ctx, u8 *out, const u8 *in) {
if ((out == NULL) || (in == NULL))
return;
cryptoapi_session.src = (void *) in;
cryptoapi_session.dest = (void *) out;
geode_aes_wait_for_op(geode_crypto_driver, &cryptoapi_session, CRYPTO_FLAG_DECRYPT);
}
static struct crypto_alg geode_aes_crypto = {
.cra_name = "geodeaes",
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = GEODE_AES_BLOCK_SIZE,
.cra_ctxsize = 0,
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(geode_aes_crypto.cra_list),
.cra_u = {
.cipher = {
.cia_min_keysize = GEODE_AES_KEY_SIZE,
.cia_max_keysize = GEODE_AES_KEY_SIZE,
.cia_setkey = geode_aes_setkey,
.cia_encrypt = geode_aes_encrypt,
.cia_decrypt = geode_aes_decrypt
}
}
};
#endif
/* aes_remove()
Remove the device and go away
*/
static void __devexit geode_aes_remove(struct pci_dev *pdev) {
/* If geode_crypto_driver is null, then nothing was really set up */
if (geode_crypto_driver) {
if (geode_crypto_driver->session_list) BUG();
if (geode_crypto_driver->flags & HAVE_RSVD_BUFFERS) {
if (geode_crypto_driver->rsvd_src_bfr != 0)
free_pages((u32)geode_crypto_driver->rsvd_src_bfr,MAX_BLK_ORDER);
if (geode_crypto_driver->rsvd_dest_bfr != 0)
free_pages((u32)geode_crypto_driver->rsvd_dest_bfr,MAX_BLK_ORDER);
}
#ifdef CONFIG_CRYPTO
if (geode_crypto_driver->flags & HAVE_CRYPTOAPI_REGISTERED)
crypto_unregister_alg(&geode_aes_crypto);
#endif
if (geode_crypto_driver->flags & HAVE_EEPROM_REGISTERED)
misc_deregister(&geode_eeprom_device);
if (geode_crypto_driver->flags & HAVE_CRYPT_REGISTERED)
misc_deregister(&geode_crypt_device);
if (geode_crypto_driver->flags & HAVE_IRQ_ATTACHED)
free_irq(GEODE_AES_IRQ, geode_crypto_driver);
if (geode_crypto_driver->flags & HAVE_BAR_MAPPED)
if (geode_crypto_driver->base)
iounmap(geode_crypto_driver->base);
if (geode_crypto_driver->flags & HAVE_PCI_REGIONS)
pci_release_regions (pdev);
if (geode_crypto_driver->flags & HAVE_PCI_ENABLED)
pci_disable_device (pdev);
kfree(geode_crypto_driver);
geode_crypto_driver = 0;
}
}
static int
geode_aes_probe(struct pci_dev *pdev, const struct pci_device_id *id) {
int ret = 0;
unsigned long ioaddr, iolen;
geode_crypto_driver = (struct geode_crypt_driver *)
kmalloc(sizeof(*geode_crypto_driver), GFP_KERNEL);
if (!geode_crypto_driver) return -ENOMEM;
memset(geode_crypto_driver, 0, sizeof(*geode_crypto_driver));;
ret = pci_enable_device(pdev);
if (ret) goto xit;
geode_crypto_driver->flags |= HAVE_PCI_ENABLED;
/* Get our resources - should be just the mmeory mapped region */
ioaddr = pci_resource_start(pdev, 0);
iolen = pci_resource_len(pdev, 0);
ret = pci_request_regions(pdev, "Geode AES module");
if (ret) goto xit;
geode_crypto_driver->flags |= HAVE_PCI_REGIONS;
/* Set up the memory block */
if (!(geode_crypto_driver->base = (u8 *) ioremap(ioaddr, iolen))) {
ERROR("Unable to map the registers [%lx]\n", ioaddr);
ret = -ENOMEM;
goto xit;
}
geode_crypto_driver->flags |= HAVE_BAR_MAPPED;
/* Clear any pending AES calls, and disable the interrupts */
/* Interrupts will be enabled right before the session */
writel(AES_INTR_PENDING | AES_INTR_MASK, geode_crypto_driver->base + AES_INTERRUPT_REG);
/* Request the interrupt for non-polling sessions */
ret = request_irq(GEODE_AES_IRQ, geode_aes_irq, SA_SHIRQ,
"Geode AES Engine", geode_crypto_driver);
if (ret) {
ERROR("Unable to attach irq %d\n",GEODE_AES_IRQ);
goto xit;
}
geode_crypto_driver->flags |= HAVE_IRQ_ATTACHED;
/* semaphore for accessing the engine */
init_MUTEX(&geode_crypto_driver->engine_mutex);
/* semaphore for accessing the device file */
init_MUTEX(&geode_crypto_driver->dev_mutex);
init_MUTEX(&geode_crypto_driver->eeprom_mutex);
/* Register the AES interface */
if ((ret = misc_register(&geode_crypt_device))) {
ERROR("Unable to register the crypto device\n");
goto xit;
}
geode_crypto_driver->flags |= HAVE_CRYPT_REGISTERED;
if (misc_register(&geode_eeprom_device))
WARNING("Unable to register the eeprom device\n");
else
geode_crypto_driver->flags |= HAVE_EEPROM_REGISTERED;
#ifdef CONFIG_CRYPTO
if (crypto_register_alg(&geode_aes_crypto))
WARNING("Unable to register the cryptoAPI module.\n");
else
geode_crypto_driver->flags |= HAVE_CRYPTOAPI_REGISTERED;
#endif
if (rsvd_mem != 0) {
WARNING("reserving %lu physical memory\n",PAGE_SIZE<rsvd_src_bfr =
(void *) __get_free_pages(GFP_KERNEL, MAX_BLK_ORDER);
geode_crypto_driver->rsvd_dest_bfr =
(void *) __get_free_pages(GFP_KERNEL, MAX_BLK_ORDER);
if (geode_crypto_driver->rsvd_src_bfr == 0 ||
geode_crypto_driver->rsvd_dest_bfr == 0) {
WARNING("Unable to allocate reserved memory buffer\n");
ret = -ENOMEM;
goto xit;
}
geode_crypto_driver->flags |= HAVE_RSVD_BUFFERS;
}
xit:
if(ret) geode_aes_remove(pdev);
return ret;
}
struct pci_device_id geode_aes_tbl[] = {
{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_GEODE_AES,
PCI_ANY_ID, PCI_ANY_ID} ,
{ 0, }
};
MODULE_DEVICE_TABLE(pci, geode_aes_tbl);
struct pci_driver aes_pci_driver = {
name: "Geode GX AES drver",
id_table: geode_aes_tbl,
probe: geode_aes_probe,
remove: __devexit_p(geode_aes_remove)
};
static int __init geode_aes_init(void)
{
printk(KERN_INFO "%s\n", AMD_VERSION);
return pci_module_init(&aes_pci_driver);
}
static void __exit geode_aes_exit(void)
{
pci_unregister_driver(&aes_pci_driver);
}
MODULE_AUTHOR("Advanced Micro Devices, Inc.");
MODULE_DESCRIPTION("Geode LX Hardware AES driver");
MODULE_LICENSE("GPL");
MODULE_PARM(rsvd_mem, "i");
MODULE_PARM_DESC(rsvd_mem, "preallocated buffer memory");
module_init(geode_aes_init);
module_exit(geode_aes_exit);
AES_Linux_LX_02.01.0100/modules/geode_crypto.h 0000444 0112057 0000024 00000010711 10337203736 020667 0 ustar pmccumbe dialout #ifndef CRYPTO_H_
/* The key length is now and forever more 128 bits */
#define CRYPTO_KEY_LEN 16
#define CRYPTO_SESSION_HWKEY 0x001
#define CRYPTO_SESSION_ECB 0x010
#define CRYPTO_SESSION_CBC 0x020
#define CRYPTO_SESSION_NOCOHERENCY 0x100
#define CRYPTO_SESSION_POLL 0x200
#define CRYPTO_FLAG_DECRYPT 0x001
#define CRYPTO_FLAG_ENCRYPT 0x002
/* Size of the user block in the EEPROM */
#define EEPROM_SIZE 237
#define EEPROM_LOWER_RW 0x01
#define EEPROM_UPPER_RW 0x02
struct geode_crypt_session {
unsigned int flags;
unsigned int blocksize;
unsigned char key[CRYPTO_KEY_LEN];
int id;
};
struct geode_crypt_op {
int id;
unsigned int flags;
unsigned int len;
#ifdef _KERNEL_
void __user *src;
void __user *dst;
void __user *iv;
#else
void *src;
void *dst;
void *iv;
#endif
};
struct geode_crypt_key {
int id;
unsigned char key[CRYPTO_KEY_LEN];
};
#define CIOCGSESSION _IOWR('c', 101, struct geode_crypt_session *)
#define CIOCFSESSION _IOW('c', 102, unsigned int)
#define CIOCCRYPT _IOWR('c', 103, struct geode_crypt_op *)
#define CIOCSKEY _IOW('c', 103, struct geode_crypt_key *)
#define EIOCSKEYOFF _IOW('c', 104, unsigned int)
#define EIOCSLOCKUP _IOW('c', 105, unsigned int)
#define EIOCSLOCKLW _IOW('c', 106, unsigned int)
#define EIOSKEY _IOW('c', 107, unsigned char *)
#define EIOGPERMS _IOR('c', 108, int)
#ifdef __KERNEL__
#define GEODE_CRYPT_MINOR_DEV 155
/* Doh - Cimarron is 156 */
#define GEODE_EEPROM_MINOR_DEV 157
#define AES_CONTROLA_REG 0x0000
#define AES_CONTROLB_REG 0x0004
/* Ctrl register bits */
#define AES_CTRL_START 0x01
#define AES_CTRL_DECRYPT 0x00 /* Default - but defined for simplicity */
#define AES_CTRL_ENCRYPT 0x02
#define AES_CTRL_WRKEY 0x04
#define AES_CTRL_DCA 0x08
#define AES_CTRL_SCA 0x10
#define AES_CTRL_CBCA 0x20
#define AES_INTERRUPT_REG 0x0008
#define AES_INTR_EEPROM_PENDING 0x40000
#define AES_INTR_B_PENDING 0x20000
#define AES_INTR_A_PENDING 0x10000
#define AES_INTR_PENDING (AES_INTR_A_PENDING | AES_INTR_B_PENDING)
#define AES_INTR_EEPROM_MASK 0x00004
#define AES_INTR_B_MASK 0x00002
#define AES_INTR_A_MASK 0x00001
#define AES_INTR_MASK (AES_INTR_EEPROM_MASK | AES_INTR_A_MASK | AES_INTR_B_MASK)
#define AES_SOURCEA_REG 0x0010
#define AES_DSTA_REG 0x0014
#define AES_LENA_REG 0x0018
#define AES_SOURCEB_REG 0x0020
#define AES_DSTB_REG 0x0024
#define AES_LENB_REG 0x0028
#define AES_WRITEKEY0_REG 0x0030
#define AES_WRITEKEY1_REG 0x0034
#define AES_WRITEKEY2_REG 0x0038
#define AES_WRITEKEY3_REG 0x003C
#define AES_WRITEIV0_REG 0x0040
#define AES_WRITEIV1_REG 0x0044
#define AES_WRITEIV2_REG 0x0048
#define AES_WRITEIV3_REG 0x004C
/* EEPROM definitions */
#define EEPROM_CTRL_REG 0x0800
#define EEPROM_CTRL_READ 0x00
#define EEPROM_CTRL_START 0x01
#define EEPROM_CTRL_WRITE 0x02
#define EEPROM_CTRL_EXCEPT 0x04
#define EEPROM_CTRL_KEYDISABLE 0x20
#define EEPROM_ADDR_REG 0x0804
#define EEPROM_DATA_REG 0x0808
#define EEPROM_SEC_REG 0x080C
#define EEPROM_ACCESS_WPL 0x0007
#define EEPROM_ACCESS_WPU 0x0070
/* Defines for the eeprom space map - only the key offset is used by
the driver, everywhere from 18 to 255 is the users space, and he only
thinks he has 238 total bytes of space
*/
#define EEPROM_WPL_OFFSET 0x00
#define EEPROM_WPE_OFFSET 0x01
#define EEPROM_KEY_OFFSET 0x02
#define EEPROM_ID_OFFSET 18
#define EEPROM_ULOWER_OFFSET 34
#define EEPROM_UUPPER_OFFSET 128
struct geode_crypt_ksession {
u32 flags;
u32 blocksize;
u8 key[CRYPTO_KEY_LEN];
int id;
void *src;
void *dest;
void *done_data;
};
struct crypt_slist {
int id;
struct crypt_slist *next;
char *rsvd_src_bfr;
char *rsvd_dest_bfr;
struct geode_crypt_ksession session;
};
#define HAVE_PCI_ENABLED 0x01
#define HAVE_PCI_REGIONS 0x02
#define HAVE_BAR_MAPPED 0x04
#define HAVE_IRQ_ATTACHED 0x08
#define HAVE_CRYPT_REGISTERED 0x10
#define HAVE_EEPROM_REGISTERED 0x20
#define HAVE_CRYPTOAPI_REGISTERED 0x40
#define HAVE_RSVD_BUFFERS 0x80
struct geode_crypt_driver {
unsigned char *base;
int flags;
char *rsvd_src_bfr;
char *rsvd_dest_bfr;
struct semaphore dev_mutex;
struct semaphore engine_mutex;
struct semaphore eeprom_mutex;
int session_index;
struct crypt_slist *session_list;
struct geode_crypt_ksession *session_ptr;
};
#endif
#endif
AES_Linux_LX_02.01.0100/modules/eeprom.c 0000444 0112057 0000024 00000014343 10337203736 017473 0 ustar pmccumbe dialout /*
* Driver for the EEPROM encryption key storage on the Geode GX
* Copyright (C) 2003 Advanced Micro Devices, Inc. All Rights Reserved.
*/
/* This driver allows the user to read and write the 238 bytes of user
on the EEPROM. This is the space above the access control bytes and
the hidden key, which couldn't be read even if we wanted to. As far
as the user is concerned, he can seek, read and (if the bytes are set),
write up to 238 bytes of general storage.
Setting the key and the access control bytes is handled by the ioctl
commands.
*/
#include
#include
#include
#include
#include
#include
#include
#include "geode_crypto.h"
static int
eeprom_read_dev(struct geode_crypt_driver *driver, u8 *data, int offset,
int size)
{
u32 ctrl = readl(driver->base + EEPROM_CTRL_REG);
int i = 0;
int ret = -EINVAL;
/* Sanity check */
if (offset + size > 255) return -EINVAL;
/* Just a simple wait loop */
for(i = 0; i < size; i++) {
u32 reg = ctrl;
u32 value = 0;
writel(0x0 | ((offset + i) & 0xFF),
driver->base + EEPROM_ADDR_REG);
reg &= ~EEPROM_CTRL_WRITE;
reg |= EEPROM_CTRL_START;
writel(reg, driver->base + EEPROM_CTRL_REG);
while(1) {
reg = readl(driver->base + EEPROM_CTRL_REG);
if (reg & EEPROM_CTRL_EXCEPT) goto exit_read;
else if (!(reg & EEPROM_CTRL_START)) break;
udelay(10);
}
value = readl(driver->base + EEPROM_DATA_REG);
data[i] = value & 0xFF;
}
ret = 0;
exit_read:
writel(ctrl | EEPROM_CTRL_EXCEPT, driver->base + EEPROM_CTRL_REG);
return ret;
}
static int
eeprom_write_dev(struct geode_crypt_driver *driver, u8 *data,
int offset, int size)
{
int i = 0;
int ret = -EINVAL;
u32 in = readl(driver->base + EEPROM_SEC_REG);
u32 mask = offset < 127 ? EEPROM_ACCESS_WPL : EEPROM_ACCESS_WPU;
u32 ctrl = readl(driver->base + EEPROM_CTRL_REG);
/* Sanity check */
if (offset + size > 255) return -EINVAL;
/* Make sure that we have permission to write */
if ((in & mask) != mask) return -EACCES;
/* Just a simple wait loop */
for(i = 0; i < size; i++) {
u32 reg = 0;
writel(0x0 | ((offset + i) & 0xFF),
driver->base + EEPROM_ADDR_REG);
writel(0x0 | (data[i] & 0xFF), driver->base + EEPROM_DATA_REG);
writel(ctrl | EEPROM_CTRL_WRITE | EEPROM_CTRL_START,
driver->base + EEPROM_CTRL_REG);
while(1) {
reg = readl(driver->base + EEPROM_CTRL_REG);
if (reg & EEPROM_CTRL_EXCEPT) goto exit_write;
else if (!(reg & EEPROM_CTRL_START)) break;
udelay(10);
}
}
ret = 0;
exit_write:
writel(ctrl | EEPROM_CTRL_EXCEPT, driver->base + EEPROM_CTRL_REG);
return ret;
}
static loff_t
eeprom_lseek(struct file * file, loff_t offset, int orig) {
switch(orig) {
case 0:
if (offset < 0 || offset > 237) return -EINVAL;
file->f_pos = (unsigned int) offset;
return file->f_pos;
case 1:
if (file->f_pos + offset > 237) return -EINVAL;
if (file->f_pos + offset < 0) return -EINVAL;
file->f_pos += offset;
return file->f_pos;
default:
return -EINVAL;
}
}
static ssize_t
eeprom_write(struct file *filep, const char *buffer,
size_t count, loff_t * ppos) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) filep->private_data;
u8 local[238];
int len, ret;
if (filep->f_pos > 237) return 0;
len = (filep->f_pos + count > 237) ? 238 - filep->f_pos : count;
if (copy_from_user(local, buffer, len))
return -EFAULT;
down(&driver->eeprom_mutex);
ret = eeprom_write_dev(driver, local, 18 + filep->f_pos, len);
up(&driver->eeprom_mutex);
if (ret) return ret;
*ppos += len;
return len;
}
static ssize_t
eeprom_read(struct file *filep, char *buffer, size_t count, loff_t * ppos) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) filep->private_data;
u8 local[238];
int len, ret;
if (filep->f_pos > EEPROM_SIZE) return 0;
len = (filep->f_pos + count > EEPROM_SIZE)
? (EEPROM_SIZE + 1) - filep->f_pos : count;
down(&driver->eeprom_mutex);
ret = eeprom_read_dev(driver, local,
EEPROM_ID_OFFSET + filep->f_pos, len);
up(&driver->eeprom_mutex);
if (ret) return ret;
if (copy_to_user(buffer, local, len))
return -EFAULT;
*ppos += len;
return len;
}
static int
eeprom_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) {
struct geode_crypt_driver *driver =
(struct geode_crypt_driver *) filp->private_data;
u32 in, mask;
/* Return -EINVAL if there is an exepction on the device */
in = readl(driver->base + EEPROM_CTRL_REG);
if (in & EEPROM_CTRL_EXCEPT)
return -EINVAL;
switch(cmd) {
case EIOCSKEYOFF:
in |= EEPROM_CTRL_KEYDISABLE;
writel(in, driver->base + EEPROM_CTRL_REG);
return 0;
case EIOCSLOCKUP:
case EIOCSLOCKLW:
mask = (cmd == EIOCSLOCKLW) ?
EEPROM_ACCESS_WPL : EEPROM_ACCESS_WPU;
in = readl(driver->base + EEPROM_SEC_REG);
/* If write access is enabled, then we can lock it */
/* This will take effect on the next reset */
if ((in & mask) == mask) {
char ctrl = 0x00;
eeprom_read_dev(driver, &ctrl, 0, 1);
ctrl &= ~mask;
eeprom_write_dev(driver, &ctrl, 0, 1);
}
return 0;
case EIOSKEY: {
u8 key[32];
if (!arg) return -EINVAL;
if (copy_from_user((u8 *) key, (u8 *) arg, sizeof(key)))
return -EFAULT;
return eeprom_write_dev(driver, (u8 *) key,
EEPROM_KEY_OFFSET, 16);
}
case EIOGPERMS: {
int ret = 0;
in = readl(driver->base + EEPROM_SEC_REG);
if ((in & EEPROM_ACCESS_WPL) == EEPROM_ACCESS_WPL)
ret |= EEPROM_LOWER_RW;
if ((in & EEPROM_ACCESS_WPU) == EEPROM_ACCESS_WPL)
ret |= EEPROM_UPPER_RW;
return ret;
}
}
return -EINVAL;
}
extern struct geode_crypt_driver *geode_crypto_driver;
static
int eeprom_open(struct inode * inode, struct file * filp) {
filp->private_data = (void *) geode_crypto_driver;
return 0;
}
static struct file_operations geode_eeprom_fops = {
owner: THIS_MODULE,
open: eeprom_open,
read: eeprom_read,
write: eeprom_write,
llseek: eeprom_lseek,
ioctl: eeprom_ioctl,
};
struct miscdevice geode_eeprom_device = {
GEODE_EEPROM_MINOR_DEV,
"geode_eeprom",
&geode_eeprom_fops
};
AES_Linux_LX_02.01.0100/modules/interface.txt 0000444 0112057 0000024 00000003417 10337203736 020541 0 ustar pmccumbe dialout AMD AES Encryption Module Interface
** DESCRIPTION **
The AES encryption module provides two paths for a user application to perform
an encryption or decryption operation.
Asynchronous operations can be performed via write() and read() operations
through the device file. These are considered to be asynchronous, because the
user can go off and do other things while waiting for the encryption to return.
Synchronous methods are prompted via an ioctl() call (see below), and wait for
the result to be calculated.
Both methods use the key specified by the AES_IOCTL_SETKEY ioctl() call.
** IOCTL **
-----------------------------
AES_IOCTL_SETMODE (0x01)
-----------------------------
Arguments:
AES_MODE_ENCRYPT (0x01)
AES_MODE_DECRYPT (0x02)
Description:
Set the appropriate mode for subsequent asynchronous operations.
-----------------------------
AES_IOCTL_SETKEY (0x02)
-----------------------------
Argument:
16 byte AES key
Description:
Set the AES key for subsequent operations (both synchronous and asynchronous)
-----------------------------
AES_IOCTL_ENCRYPT (0x03)
AES_IOCTL_DECRYPT (0x04)
-----------------------------
Arguments:
struct aes_operation {
unsigned long src;
unsigned long dst;
int len;
}
Description:
Perform a synchronous encryption or decryption operation. The argument
is the aes_operation structure, where src is the address of the source block,
dst is the address of the destination block, and len is the size of the block.
(padded to 16 byte intervals).
-----------------------------
AES_IOCTL_SET_COHERENCY (0x05)
-----------------------------
Arguments:
true (1) or false (0)
Description:
Determine if the AES module should perform its own cache coherency,
or if it should be left to the driver to flush the cache.
AES_Linux_LX_02.01.0100/modules/build_num.h 0000444 0112057 0000024 00000001364 10337203736 020166 0 ustar pmccumbe dialout #ifndef BUILD_NUM_H
#define BUILD_NUM_H
#ifdef AMD_BUILDNUM_DEFINED
#error "Caution: You have muliple version files in your path. Please correct this."
#endif
#define AMD_BUILDNUM_DEFINED
/* Define the following for your driver */
#define _NAME "AMD Geode LX AES driver"
#define _MAJOR 02
#define _MINOR 01
/* This defines the current buildlevel and revision of the code */
#define _BL 01
#define _BLREV 00
#ifdef _BLREV
#define _BUILDLEVEL _x(_BL) "." _x(_BLREV)
#else
#define _BUILDLEVEL _x(_BL)
#endif
/* Use this macro to get the version string */
#define AMD_VERSION _NAME " " _x(_MAJOR) "." _x(_MINOR) "." _BUILDLEVEL
/* Syntatic sugar for use above - you probably don't have to touch this */
#define _x(s) _s(s)
#define _s(s) #s
#endif
AES_Linux_LX_02.01.0100/modules/Makefile.in 0000444 0112057 0000024 00000003276 10337203736 020110 0 ustar pmccumbe dialout CC=@CC@
LD=@LD@
KERNEL_SRC=@KERNEL_SRC@
# Grab the kernel version right out of the tree
KERNEL_VERSION = $(shell sed -ne 's/"//g;s/^\#define UTS_RELEASE //p' \
$(KERNEL_SRC)/include/linux/version.h)
# This is borrowed from the Orinoco drivers. Thanks fellas...
OLDMAKE = $(filter 2.4%, $(KERNEL_VERSION))
DOT_CONFIG = $(wildcard $(KERNEL_SRC)/.config)
ifeq (,$(DOT_CONFIG))
$(error The kernel source is not configured)
endif
include $(DOT_CONFIG)
MODULES=geodeaes.o
CURDIR=$(shell pwd)
ifeq (,$(OLDMAKE))
obj-m := $(MODULES)
geodeaes-objs := geode_crypto.o eeprom.o
all: modules
modules:
$(MAKE) -C $(KERNEL_SRC) M=$(CURDIR) modules
install: modules
install -d $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/misc
install -m 0644 $(MODULES:%.o=%.ko) $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/misc
clean:
rm -f *.o *.ko
else
KERNEL_HEADERS = -I$(KERNEL_SRC)/include
CPPFLAGS = -D__KERNEL__ -DMODULE -I. $(KERNEL_HEADERS)
CFLAGS=-O2 -g -Wall -Wstrict-prototypes -fno-strict-aliasing -fno-common -pipe
ifdef CONFIG_MODVERSIONS
MFLAG = -DMODVERSIONS -include $(KERNEL_SRC)/include/linux/modversions.h
endif
SRCS=geode_crypto.c eeprom.c
all: $(MODULES)
clean:
@ rm -f *.o *.d
install: $(MODULES)
@ install -d $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/misc
@ install -m 0644 geodeaes.o $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/misc/geodeaes.o
geodeaes.o: geode_crypto.o eeprom.o
$(LD) -r -o $@ geode_crypto.o eeprom.o
%.o: %.c
$(CC) -MD $(CFLAGS) $(CPPFLAGS) $(MFLAG) -c $<
%.s: %.c
$(CC) -MD $(CFLAGS) $(CPPFLAGS) -S $<
%.i: %.c
$(CC) -MD $(CPPFLAGS) -E $< -o $@
-include $(SRCS:%.c=%.d)
endif
distclean: clean
@ rm Makefile
AES_Linux_LX_02.01.0100/README.api 0000444 0112057 0000024 00000004515 10337203713 016013 0 ustar pmccumbe dialout ----------------------------
USING THE GEODEAES INTERFACE
----------------------------
User applications can communicate with the AES engine through a series of
ioctl() calls as detailed below:
* ALLOCATING A SESSION
All AES operations happen against a set session.
struct geode_crypt_session {
unsigned int flags;
unsigned int blocksize;
unsigned char key[CRYPTO_KEY_LEN];
int id;
};
* Flags is a bitmask of the following options:
CRYPTO_SESSION_HWKEY
Specify that the session should use the hardware key from the EEPROM.
Default is off
CRYPTO_SESSION_ECB
Indicates that this session should use the ECB mode of encryption
CRYPTO_SESSION_CBC
Indicates that this session should use the CBC mode of encryption. These
two modes cannot be defined at the same time.
CRYPTO_SESSION_NOCOHERENCY
Indicates that you should not use cache coherency when doing this operation.
Default is to turn caching off on the pages being operated on.
* Blocksize is the size of the block (from 16 to 3MB allowed)
* key is an array of 16 bytes that should hold the hex equivelent of the
key (if HWKEY is set, this field is ignored).
* id should be zero going in.
Specify a new session by calling the ioctl:
ioctl(fd, SIOCGSESSION, &session);
The session id is returned in the id member.
* PERFORMING AN OPERATION
To perform a particular encryption/decryption operation, the following
structure is used:
struct geode_crypt_op {
int id;
unsigned int flags;
unsigned int len;
void *src;
void *dst;
void *iv;
};
* id - the session id as allocated above
* flags - either CRYPTO_FLAG_DECRYPT or CRYPTO_FLAG_ENCRYPT
* len - the length of the operation (not nessesarly the blocksize indicated
in the session).
* src,dst - the sorce and destination pointers of the data. These must be
non null and big enough to hold the block size.
* iv - an optional initalization vector used in CBC mode. If it is null,
* then it is ignored.
Call an operation with the following:
ioctl(fd, SIOCCRYPT, &op);
Any number of operations can be called on a single session.
* SETTING A NEW KEY ON THE SESSION
to change the key of a session, use the following:
struct geode_crypt_key {
int id;
unsigned char key[CRYPTO_KEY_LEN];
};
ioctl(fd, CIOSKEY, &key);
* FREEING A SESSION
When you are done with a session, free it with following
ioctl(fd, CIOFSESSION, session.id);
AES_Linux_LX_02.01.0100/AUTHORS 0000644 0112057 0000024 00000000222 10337203713 015424 0 ustar pmccumbe dialout For bugs, patches, and info requests, please subscribe to info-linux@geode.amd.com.
Send a blank message to: info-linux-subscribe@geode.amd.com
AES_Linux_LX_02.01.0100/COPYING 0000644 0112057 0000024 00000043131 10337203713 015415 0 ustar pmccumbe dialout GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.