/* * Unit tests for rsaenh functions * * Copyright (c) 2004 Michael Jung * Copyright (c) 2006 Juan Lang * Copyright (c) 2007 Vijay Kiran Kamuju * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include "wine/test.h" #include "windef.h" #include "winbase.h" #include "winerror.h" #include "wincrypt.h" #include "winreg.h" static HCRYPTPROV hProv; static const char szContainer[] = "winetest"; static const char szProvider[] = MS_ENHANCED_PROV_A; typedef struct _ctdatatype { unsigned char origstr[32]; unsigned char decstr[32]; int strlen; int enclen; int buflen; } cryptdata; static const cryptdata cTestData[4] = { {"abcdefghijkl", {'a','b','c','d','e','f','g','h',0x2,0x2,'k','l',0}, 12,8,16}, {"abcdefghij", {'a','b','c','d','e','f','g','h',0x2,0x2,0}, 10,8,16}, {"abcdefgh", {'a','b','c','d','e','f','g','h',0}, 8,8,16}, {"abcdefghijkl", {'a','b','c','d','e','f','g','h','i','j','k','l',0}, 12,12,16} }; /* * 1. Take the MD5 Hash of the container name (with an extra null byte) * 2. Turn the hash into a 4 DWORD hex value * 3. Append a '_' * 4. Add the MachineGuid * */ static void uniquecontainer(char *unique) { /* MD5 hash of "winetest\0" in 4 DWORD hex */ static const char szContainer_md5[] = "9d20fd8d05ed2b8455d125d0bf6d6a70"; static const char szCryptography[] = "Software\\Microsoft\\Cryptography"; static const char szMachineGuid[] = "MachineGuid"; HKEY hkey; char guid[MAX_PATH]; DWORD size = MAX_PATH; HRESULT ret; /* Get the MachineGUID */ ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, szCryptography, 0, KEY_READ | KEY_WOW64_64KEY, &hkey); if (ret == ERROR_ACCESS_DENIED) { /* Windows 2000 can't handle KEY_WOW64_64KEY */ RegOpenKeyA(HKEY_LOCAL_MACHINE, szCryptography, &hkey); } RegQueryValueExA(hkey, szMachineGuid, NULL, NULL, (LPBYTE)guid, &size); RegCloseKey(hkey); lstrcpy(unique, szContainer_md5); lstrcat(unique, "_"); lstrcat(unique, guid); } static void printBytes(const char *heading, const BYTE *pb, size_t cb) { size_t i; printf("%s: ",heading); for(i=0;i