Path: blob/master/dep/ffmpeg/include/libavutil/aes_ctr.h
4216 views
/*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/**25* @defgroup lavu_aes_ctr AES-CTR26* @ingroup lavu_crypto27* @{28*/2930#include <stdint.h>3132#include "attributes.h"3334#define AES_CTR_KEY_SIZE (16)35#define AES_CTR_IV_SIZE (8)3637struct AVAESCTR;3839/**40* Allocate an AVAESCTR context.41*/42struct AVAESCTR *av_aes_ctr_alloc(void);4344/**45* Initialize an AVAESCTR context.46*47* @param a The AVAESCTR context to initialize48* @param key encryption key, must have a length of AES_CTR_KEY_SIZE49*/50int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);5152/**53* Release an AVAESCTR context.54*55* @param a The AVAESCTR context56*/57void av_aes_ctr_free(struct AVAESCTR *a);5859/**60* Process a buffer using a previously initialized context.61*62* @param a The AVAESCTR context63* @param dst destination array, can be equal to src64* @param src source array, can be equal to dst65* @param size the size of src and dst66*/67void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size);6869/**70* Get the current iv71*/72const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);7374/**75* Generate a random iv76*/77void av_aes_ctr_set_random_iv(struct AVAESCTR *a);7879/**80* Forcefully change the 8-byte iv81*/82void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);8384/**85* Forcefully change the "full" 16-byte iv, including the counter86*/87void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv);8889/**90* Increment the top 64 bit of the iv (performed after each frame)91*/92void av_aes_ctr_increment_iv(struct AVAESCTR *a);9394/**95* @}96*/9798#endif /* AVUTIL_AES_CTR_H */99100101