aboutsummaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer2015-07-28 16:57:47 -0300
committerAnton Khirnov2015-07-31 09:04:12 +0200
commitae365453c370c85f278bff7fbf9e20d9d335cb2a (patch)
tree22259fce9a541f6a846b5bbdb12dae04b70ddb4c /libavutil
parent7a7df34c91e16ea8936f59524145a2cdd6b790f9 (diff)
rc4: add av_rc4_alloc()
Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/rc4.c13
-rw-r--r--libavutil/rc4.h24
2 files changed, 34 insertions, 3 deletions
diff --git a/libavutil/rc4.c b/libavutil/rc4.c
index 3bf710f3f1..36b0de9f53 100644
--- a/libavutil/rc4.c
+++ b/libavutil/rc4.c
@@ -22,9 +22,20 @@
*/
#include "avutil.h"
#include "common.h"
+#include "mem.h"
#include "rc4.h"
-typedef struct AVRC4 AVRC4;
+#if !FF_API_CRYPTO_CONTEXT
+struct AVRC4 {
+ uint8_t state[256];
+ int x, y;
+};
+#endif
+
+AVRC4 *av_rc4_alloc(void)
+{
+ return av_mallocz(sizeof(struct AVRC4));
+}
int av_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt) {
int i, j;
diff --git a/libavutil/rc4.h b/libavutil/rc4.h
index ec3b47cc8a..f6d2d44504 100644
--- a/libavutil/rc4.h
+++ b/libavutil/rc4.h
@@ -22,11 +22,27 @@
#define AVUTIL_RC4_H
#include <stdint.h>
+#include "version.h"
-struct AVRC4 {
+/**
+ * @defgroup lavu_rc4 RC4
+ * @ingroup lavu_crypto
+ * @{
+ */
+
+#if FF_API_CRYPTO_CONTEXT
+typedef struct AVRC4 {
uint8_t state[256];
int x, y;
-};
+} AVRC4;
+#else
+typedef struct AVRC4 AVRC4;
+#endif
+
+/**
+ * Allocate an AVRC4 context.
+ */
+AVRC4 *av_rc4_alloc(void);
/**
* @brief Initializes an AVRC4 context.
@@ -47,4 +63,8 @@ int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt);
*/
void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
+/**
+ * @}
+ */
+
#endif /* AVUTIL_RC4_H */