1 /* 2 * DES encryption/decryption 3 * Copyright (c) 2007 Reimar Doeffinger 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 22 module ffmpeg.libavutil.des; 23 24 extern (C): 25 import ffmpeg; @nogc nothrow: 26 27 /** 28 * @defgroup lavu_des DES 29 * @ingroup lavu_crypto 30 * @{ 31 */ 32 33 struct AVDES 34 { 35 ulong[16][3] round_keys; 36 int triple_des; 37 } 38 39 /** 40 * Allocate an AVDES context. 41 */ 42 AVDES* av_des_alloc (); 43 44 /** 45 * @brief Initializes an AVDES context. 46 * 47 * @param key_bits must be 64 or 192 48 * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption 49 * @return zero on success, negative value otherwise 50 */ 51 int av_des_init (AVDES* d, const(ubyte)* key, int key_bits, int decrypt); 52 53 /** 54 * @brief Encrypts / decrypts using the DES algorithm. 55 * 56 * @param count number of 8 byte blocks 57 * @param dst destination array, can be equal to src, must be 8-byte aligned 58 * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL 59 * @param iv initialization vector for CBC mode, if NULL then ECB will be used, 60 * must be 8-byte aligned 61 * @param decrypt 0 for encryption, 1 for decryption 62 */ 63 void av_des_crypt (AVDES* d, ubyte* dst, const(ubyte)* src, int count, ubyte* iv, int decrypt); 64 65 /** 66 * @brief Calculates CBC-MAC using the DES algorithm. 67 * 68 * @param count number of 8 byte blocks 69 * @param dst destination array, can be equal to src, must be 8-byte aligned 70 * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL 71 */ 72 void av_des_mac (AVDES* d, ubyte* dst, const(ubyte)* src, int count); 73 74 /** 75 * @} 76 */ 77 78 /* AVUTIL_DES_H */