Skip to content

Commit 9a0c37a

Browse files
authored
Merge pull request #740 from pabuhler/wolfssl-icm-multi-encrypt
WolfSSL aes icm multi encrypt fix
2 parents f0108f7 + eeb02e9 commit 9a0c37a

File tree

4 files changed

+398
-7
lines changed

4 files changed

+398
-7
lines changed

crypto/cipher/aes_icm_wssl.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,11 @@ static srtp_err_status_t srtp_aes_icm_wolfssl_context_init(void *cv,
256256
break;
257257
}
258258

259-
/* Counter mode always encrypts. */
260-
err = wc_AesSetKey(c->ctx, key, c->key_size, NULL, AES_ENCRYPTION);
261-
if (err < 0) {
262-
debug_print(srtp_mod_aes_icm, "wolfSSL error code: %d", err);
263-
return srtp_err_status_fail;
259+
/* Store key. */
260+
if (c->key_size > sizeof(c->key)) {
261+
return srtp_err_status_bad_param;
264262
}
263+
memcpy(c->key, key, c->key_size);
265264

266265
return srtp_err_status_ok;
267266
}
@@ -290,7 +289,9 @@ static srtp_err_status_t srtp_aes_icm_wolfssl_set_iv(
290289
debug_print(srtp_mod_aes_icm, "set_counter: %s",
291290
v128_hex_string(&c->counter));
292291

293-
err = wc_AesSetIV(c->ctx, c->counter.v8);
292+
/* Counter mode always encrypts. */
293+
err = wc_AesSetKey(c->ctx, c->key, c->key_size, c->counter.v8,
294+
AES_ENCRYPTION);
294295
if (err < 0) {
295296
debug_print(srtp_mod_aes_icm, "wolfSSL error code: %d", err);
296297
return srtp_err_status_fail;

crypto/include/aes_icm_ext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ typedef struct {
6969
typedef struct {
7070
v128_t counter; /* holds the counter value */
7171
v128_t offset; /* initial offset value */
72-
int key_size;
72+
uint8_t key[SRTP_AES_256_KEY_LEN];
73+
size_t key_size;
7374
Aes *ctx;
7475
} srtp_aes_icm_ctx_t;
7576

0 commit comments

Comments
 (0)