projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: fix ads124s0x data structure
[fw/altos]
/
src
/
aes
/
ao_aes.c
diff --git
a/src/aes/ao_aes.c
b/src/aes/ao_aes.c
index 4977aaf81158408aff72e02ad5641a22de919f83..0bc8188e3d2ae68c7eca2b78a214b473ce34b712 100644
(file)
--- a/
src/aes/ao_aes.c
+++ b/
src/aes/ao_aes.c
@@
-11,7
+11,9
@@
* Vincent Rijmen
*/
* Vincent Rijmen
*/
+#ifndef AO_AES_TEST
#include <ao.h>
#include <ao.h>
+#endif
#include <ao_aes.h>
#include "ao_aes_int.h"
#include <ao_aes.h>
#include "ao_aes_int.h"
@@
-193,6
+195,7
@@
static inline void xAddInvMix(word32 res[MAXBC], word32 a[MAXBC],
#endif /* code included for reference */
#endif /* code included for reference */
+static
int xrijndaelKeySched(word32 key[], int keyBits, int blockBits,
roundkey *rkk)
{
int xrijndaelKeySched(word32 key[], int keyBits, int blockBits,
roundkey *rkk)
{
@@
-280,6
+283,7
@@
int xrijndaelKeySched(word32 key[], int keyBits, int blockBits,
/* Encryption of one block. */
/* Encryption of one block. */
+static
void xrijndaelEncrypt(word32 block[], roundkey *rkk)
{
word32 block2[MAXBC]; /* hold intermediate result */
void xrijndaelEncrypt(word32 block[], roundkey *rkk)
{
word32 block2[MAXBC]; /* hold intermediate result */
@@
-306,6
+310,11
@@
void xrijndaelEncrypt(word32 block[], roundkey *rkk)
xKeyAddition(block, block2, rp, BC);
}
xKeyAddition(block, block2, rp, BC);
}
+#if NOTUSED
+/* We don't actually need this in AltOS, so don't bother including it */
+
+/* Decryption of one block. */
+static
void xrijndaelDecrypt(word32 block[], roundkey *rkk)
{
word32 block2[MAXBC]; /* hold intermediate result */
void xrijndaelDecrypt(word32 block[], roundkey *rkk)
{
word32 block2[MAXBC]; /* hold intermediate result */
@@
-347,22
+356,26
@@
void xrijndaelDecrypt(word32 block[], roundkey *rkk)
xKeyAddition(block, block, rp, BC);
}
xKeyAddition(block, block, rp, BC);
}
+#endif
uint8_t ao_aes_mutex;
uint8_t ao_aes_mutex;
+static word32 key[16/4];
static roundkey rkk;
static roundkey rkk;
-static
uint8_t iv[16
];
+static
word32 iv[16/4
];
void
ao_aes_set_mode(enum ao_aes_mode mode)
{
void
ao_aes_set_mode(enum ao_aes_mode mode)
{
+ (void) mode;
/* we only do CBC_MAC anyways... */
}
void
/* we only do CBC_MAC anyways... */
}
void
-ao_aes_set_key(
__xdata
uint8_t *in)
+ao_aes_set_key(uint8_t *in)
{
{
- xrijndaelKeySched((word32 *) in, 128, 128, &rkk);
+ memcpy(key, in, 16);
+ xrijndaelKeySched((word32 *) key, 128, 128, &rkk);
}
void
}
void
@@
-372,14
+385,15
@@
ao_aes_zero_iv(void)
}
void
}
void
-ao_aes_run(
__xdata
uint8_t *in,
-
__xdata
uint8_t *out)
+ao_aes_run(uint8_t *in,
+ uint8_t *out)
{
uint8_t i;
{
uint8_t i;
+ uint8_t *_iv = (uint8_t *) iv;
for (i = 0; i < 16; i++)
for (i = 0; i < 16; i++)
- iv[i] ^= in[i];
- xrijndaelEncrypt(
(word32 *)
iv, &rkk);
+
_
iv[i] ^= in[i];
+ xrijndaelEncrypt(iv, &rkk);
if (out)
memcpy(out, iv, 16);
}
if (out)
memcpy(out, iv, 16);
}