su
1.12.11
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef SU_MD5_H 00026 #define SU_MD5_H 00027 00045 #ifndef SU_TYPES_H 00046 #include "sofia-sip/su_types.h" 00047 #endif 00048 00049 SOFIA_BEGIN_DECLS 00050 00052 typedef struct su_md5_t { 00053 uint32_t buf[4]; 00054 uint32_t bits[2]; 00055 uint8_t in[64]; 00056 } su_md5_t; 00057 00058 #define SU_MD5_DIGEST_SIZE 16 00059 00060 SOFIAPUBFUN void su_md5_init(su_md5_t *context); 00061 SOFIAPUBFUN void su_md5_deinit(su_md5_t *context); 00062 SOFIAPUBFUN void su_md5_update(su_md5_t *context, 00063 void const *buf, usize_t len); 00064 SOFIAPUBFUN void su_md5_strupdate(su_md5_t *ctx, char const *s); 00065 SOFIAPUBFUN void su_md5_str0update(su_md5_t *ctx, char const *s); 00066 00067 SOFIAPUBFUN void su_md5_iupdate(su_md5_t *context, 00068 void const *buf, usize_t len); 00069 SOFIAPUBFUN void su_md5_striupdate(su_md5_t *ctx, char const *s); 00070 SOFIAPUBFUN void su_md5_stri0update(su_md5_t *ctx, char const *s); 00071 00072 SOFIAPUBFUN void su_md5_digest(su_md5_t const *ctx, 00073 uint8_t digest[SU_MD5_DIGEST_SIZE]); 00074 SOFIAPUBFUN void su_md5_hexdigest(su_md5_t const *ctx, 00075 char digest[2 * SU_MD5_DIGEST_SIZE + 1]); 00076 00077 #define SU_MD5_STRUPDATE(ctx, s) \ 00078 ((s) ? su_md5_update(ctx, (s), strlen(s)) : (void)0) 00079 #define SU_MD5_STR0UPDATE(ctx, s) \ 00080 su_md5_update(ctx, (s) ? (s) : "", (s) ? strlen(s) + 1 : 1) 00081 #define SU_MD5_STRIUPDATE(ctx, s) \ 00082 ((s) ? su_md5_iupdate(ctx, (s), strlen(s)) : (void)0) 00083 #define SU_MD5_STRI0UPDATE(ctx, s) \ 00084 su_md5_iupdate(ctx, (s) ? (s) : "", (s) ? strlen(s) : 1) 00085 00086 SOFIA_END_DECLS 00087 00088 #endif /* !defined(MD5_H) */