su  1.12.11devel
 All Data Structures Files Functions Variables Typedefs Enumerator Macros Groups Pages
su_md5.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SU_MD5_H
26 #define SU_MD5_H
27 
45 #ifndef SU_TYPES_H
46 #include "sofia-sip/su_types.h"
47 #endif
48 
49 SOFIA_BEGIN_DECLS
50 
52 typedef struct su_md5_t {
53  uint32_t buf[4];
54  uint32_t bits[2];
55  uint8_t in[64];
56 } su_md5_t;
57 
58 #define SU_MD5_DIGEST_SIZE 16
59 
60 SOFIAPUBFUN void su_md5_init(su_md5_t *context);
61 SOFIAPUBFUN void su_md5_deinit(su_md5_t *context);
62 SOFIAPUBFUN void su_md5_update(su_md5_t *context,
63  void const *buf, usize_t len);
64 SOFIAPUBFUN void su_md5_strupdate(su_md5_t *ctx, char const *s);
65 SOFIAPUBFUN void su_md5_str0update(su_md5_t *ctx, char const *s);
66 
67 SOFIAPUBFUN void su_md5_iupdate(su_md5_t *context,
68  void const *buf, usize_t len);
69 SOFIAPUBFUN void su_md5_striupdate(su_md5_t *ctx, char const *s);
70 SOFIAPUBFUN void su_md5_stri0update(su_md5_t *ctx, char const *s);
71 
72 SOFIAPUBFUN void su_md5_digest(su_md5_t const *ctx,
73  uint8_t digest[SU_MD5_DIGEST_SIZE]);
74 SOFIAPUBFUN void su_md5_hexdigest(su_md5_t const *ctx,
75  char digest[2 * SU_MD5_DIGEST_SIZE + 1]);
76 
77 #define SU_MD5_STRUPDATE(ctx, s) \
78  ((s) ? su_md5_update(ctx, (s), strlen(s)) : (void)0)
79 #define SU_MD5_STR0UPDATE(ctx, s) \
80  su_md5_update(ctx, (s) ? (s) : "", (s) ? strlen(s) + 1 : 1)
81 #define SU_MD5_STRIUPDATE(ctx, s) \
82  ((s) ? su_md5_iupdate(ctx, (s), strlen(s)) : (void)0)
83 #define SU_MD5_STRI0UPDATE(ctx, s) \
84  su_md5_iupdate(ctx, (s) ? (s) : "", (s) ? strlen(s) : 1)
85 
86 SOFIA_END_DECLS
87 
88 #endif /* !defined(MD5_H) */

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.