Commit 798cc279 authored by Jordan Crouse's avatar Jordan Crouse Committed by Chris Wright

[PATCH] GEODE-AES: Allow in-place operations [CVE-2007-2451]

Allow in-place crypto operations.  Also remove the coherent user flag
(we use it automagically now), and by default use the user written
key rather then the HW hidden key - this makes crypto just work without
any special considerations, and thats OK, since its our only usage
model.
Signed-off-by: default avatarJordan Crouse <jordan.crouse@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
parent 7682ffa2
...@@ -102,10 +102,15 @@ geode_aes_crypt(struct geode_aes_op *op) ...@@ -102,10 +102,15 @@ geode_aes_crypt(struct geode_aes_op *op)
u32 flags = 0; u32 flags = 0;
unsigned long iflags; unsigned long iflags;
if (op->len == 0 || op->src == op->dst) if (op->len == 0)
return 0; return 0;
if (op->flags & AES_FLAGS_COHERENT) /* If the source and destination is the same, then
* we need to turn on the coherent flags, otherwise
* we don't need to worry
*/
if (op->src == op->dst)
flags |= (AES_CTRL_DCA | AES_CTRL_SCA); flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
if (op->dir == AES_DIR_ENCRYPT) if (op->dir == AES_DIR_ENCRYPT)
...@@ -120,7 +125,7 @@ geode_aes_crypt(struct geode_aes_op *op) ...@@ -120,7 +125,7 @@ geode_aes_crypt(struct geode_aes_op *op)
_writefield(AES_WRITEIV0_REG, op->iv); _writefield(AES_WRITEIV0_REG, op->iv);
} }
if (op->flags & AES_FLAGS_USRKEY) { if (!(op->flags & AES_FLAGS_HIDDENKEY)) {
flags |= AES_CTRL_WRKEY; flags |= AES_CTRL_WRKEY;
_writefield(AES_WRITEKEY0_REG, op->key); _writefield(AES_WRITEKEY0_REG, op->key);
} }
...@@ -289,6 +294,7 @@ static struct crypto_alg geode_cbc_alg = { ...@@ -289,6 +294,7 @@ static struct crypto_alg geode_cbc_alg = {
.setkey = geode_setkey, .setkey = geode_setkey,
.encrypt = geode_cbc_encrypt, .encrypt = geode_cbc_encrypt,
.decrypt = geode_cbc_decrypt, .decrypt = geode_cbc_decrypt,
.ivsize = AES_IV_LENGTH,
} }
} }
}; };
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#define AES_DIR_DECRYPT 0 #define AES_DIR_DECRYPT 0
#define AES_DIR_ENCRYPT 1 #define AES_DIR_ENCRYPT 1
#define AES_FLAGS_USRKEY (1 << 0) #define AES_FLAGS_HIDDENKEY (1 << 0)
#define AES_FLAGS_COHERENT (1 << 1)
struct geode_aes_op { struct geode_aes_op {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment