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