LibVNCServer/LibVNCClient
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rfbcrypto_included.c
Go to the documentation of this file.
1 /*
2  * rfbcrypto_included.c - Crypto wrapper (included version)
3  */
4 
5 /*
6  * Copyright (C) 2011 Gernot Tenchio
7  *
8  * This is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This software is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this software; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21  * USA.
22  */
23 
24 #include <string.h>
25 #include "md5.h"
26 #include "sha1.h"
27 #include "rfbcrypto.h"
28 
29 void digestmd5(const struct iovec *iov, int iovcnt, void *dest)
30 {
31  struct md5_ctx c;
32  int i;
33 
34  __md5_init_ctx(&c);
35  for (i = 0; i < iovcnt; i++)
36  __md5_process_bytes(iov[i].iov_base, iov[i].iov_len, &c);
37  __md5_finish_ctx(&c, dest);
38 }
39 
40 void digestsha1(const struct iovec *iov, int iovcnt, void *dest)
41 {
42  SHA1Context c;
43  int i;
44 
45  SHA1Reset(&c);
46  for (i = 0; i < iovcnt; i++)
47  SHA1Input(&c, iov[i].iov_base, iov[i].iov_len);
48  SHA1Result(&c, dest);
49 }