* commit 'd9e8b47e3144262d6bc4681740411d4bdafad6ac': des: add av_des_alloc() Conflicts: libavutil/des.c
Unified · Split
| @@ -19,6 +19,7 @@ API changes, most recent first: · 18 unmodified lines | ||
| 19 | 19 | xxxxxxx - Add av_blowfish_alloc(). |
| 20 | 20 | xxxxxxx - Add av_rc4_alloc(). |
| 21 | 21 | xxxxxxx - Add av_xtea_alloc(). |
| 22 | + xxxxxxx - Add av_des_alloc(). | |
| 22 | 23 | |
| 23 | 24 | 2015-xx-xx - lavc 56.35.0 - avcodec.h |
| 24 | 25 | xxxxxxxxx - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. |
| @@ -22,9 +22,15 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "avutil.h" |
| 23 | 23 | #include "common.h" |
| 24 | 24 | #include "intreadwrite.h" |
| 25 | +#include "mem.h" | |
| 25 | 26 | #include "des.h" |
| 26 | 27 | |
| 27 | −typedef struct AVDES AVDES; | |
| 28 | +#if !FF_API_CRYPTO_CONTEXT | |
| 29 | +struct AVDES { | |
| 30 | + uint64_t round_keys[3][16]; | |
| 31 | + int triple_des; | |
| 32 | +}; | |
| 33 | +#endif | |
| 28 | 34 | |
| 29 | 35 | #define T(a, b, c, d, e, f, g, h) 64-a,64-b,64-c,64-d,64-e,64-f,64-g,64-h |
| 30 | 36 | static const uint8_t IP_shuffle[] = { |
| @@ -286,6 +292,11 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) { · 255 unmodified lines | ||
| 286 | 292 | return in; |
| 287 | 293 | } |
| 288 | 294 | |
| 295 | +AVDES *av_des_alloc(void) | |
| 296 | +{ | |
| 297 | + return av_mallocz(sizeof(struct AVDES)); | |
| 298 | +} | |
| 299 | + | |
| 289 | 300 | int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt) { |
| 290 | 301 | if (key_bits != 64 && key_bits != 192) |
| 291 | 302 | return -1; |
| @@ -24,10 +24,25 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | #include <stdint.h> |
| 26 | 26 | |
| 27 | −struct AVDES { | |
| 27 | +/** | |
| 28 | + * @defgroup lavu_des DES | |
| 29 | + * @ingroup lavu_crypto | |
| 30 | + * @{ | |
| 31 | + */ | |
| 32 | + | |
| 33 | +#if FF_API_CRYPTO_CONTEXT | |
| 34 | +typedef struct AVDES { | |
| 28 | 35 | uint64_t round_keys[3][16]; |
| 29 | 36 | int triple_des; |
| 30 | −}; | |
| 37 | +} AVDES; | |
| 38 | +#else | |
| 39 | +typedef struct AVDES AVDES; | |
| 40 | +#endif | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * Allocate an AVDES context. | |
| 44 | + */ | |
| 45 | +AVDES *av_des_alloc(void); | |
| 31 | 46 | |
| 32 | 47 | /** |
| 33 | 48 | * @brief Initializes an AVDES context. |
| @@ -58,4 +73,8 @@ void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, · 24 unmodified lines | ||
| 58 | 73 | */ |
| 59 | 74 | void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count); |
| 60 | 75 | |
| 76 | +/** | |
| 77 | + * @} | |
| 78 | + */ | |
| 79 | + | |
| 61 | 80 | #endif /* AVUTIL_DES_H */ |