annotate lib/libavutil/blowfish.h @ 2544:c674d547cc7c

GUIWindow switch logic refactored into behaviour classes
author a.parshin
date Mon, 11 May 2015 09:51:04 +0200
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 * Blowfish algorithm
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 * Copyright (c) 2012 Samuel Pitoiset
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 #ifndef AVUTIL_BLOWFISH_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23 #define AVUTIL_BLOWFISH_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 #include <stdint.h>
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 * @defgroup lavu_blowfish Blowfish
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29 * @ingroup lavu_crypto
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 #define AV_BF_ROUNDS 16
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 typedef struct AVBlowfish {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 uint32_t p[AV_BF_ROUNDS + 2];
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 uint32_t s[4][256];
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 } AVBlowfish;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 * Initialize an AVBlowfish context.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * @param ctx an AVBlowfish context
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 * @param key a key
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * @param key_len length of the key
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 * Encrypt or decrypt a buffer using a previously initialized context.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 * @param ctx an AVBlowfish context
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * @param xl left four bytes halves of input to be encrypted
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 * @param xr right four bytes halves of input to be encrypted
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 * @param decrypt 0 for encryption, 1 for decryption
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 int decrypt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 * Encrypt or decrypt a buffer using a previously initialized context.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 * @param ctx an AVBlowfish context
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 * @param dst destination array, can be equal to src
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 * @param src source array, can be equal to dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 * @param count number of 8 byte blocks
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 * @param iv initialization vector for CBC mode, if NULL ECB will be used
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 * @param decrypt 0 for encryption, 1 for decryption
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 int count, uint8_t *iv, int decrypt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77 #endif /* AVUTIL_BLOWFISH_H */