LibVNCServer/LibVNCClient
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rfbcrypto_gnutls.c
Go to the documentation of this file.
1 /*
2  * rfbcrypto_gnutls.c - Crypto wrapper (gnutls 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 <gcrypt.h>
26 #include "rfbcrypto.h"
27 
28 void digestmd5(const struct iovec *iov, int iovcnt, void *dest)
29 {
30  gcry_md_hd_t c;
31  int i;
32 
33  gcry_md_open(&c, GCRY_MD_MD5, 0);
34  for (i = 0; i < iovcnt; i++)
35  gcry_md_write(c, iov[i].iov_base, iov[i].iov_len);
36  gcry_md_final(c);
37  memcpy(dest, gcry_md_read(c, 0), gcry_md_get_algo_dlen(GCRY_MD_MD5));
38 }
39 
40 void digestsha1(const struct iovec *iov, int iovcnt, void *dest)
41 {
42  gcry_md_hd_t c;
43  int i;
44 
45  gcry_md_open(&c, GCRY_MD_SHA1, 0);
46  for (i = 0; i < iovcnt; i++)
47  gcry_md_write(c, iov[i].iov_base, iov[i].iov_len);
48  gcry_md_final(c);
49  memcpy(dest, gcry_md_read(c, 0), gcry_md_get_algo_dlen(GCRY_MD_SHA1));
50 }