mail-notification

Fork of Jean-Yves Lefort's mail-notification, a tray icon to notify of new mail
git clone https://code.djc.id.au/git/mail-notification/

src/mn-md5.h (2717B) - raw

      1 /*
      2  * MD5 message digest implementation, taken from glibc and edited for
      3  * style.
      4  *
      5  * The GNU C Library,
      6  * Copyright (C) 1995,1996,1997,1999,2000,2001,2005
      7  * Free Software Foundation, Inc.
      8  *
      9  * Mail Notification
     10  * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be>
     11  *
     12  * This program is free software; you can redistribute it and/or modify
     13  * it under the terms of the GNU General Public License as published by
     14  * the Free Software Foundation; either version 3 of the License, or
     15  * (at your option) any later version.
     16  *
     17  * This program is distributed in the hope that it will be useful,
     18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20  * GNU General Public License for more details.
     21  *
     22  * You should have received a copy of the GNU General Public License along
     23  * with this program; if not, write to the Free Software Foundation, Inc.,
     24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     25  */
     26 
     27 #ifndef _MN_MD5_H
     28 #define _MN_MD5_H
     29 
     30 #include <stdint.h>
     31 
     32 typedef struct
     33 {
     34   uint32_t A;
     35   uint32_t B;
     36   uint32_t C;
     37   uint32_t D;
     38 
     39   uint32_t total[2];
     40   uint32_t buflen;
     41   char buffer[128]
     42 #ifdef __GNUC__
     43   __attribute__ ((__aligned__ (__alignof__ (uint32_t))))
     44 #endif
     45     ;
     46 } MNMD5Context;
     47 
     48 /* Initialize structure containing state of computation.
     49    (RFC 1321, 3.3: Step 3)  */
     50 void mn_md5_init_ctx (MNMD5Context *ctx);
     51 
     52 /* Starting with the result of former calls of this function (or the
     53    initialization function update the context for the next LEN bytes
     54    starting at BUFFER.
     55    It is necessary that LEN is a multiple of 64!!! */
     56 void mn_md5_process_block (MNMD5Context *ctx, const void *buffer, size_t len);
     57 
     58 /* Starting with the result of former calls of this function (or the
     59    initialization function update the context for the next LEN bytes
     60    starting at BUFFER.
     61    It is NOT required that LEN is a multiple of 64.  */
     62 void mn_md5_process_bytes (MNMD5Context *ctx, const void *buffer, size_t len);
     63 
     64 /* Process the remaining bytes in the buffer and put result from CTX
     65    in first 16 bytes following RESBUF.  The result is always in little
     66    endian byte order, so that a byte-wise output yields to the wanted
     67    ASCII representation of the message digest.
     68 
     69    IMPORTANT: On some systems it is required that RESBUF is correctly
     70    aligned for a 32 bits value.  */
     71 void *mn_md5_finish_ctx (MNMD5Context *ctx, unsigned char resbuf[16]);
     72 
     73 /*
     74  * Stores the nul-terminated hexadecimal representation of @resbuf
     75  * (which must be the result buffer filled in by mn_md5_finish_ctx())
     76  * into @hexbuf.
     77  */
     78 void mn_md5_to_hex (const unsigned char resbuf[16], char hexbuf[33]);
     79 
     80 #endif /* _MN_MD5_H */