1 /* 2 * AES-CTR cipher 3 * Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com> 4 * 5 * This file is part of FFmpeg. 6 * 7 * FFmpeg is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * FFmpeg is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with FFmpeg; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 module ffmpeg.libavutil.aes_ctr; 22 23 extern (C) @nogc nothrow: 24 25 enum AES_CTR_KEY_SIZE = 16; 26 enum AES_CTR_IV_SIZE = 8; 27 28 struct AVAESCTR; 29 30 /** 31 * Allocate an AVAESCTR context. 32 */ 33 AVAESCTR* av_aes_ctr_alloc (); 34 35 /** 36 * Initialize an AVAESCTR context. 37 * @param key encryption key, must have a length of AES_CTR_KEY_SIZE 38 */ 39 int av_aes_ctr_init (AVAESCTR* a, const(ubyte)* key); 40 41 /** 42 * Release an AVAESCTR context. 43 */ 44 void av_aes_ctr_free (AVAESCTR* a); 45 46 /** 47 * Process a buffer using a previously initialized context. 48 * @param dst destination array, can be equal to src 49 * @param src source array, can be equal to dst 50 * @param size the size of src and dst 51 */ 52 void av_aes_ctr_crypt (AVAESCTR* a, ubyte* dst, const(ubyte)* src, int size); 53 54 /** 55 * Get the current iv 56 */ 57 const(ubyte)* av_aes_ctr_get_iv (AVAESCTR* a); 58 59 /** 60 * Generate a random iv 61 */ 62 void av_aes_ctr_set_random_iv (AVAESCTR* a); 63 64 /** 65 * Forcefully change the 8-byte iv 66 */ 67 void av_aes_ctr_set_iv (AVAESCTR* a, const(ubyte)* iv); 68 69 /** 70 * Forcefully change the "full" 16-byte iv, including the counter 71 */ 72 void av_aes_ctr_set_full_iv (AVAESCTR* a, const(ubyte)* iv); 73 74 /** 75 * Increment the top 64 bit of the iv (performed after each frame) 76 */ 77 void av_aes_ctr_increment_iv (AVAESCTR* a); 78 79 /** 80 * @} 81 */ 82 83 /* AVUTIL_AES_CTR_H */