globalplatform
testUtil.h
1 /*
2  * Copyright (c) 2005-2026, Karsten Ohme
3  * This file is part of GlobalPlatform.
4  *
5  * GlobalPlatform is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * GlobalPlatform is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with GlobalPlatform. If not, see <https://www.gnu.org/licenses/>.
17  *
18  * In addition, as a special exception, the copyright holders give
19  * permission to link the code of portions of this program with the
20  * OpenSSL library under certain conditions as described in each
21  * individual source file, and distribute linked combinations
22  * including the two.
23  * You must obey the GNU Lesser General Public License in all respects
24  * for all of the code used other than OpenSSL. If you modify
25  * file(s) with this exception, you may extend this exception to your
26  * version of the file(s), but you are not obligated to do so. If you
27  * do not wish to do so, delete this exception statement from your
28  * version.
29  */
30 #ifndef OPGP_TESTUTIL_H
31 #define OPGP_TESTUTIL_H
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 // MSVC does not the linker wrap flag to mock functions, it must be done in the code by using #pragma comment(linker, "/alternatename:real_foo=foo")
39 // https://stackoverflow.com/questions/33790425/visual-studio-c-linker-wrap-option
40 //#if _MSC_VER
41 //#define RAND_bytes real_RAND_bytes
42 //#include <openssl/rand.h>
43 //#undef RAND_bytes
44 //#pragma comment(linker, "/alternatename:real_RAND_bytes=RAND_bytes")
45 //#endif
46 
47 //#define RAND_bytes __wrap_RAND_bytes
48 
50 
51 void mock_setup();
52 
53 void hex_to_byte_array(OPGP_CSTRING hexString, PBYTE buffer, PDWORD bufferLength);
54 
55 int __wrap_RAND_bytes(unsigned char *buf, int num);
56 
57 OPGP_ERROR_STATUS send_APDU(OPGP_CARD_CONTEXT cardContext, OPGP_CARD_INFO cardInfo, PBYTE capdu, DWORD capduLength, PBYTE rapdu, PDWORD rapduLength);
58 
59 void enqueue_commands(OPGP_CSTRING *commands, OPGP_CSTRING *responses, int size);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif
Definition: connection.h:95
Definition: connection.h:106
Definition: error.h:58
unsigned char * PBYTE
A Microsoft/Muscle LPBYTE, pointer to unsigned char.
Definition: types.h:64
unsigned long * PDWORD
A Microsoft LPDWORD/Muscle pointer to a DWORD.
Definition: types.h:66
unsigned long DWORD
A Microsoft/Muscle DWORD definition.
Definition: types.h:68
const char * OPGP_CSTRING
A Microsoft/Muscle LPCTSTR.
Definition: types.h:63