On Mon, 14 Jan 2013, Diego Biurrun wrote:

On Mon, Jan 14, 2013 at 08:12:41PM +0200, Martin Storsjö wrote:
This supports HMAC-MD5 and HMAC-SHA1 for now, other hashes are
simple to add.
---

.. nits as agreed to on IRC ..

--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2012-10-22

 API changes, most recent first:

+2013-01-xx - xxxxxxx - lavu 52.5.0 - hmac.h
+  Add AVHMAC

.

Updated locally

--- /dev/null
+++ b/libavutil/hmac.c
@@ -0,0 +1,135 @@
+
+#include <string.h>
+#include "hmac.h"

Leave an empty line between system and local headers.

Done

+struct AVHMAC *av_hmac_alloc(enum AVHMACType type)
+{
+    struct AVHMAC *c = av_mallocz(sizeof(*c));
+    if (!c)
+        return NULL;
+    switch (type) {
+    case AV_HMAC_MD5:
+        c->blocklen = 64;
+        c->hashlen = 16;
+        c->init = av_md5_init;
+        c->update = av_md5_update;
+        c->final = av_md5_final;
+        c->hash = av_md5_alloc();
+        break;
+    case AV_HMAC_SHA1:
+        c->blocklen = 64;
+        c->hashlen = 20;
+        c->init = sha1_init;
+        c->update = av_sha_update;
+        c->final = av_sha_final;
+        c->hash = av_sha_alloc();
+        break;

align

Done

+void av_hmac_free(struct AVHMAC *c)
+{
+    av_free(c->hash);
+    av_free(c);
+}

This assumes that c is not NULL, hmmm, most free()-type functions are
NULL-tolerant, so I'd expect this not to choke on NULL...

--- /dev/null
+++ b/libavutil/hmac.h
@@ -0,0 +1,44 @@
+
+#ifndef AVUTIL_HMAC_H
+#define AVUTIL_HMAC_H
+
+#endif

Please comment the #endif.

I already fixed the last two in the v2 of the patch I posted a few hours later.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to