Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / rsabase / tests / rsabase.c
blob1c14a47e79e196ae92568e00e39b78409a9da74e
1 /*
2 * Unit tests for rsabase functions
4 * Copyright (c) 2004 Michael Jung
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <string.h>
22 #include "wine/test.h"
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wincrypt.h"
28 HCRYPTPROV hProv;
29 static const char szContainer[] = "Wine Test Container";
30 static const char szProvider[] = MS_DEF_PROV_A;
32 static int init_environment(void)
34 hProv = (HCRYPTPROV)INVALID_HANDLE_VALUE;
36 if (!CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, 0))
38 if (GetLastError()==NTE_BAD_KEYSET)
40 if(!CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_NEWKEYSET))
42 trace("%08x\n", (unsigned int)GetLastError());
43 return 0;
46 else
48 trace("%08x\n", (unsigned int)GetLastError());
49 return 0;
53 return 1;
56 static void clean_up_environment(void)
58 CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
61 static void test_gen_random()
63 BOOL result;
64 BYTE rnd1[16], rnd2[16];
66 memset(rnd1, 0, sizeof(rnd1));
67 memset(rnd2, 0, sizeof(rnd2));
69 result = CryptGenRandom(hProv, sizeof(rnd1), rnd1);
70 ok(result, "%08x\n", (unsigned int)GetLastError());
72 result = CryptGenRandom(hProv, sizeof(rnd2), rnd2);
73 ok(result, "%08x\n", (unsigned int)GetLastError());
75 ok(memcmp(rnd1, rnd2, sizeof(rnd1)), "CryptGenRandom generates non random data\n");
78 START_TEST(rsabase)
80 if (!init_environment())
81 return;
82 test_gen_random();
83 clean_up_environment();