]> git.sesse.net Git - ffmpeg/commitdiff
avutil/aes_ctr: Add method to set 16-byte IV.
authorJacob Trimble <modmaker-at-google.com@ffmpeg.org>
Mon, 8 Jan 2018 22:12:43 +0000 (14:12 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 23 Jan 2018 20:48:31 +0000 (21:48 +0100)
Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
doc/APIchanges
libavutil/aes_ctr.c
libavutil/aes_ctr.h
libavutil/tests/aes_ctr.c

index 76993658794e5cf128ae445bf592a8d77d540ac3..c27f104c951c08bd299d885a0f363f44f971712e 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xxxxxxx - lavu 56.9.100 - aes_ctr.h
+  Add method to set the 16-byte IV.
+
 2018-01-xx - xxxxxxx - lavf 58.5.100 - avformat.h
   Explicitly make avformat_network_init() and avformat_network_deinit() optional.
   If these are not called, network initialization and deinitialization is
index e9c568fe0d13dd569ca151c29d7b97503cbd05ef..0c2e86785f1bbbd67b9205a93e51c7f8e5f57628 100644 (file)
@@ -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;
index f596fa6a46bac698aca25ebb1967e96fe22c549b..e4aae126a764be2b7bbf8f4106a3990344db1a5a 100644 (file)
@@ -67,10 +67,15 @@ 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)
  */
index c5ebeda7ac2095ff69d3dcd309c8d57371861101..00fdb05d13a01a91a6a3cf1ecb5cf77cb012db06 100644 (file)
@@ -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));