diff options
author | Jacob Trimble | 2018-01-08 14:12:43 -0800 |
---|---|---|
committer | Michael Niedermayer | 2018-01-23 21:48:31 +0100 |
commit | 9f07cf7c00f3a87669c27aec947daf0f3d33b01f (patch) | |
tree | 313b8091795c0299baec9c8412838af60b799931 /libavutil | |
parent | 9b1ec248350405e1da64eecad620a8d7a4ee6caa (diff) |
avutil/aes_ctr: Add method to set 16-byte IV.
Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/aes_ctr.c | 6 | ||||
-rw-r--r-- | libavutil/aes_ctr.h | 7 | ||||
-rw-r--r-- | libavutil/tests/aes_ctr.c | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/libavutil/aes_ctr.c b/libavutil/aes_ctr.c index e9c568fe0d..0c2e86785f 100644 --- a/libavutil/aes_ctr.c +++ b/libavutil/aes_ctr.c @@ -45,6 +45,12 @@ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv) a->block_offset = 0; } +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv) +{ + memcpy(a->counter, iv, sizeof(a->counter)); + a->block_offset = 0; +} + const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a) { return a->counter; diff --git a/libavutil/aes_ctr.h b/libavutil/aes_ctr.h index f596fa6a46..e4aae126a7 100644 --- a/libavutil/aes_ctr.h +++ b/libavutil/aes_ctr.h @@ -67,11 +67,16 @@ const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a); void av_aes_ctr_set_random_iv(struct AVAESCTR *a); /** - * Forcefully change the iv + * Forcefully change the 8-byte iv */ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv); /** + * Forcefully change the "full" 16-byte iv, including the counter + */ +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv); + +/** * Increment the top 64 bit of the iv (performed after each frame) */ void av_aes_ctr_increment_iv(struct AVAESCTR *a); diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c index c5ebeda7ac..00fdb05d13 100644 --- a/libavutil/tests/aes_ctr.c +++ b/libavutil/tests/aes_ctr.c @@ -45,7 +45,7 @@ int main (void) av_aes_ctr_set_random_iv(ae); iv = av_aes_ctr_get_iv(ae); - av_aes_ctr_set_iv(ad, iv); + av_aes_ctr_set_full_iv(ad, iv); av_aes_ctr_crypt(ae, tmp, plain, sizeof(tmp)); av_aes_ctr_crypt(ad, tmp, tmp, sizeof(tmp)); |