Path: blob/master/dep/ffmpeg/include/libavutil/cast5.h
4216 views
/*1* An implementation of the CAST128 algorithm as mentioned in RFC21442* Copyright (c) 2014 Supraja Meedinti3*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_CAST5_H22#define AVUTIL_CAST5_H2324#include <stdint.h>252627/**28* @file29* @brief Public header for libavutil CAST5 algorithm30* @defgroup lavu_cast5 CAST531* @ingroup lavu_crypto32* @{33*/3435extern const int av_cast5_size;3637struct AVCAST5;3839/**40* Allocate an AVCAST5 context41* To free the struct: av_free(ptr)42*/43struct AVCAST5 *av_cast5_alloc(void);44/**45* Initialize an AVCAST5 context.46*47* @param ctx an AVCAST5 context48* @param key a key of 5,6,...16 bytes used for encryption/decryption49* @param key_bits number of keybits: possible are 40,48,...,12850* @return 0 on success, less than 0 on failure51*/52int av_cast5_init(struct AVCAST5 *ctx, const uint8_t *key, int key_bits);5354/**55* Encrypt or decrypt a buffer using a previously initialized context, ECB mode only56*57* @param ctx an AVCAST5 context58* @param dst destination array, can be equal to src59* @param src source array, can be equal to dst60* @param count number of 8 byte blocks61* @param decrypt 0 for encryption, 1 for decryption62*/63void av_cast5_crypt(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, int decrypt);6465/**66* Encrypt or decrypt a buffer using a previously initialized context67*68* @param ctx an AVCAST5 context69* @param dst destination array, can be equal to src70* @param src source array, can be equal to dst71* @param count number of 8 byte blocks72* @param iv initialization vector for CBC mode, NULL for ECB mode73* @param decrypt 0 for encryption, 1 for decryption74*/75void av_cast5_crypt2(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);76/**77* @}78*/79#endif /* AVUTIL_CAST5_H */808182