Path: blob/master/dep/ffmpeg/include/libavutil/blowfish.h
4216 views
/*1* Blowfish algorithm2* Copyright (c) 2012 Samuel Pitoiset3*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_BLOWFISH_H22#define AVUTIL_BLOWFISH_H2324#include <stdint.h>2526/**27* @defgroup lavu_blowfish Blowfish28* @ingroup lavu_crypto29* @{30*/3132#define AV_BF_ROUNDS 163334typedef struct AVBlowfish {35uint32_t p[AV_BF_ROUNDS + 2];36uint32_t s[4][256];37} AVBlowfish;3839/**40* Allocate an AVBlowfish context.41*/42AVBlowfish *av_blowfish_alloc(void);4344/**45* Initialize an AVBlowfish context.46*47* @param ctx an AVBlowfish context48* @param key a key49* @param key_len length of the key50*/51void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);5253/**54* Encrypt or decrypt a buffer using a previously initialized context.55*56* @param ctx an AVBlowfish context57* @param xl left four bytes halves of input to be encrypted58* @param xr right four bytes halves of input to be encrypted59* @param decrypt 0 for encryption, 1 for decryption60*/61void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,62int decrypt);6364/**65* Encrypt or decrypt a buffer using a previously initialized context.66*67* @param ctx an AVBlowfish context68* @param dst destination array, can be equal to src69* @param src source array, can be equal to dst70* @param count number of 8 byte blocks71* @param iv initialization vector for CBC mode, if NULL ECB will be used72* @param decrypt 0 for encryption, 1 for decryption73*/74void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,75int count, uint8_t *iv, int decrypt);7677/**78* @}79*/8081#endif /* AVUTIL_BLOWFISH_H */828384