]> granicus.if.org Git - neomutt/commitdiff
fix docs for mutt_md5_toascii
authorRichard Russon <rich@flatcap.org>
Fri, 26 Jan 2018 02:13:12 +0000 (02:13 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 3 Feb 2018 13:29:06 +0000 (13:29 +0000)
mutt/md5.c
mutt/md5.h

index 335f9a118ee70489d90acb815e459140cc7297a0..6fddf0f99b044fbafc138426849645cdfa86775a 100644 (file)
  *
  * | Function                 | Description
  * | :----------------------- | :----------------------------------------------------
- * | mutt_md5_bytes()         | Calculate the MD5 hash of a buffer
  * | mutt_md5()               | Calculate the MD5 hash of a NULL-terminated string
+ * | mutt_md5_buf()           | Calculate the MD5 hash of a buffer
  * | mutt_md5_finish_ctx()    | Process the remaining bytes in the buffer
  * | mutt_md5_init_ctx()      | Initialise the MD5 computation
+ * | mutt_md5_process()       | Process a NULL-terminated string
  * | mutt_md5_process_block() | Process a block with MD5
  * | mutt_md5_process_bytes() | Process a block of data
- * | mutt_md5_process()       | Process a string
  * | mutt_md5_read_ctx()      | Read from the context into a buffer
- * | mutt_md5_toascii()       | Produce an ASCII MD5 digest from a buffer
- */
-
-/* md5.c - Functions to compute MD5 message digest of files or memory blocks
- * according to the definition of MD5 in RFC1321 from April 1992.
+ * | mutt_md5_toascii()       | Convert a binary MD5 digest into ASCII Hexadecimal
  */
 
 #include "config.h"
@@ -317,7 +313,7 @@ void *mutt_md5_finish_ctx(struct Md5Ctx *ctx, void *resbuf)
 }
 
 /**
- * mutt_md5 - Calculate the MD5 hash of a NULL-termianted string
+ * mutt_md5 - Calculate the MD5 hash of a NULL-terminated string
  * @param s      String to hash
  * @param resbuf Buffer for result
  */
@@ -437,10 +433,17 @@ void mutt_md5_process_bytes(const void *buffer, size_t len, struct Md5Ctx *ctx)
   }
 }
 
-void mutt_md5_toascii(const void *resbuf, char *digest)
+/**
+ * mutt_md5_toascii - Convert a binary MD5 digest into ASCII Hexadecimal
+ * @param digest Binary MD5 digest
+ * @param resbuf Buffer for the ASCII result
+ *
+ * @note refbuf must be at least 33 bytes long.
+ */
+void mutt_md5_toascii(const void *digest, char *resbuf)
 {
-  const unsigned char *c = resbuf;
-  sprintf(digest, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+  const unsigned char *c = digest;
+  sprintf(resbuf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
           c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10],
           c[11], c[12], c[13], c[14], c[15]);
 }
index 9b1752bc22dd253a77079fd784971e10f75e1a29..385645ba8d6bf1fd074113efe7a0f8db3384cc81 100644 (file)
@@ -51,6 +51,6 @@ void  mutt_md5_init_ctx     (struct Md5Ctx *ctx);
 void  mutt_md5_process      (const char *string,             struct Md5Ctx *ctx);
 void  mutt_md5_process_bytes(const void *buffer, size_t len, struct Md5Ctx *ctx);
 void *mutt_md5_finish_ctx   (struct Md5Ctx *ctx, void *resbuf);
-void  mutt_md5_toascii      (const void *resbuf, char *digest);
+void  mutt_md5_toascii      (const void *digest, char *resbuf);
 
 #endif /* _MUTT_MD5_H */