]> git.sesse.net Git - ffmpeg/commitdiff
des: add av_des_alloc()
authorJames Almer <jamrial@gmail.com>
Tue, 28 Jul 2015 19:57:49 +0000 (16:57 -0300)
committerAnton Khirnov <anton@khirnov.net>
Fri, 31 Jul 2015 07:04:12 +0000 (09:04 +0200)
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
doc/APIchanges
libavutil/des.c
libavutil/des.h

index cfab8c6d68bccd6fddffdb38234972ddde74e703..7a653994cdbe22c279af4bb505508b2da33065c5 100644 (file)
@@ -17,6 +17,7 @@ API changes, most recent first:
   xxxxxxx -  Add av_blowfish_alloc().
   xxxxxxx -  Add av_rc4_alloc().
   xxxxxxx -  Add av_xtea_alloc().
+  xxxxxxx -  Add av_des_alloc().
 
 2015-07-29 - 7e38340 - lavu 54.16.0 - hmac.h
   Add AV_HMAC_SHA224 and AV_HMAC_SHA256.
index ab0fc2f8bc9746af503642fd31dd73d0a914a92b..86d47129448c96d0a7b9525eafbecce16c039109 100644 (file)
 #include "avutil.h"
 #include "common.h"
 #include "intreadwrite.h"
+#include "mem.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
 static const uint8_t IP_shuffle[] = {
@@ -286,6 +292,11 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) {
     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, int decrypt) {
     if (key_bits != 64 && key_bits != 192)
         return -1;
index cda98122d31f32f0f1d76077ddf301265221a717..7b82340219537cf04b64350ded8d987ab218aec3 100644 (file)
 
 #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];
     int triple_des;
-};
+} AVDES;
+#else
+typedef struct AVDES AVDES;
+#endif
+
+/**
+ * Allocate an AVDES context.
+ */
+AVDES *av_des_alloc(void);
 
 /**
  * @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,
  */
 void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
 
+/**
+ * @}
+ */
+
 #endif /* AVUTIL_DES_H */