Home | History | Annotate | Download | only in libvncserver
      1 /*
      2  * rfbcrypto_openssl.c - Crypto wrapper (openssl 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 <openssl/sha.h>
     26 #include <openssl/md5.h>
     27 #include "rfbcrypto.h"
     28 
     29 void digestmd5(const struct iovec *iov, int iovcnt, void *dest)
     30 {
     31     MD5_CTX c;
     32     int i;
     33 
     34     MD5_Init(&c);
     35     for (i = 0; i < iovcnt; i++)
     36 	MD5_Update(&c, iov[i].iov_base, iov[i].iov_len);
     37     MD5_Final(dest, &c);
     38 }
     39 
     40 void digestsha1(const struct iovec *iov, int iovcnt, void *dest)
     41 {
     42     SHA_CTX c;
     43     int i;
     44 
     45     SHA1_Init(&c);
     46     for (i = 0; i < iovcnt; i++)
     47 	SHA1_Update(&c, iov[i].iov_base, iov[i].iov_len);
     48     SHA1_Final(dest, &c);
     49 }
     50