/*1* AES-CTR cipher2* Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com>3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021#ifndef AVUTIL_AES_CTR_H22#define AVUTIL_AES_CTR_H2324#include <stdint.h>2526#include "attributes.h"27#include "version.h"2829#define AES_CTR_KEY_SIZE (16)30#define AES_CTR_IV_SIZE (8)3132struct AVAESCTR;3334/**35* Allocate an AVAESCTR context.36*/37struct AVAESCTR *av_aes_ctr_alloc(void);3839/**40* Initialize an AVAESCTR context.41* @param key encryption key, must have a length of AES_CTR_KEY_SIZE42*/43int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);4445/**46* Release an AVAESCTR context.47*/48void av_aes_ctr_free(struct AVAESCTR *a);4950/**51* Process a buffer using a previously initialized context.52* @param dst destination array, can be equal to src53* @param src source array, can be equal to dst54* @param size the size of src and dst55*/56void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size);5758/**59* Get the current iv60*/61const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);6263/**64* Generate a random iv65*/66void av_aes_ctr_set_random_iv(struct AVAESCTR *a);6768/**69* Forcefully change the iv70*/71void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);7273/**74* Increment the top 64 bit of the iv (performed after each frame)75*/76void av_aes_ctr_increment_iv(struct AVAESCTR *a);7778/**79* @}80*/8182#endif /* AVUTIL_AES_CTR_H */838485