1 /* 2 * Blowfish algorithm 3 * Copyright (c) 2012 Samuel Pitoiset 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.blowfish; 22 23 extern (C) @nogc nothrow: 24 25 /** 26 * @defgroup lavu_blowfish Blowfish 27 * @ingroup lavu_crypto 28 * @{ 29 */ 30 31 enum AV_BF_ROUNDS = 16; 32 33 struct AVBlowfish 34 { 35 uint[18] p; 36 uint[256][4] s; 37 } 38 39 /** 40 * Allocate an AVBlowfish context. 41 */ 42 AVBlowfish* av_blowfish_alloc (); 43 44 /** 45 * Initialize an AVBlowfish context. 46 * 47 * @param ctx an AVBlowfish context 48 * @param key a key 49 * @param key_len length of the key 50 */ 51 void av_blowfish_init (AVBlowfish* ctx, const(ubyte)* key, int key_len); 52 53 /** 54 * Encrypt or decrypt a buffer using a previously initialized context. 55 * 56 * @param ctx an AVBlowfish context 57 * @param xl left four bytes halves of input to be encrypted 58 * @param xr right four bytes halves of input to be encrypted 59 * @param decrypt 0 for encryption, 1 for decryption 60 */ 61 void av_blowfish_crypt_ecb (AVBlowfish* ctx, uint* xl, uint* xr, int decrypt); 62 63 /** 64 * Encrypt or decrypt a buffer using a previously initialized context. 65 * 66 * @param ctx an AVBlowfish context 67 * @param dst destination array, can be equal to src 68 * @param src source array, can be equal to dst 69 * @param count number of 8 byte blocks 70 * @param iv initialization vector for CBC mode, if NULL ECB will be used 71 * @param decrypt 0 for encryption, 1 for decryption 72 */ 73 void av_blowfish_crypt ( 74 AVBlowfish* ctx, 75 ubyte* dst, 76 const(ubyte)* src, 77 int count, 78 ubyte* iv, 79 int decrypt); 80 81 /** 82 * @} 83 */ 84 85 /* AVUTIL_BLOWFISH_H */