Path: blob/master/dep/ffmpeg/include/libavutil/des.h
4216 views
/*1* DES encryption/decryption2* Copyright (c) 2007 Reimar Doeffinger3*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_DES_H22#define AVUTIL_DES_H2324#include <stdint.h>2526/**27* @defgroup lavu_des DES28* @ingroup lavu_crypto29* @{30*/3132typedef struct AVDES {33uint64_t round_keys[3][16];34int triple_des;35} AVDES;3637/**38* Allocate an AVDES context.39*/40AVDES *av_des_alloc(void);4142/**43* @brief Initializes an AVDES context.44*45* @param d pointer to a AVDES structure to initialize46* @param key pointer to the key to use47* @param key_bits must be 64 or 19248* @param decrypt 0 for encryption/CBC-MAC, 1 for decryption49* @return zero on success, negative value otherwise50*/51int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);5253/**54* @brief Encrypts / decrypts using the DES algorithm.55*56* @param d pointer to the AVDES structure57* @param dst destination array, can be equal to src, must be 8-byte aligned58* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL59* @param count number of 8 byte blocks60* @param iv initialization vector for CBC mode, if NULL then ECB will be used,61* must be 8-byte aligned62* @param decrypt 0 for encryption, 1 for decryption63*/64void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);6566/**67* @brief Calculates CBC-MAC using the DES algorithm.68*69* @param d pointer to the AVDES structure70* @param dst destination array, can be equal to src, must be 8-byte aligned71* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL72* @param count number of 8 byte blocks73*/74void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);7576/**77* @}78*/7980#endif /* AVUTIL_DES_H */818283