Tizen 2.0 Release
[external/libgnutls26.git] / tests / openssl.c
1 /*
2  * Copyright (C) 2004, 2005, 2008, 2009, 2010 Free Software Foundation,
3  * Inc.
4  *
5  * Author: Simon Josefsson
6  *
7  * This file is part of GnuTLS.
8  *
9  * GnuTLS is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * GnuTLS is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GnuTLS; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <stdio.h>
29
30 #include "utils.h"
31
32 #include <gnutls/openssl.h>
33
34 void
35 doit (void)
36 {
37   MD5_CTX c;
38   unsigned char md[MD5_DIGEST_LENGTH];
39
40   if (gnutls_global_init () != 0)
41     fail ("gnutls_global_init\n");
42
43   if (!gnutls_check_version (GNUTLS_VERSION))
44     success ("gnutls_check_version ERROR\n");
45
46   MD5_Init (&c);
47   MD5_Update (&c, "abc", 3);
48   MD5_Final (&(md[0]), &c);
49
50   if (memcmp (md, "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
51               "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72", sizeof (md)) != 0)
52     {
53       hexprint (md, sizeof (md));
54       fail ("MD5 failure\n");
55     }
56   else if (debug)
57     success ("MD5 OK\n");
58 }