1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avutil/aes_ctr: simplify incrementing the counter

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-04-01 12:11:56 -03:00
parent fe73b84879
commit 3f30ae823e

View File

@@ -32,7 +32,7 @@
#define AES_BLOCK_SIZE (16) #define AES_BLOCK_SIZE (16)
typedef struct AVAESCTR { typedef struct AVAESCTR {
uint8_t counter[AES_BLOCK_SIZE]; DECLARE_ALIGNED(8, uint8_t, counter)[AES_BLOCK_SIZE];
DECLARE_ALIGNED(8, uint8_t, encrypted_counter)[AES_BLOCK_SIZE]; DECLARE_ALIGNED(8, uint8_t, encrypted_counter)[AES_BLOCK_SIZE];
AVAES aes; AVAES aes;
} AVAESCTR; } AVAESCTR;
@@ -82,16 +82,10 @@ void av_aes_ctr_free(struct AVAESCTR *a)
av_free(a); av_free(a);
} }
static void av_aes_ctr_increment_be64(uint8_t* counter) static inline void av_aes_ctr_increment_be64(uint8_t* counter)
{ {
uint8_t* cur_pos; uint64_t c = AV_RB64A(counter) + 1;
AV_WB64A(counter, c);
for (cur_pos = counter + 7; cur_pos >= counter; cur_pos--) {
(*cur_pos)++;
if (*cur_pos != 0) {
break;
}
}
} }
void av_aes_ctr_increment_iv(struct AVAESCTR *a) void av_aes_ctr_increment_iv(struct AVAESCTR *a)