Commit 3cf08e96 authored by Hendrik Leppkes's avatar Hendrik Leppkes

Merge commit 'd9e8b47e'

* commit 'd9e8b47e':
  des: add av_des_alloc()

Conflicts:
	libavutil/des.c
Merged-by: 's avatarHendrik Leppkes <h.leppkes@gmail.com>
parents 9ca19971 d9e8b47e
...@@ -19,6 +19,7 @@ API changes, most recent first: ...@@ -19,6 +19,7 @@ API changes, most recent first:
xxxxxxx - Add av_blowfish_alloc(). xxxxxxx - Add av_blowfish_alloc().
xxxxxxx - Add av_rc4_alloc(). xxxxxxx - Add av_rc4_alloc().
xxxxxxx - Add av_xtea_alloc(). xxxxxxx - Add av_xtea_alloc().
xxxxxxx - Add av_des_alloc().
2015-xx-xx - lavc 56.35.0 - avcodec.h 2015-xx-xx - lavc 56.35.0 - avcodec.h
xxxxxxxxx - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. xxxxxxxxx - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*.
......
...@@ -22,9 +22,15 @@ ...@@ -22,9 +22,15 @@
#include "avutil.h" #include "avutil.h"
#include "common.h" #include "common.h"
#include "intreadwrite.h" #include "intreadwrite.h"
#include "mem.h"
#include "des.h" #include "des.h"
typedef struct AVDES AVDES; #if !FF_API_CRYPTO_CONTEXT
struct AVDES {
uint64_t round_keys[3][16];
int triple_des;
};
#endif
#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 #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
static const uint8_t IP_shuffle[] = { static const uint8_t IP_shuffle[] = {
...@@ -286,6 +292,11 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) { ...@@ -286,6 +292,11 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) {
return in; return in;
} }
AVDES *av_des_alloc(void)
{
return av_mallocz(sizeof(struct AVDES));
}
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt) { int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt) {
if (key_bits != 64 && key_bits != 192) if (key_bits != 64 && key_bits != 192)
return -1; return -1;
......
...@@ -24,10 +24,25 @@ ...@@ -24,10 +24,25 @@
#include <stdint.h> #include <stdint.h>
struct AVDES { /**
* @defgroup lavu_des DES
* @ingroup lavu_crypto
* @{
*/
#if FF_API_CRYPTO_CONTEXT
typedef struct AVDES {
uint64_t round_keys[3][16]; uint64_t round_keys[3][16];
int triple_des; int triple_des;
}; } AVDES;
#else
typedef struct AVDES AVDES;
#endif
/**
* Allocate an AVDES context.
*/
AVDES *av_des_alloc(void);
/** /**
* @brief Initializes an AVDES context. * @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, ...@@ -58,4 +73,8 @@ void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count,
*/ */
void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count); void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
/**
* @}
*/
#endif /* AVUTIL_DES_H */ #endif /* AVUTIL_DES_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment