.flag_scheme = FLAG_NONE,
};
-static int env_aes_cbc_crypt(char *data, const int enc);
+static int env_aes_cbc_crypt(char *data, const int enc, uint8_t *key);
static int HaveRedundEnv = 0;
{
int ret;
if (common_args.aes_flag) {
- ret = env_aes_cbc_crypt(environment.data, 1);
+ ret = env_aes_cbc_crypt(environment.data, 1,
+ common_args.aes_key);
if (ret) {
fprintf(stderr,
"Error: can't encrypt env for flash\n");
}
/* Encrypt or decrypt the environment before writing or reading it. */
-static int env_aes_cbc_crypt(char *payload, const int enc)
+static int env_aes_cbc_crypt(char *payload, const int enc, uint8_t *key)
{
uint8_t *data = (uint8_t *)payload;
const int len = getenvsize();
uint32_t aes_blocks;
/* First we expand the key. */
- aes_expand_key(common_args.aes_key, key_exp);
+ aes_expand_key(key, key_exp);
/* Calculate the number of AES blocks to encrypt. */
aes_blocks = DIV_ROUND_UP(len, AES_KEY_LENGTH);
crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
if (common_args.aes_flag) {
- ret = env_aes_cbc_crypt(environment.data, 0);
+ ret = env_aes_cbc_crypt(environment.data, 0,
+ common_args.aes_key);
if (ret)
return ret;
}
crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
if (common_args.aes_flag) {
- ret = env_aes_cbc_crypt(redundant->data, 0);
+ ret = env_aes_cbc_crypt(redundant->data, 0,
+ common_args.aes_key);
if (ret)
return ret;
}