forked from arnaudmorin/libgtop11dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MiniDriverContainerMapFile.hpp
128 lines (79 loc) · 4.7 KB
/
MiniDriverContainerMapFile.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* PKCS#11 library for .Net smart cards
* Copyright (C) 2007-2009 Gemalto <[email protected]>
*
* 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
*
*/
#ifndef __GEMALTO_MINIDRIVER_CONTAINER_MAP_FILE__
#define __GEMALTO_MINIDRIVER_CONTAINER_MAP_FILE__
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/array.hpp>
#include <boost/array.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
#include "Log.hpp"
#include "Array.hpp"
#include "CardModuleService.hpp"
#include "MiniDriverContainer.hpp"
const int g_MaxContainer = 15;
class MiniDriverFiles;
/*
*/
class MiniDriverContainerMapFile {
public:
static unsigned char CONTAINER_INDEX_INVALID;
typedef boost::array< MiniDriverContainer, g_MaxContainer > ARRAY_CONTAINERS;
MiniDriverContainerMapFile( ) { }
inline void setMiniDriverFiles( MiniDriverFiles* p ) { m_MiniDriverFiles = p; }
void clear( void );
void containerDelete( const unsigned char& );
inline const MiniDriverContainer& containerGet( const unsigned char& a_ucContainerIndex ) { if( a_ucContainerIndex > m_Containers.size( ) ) { throw MiniDriverException( ); } return m_Containers[ a_ucContainerIndex ]; }
void containerSearch( unsigned char& );
inline const ARRAY_CONTAINERS& containerGet( void ) { return m_Containers; }
void containerRead( void );
void containerCreate( unsigned char&, const bool&, unsigned char&, Marshaller::u1Array*, const int&, Marshaller::u1Array* );
void containerSetDefault( const unsigned char&, const bool& );
bool containerGetMatching( unsigned char& a_ucContainerIndex, unsigned char& a_ucKeySpec, const Marshaller::u1Array* a_pPublicKeyModulus );
inline unsigned char containerCount( void ) { return (unsigned char)m_Containers.size( ); }
inline void containerSetTypeForSignatureKey( const unsigned char& a_ucContainerIndex, const unsigned char& a_ContainerTypeForSignatureKey ) { m_Containers[ a_ucContainerIndex ].setContainerTypeForSignatureKey( a_ContainerTypeForSignatureKey ); }
inline void containerSetTypeForExchangeKey( const unsigned char& a_ucContainerIndex, const unsigned char& a_ContainerTypeForExchangeKey ) { m_Containers[ a_ucContainerIndex ].setContainerTypeForExchangeKey( a_ContainerTypeForExchangeKey ); }
inline void containerSetPinIdentifier( const unsigned char& a_ucContainerIndex, const MiniDriverAuthentication::ROLES& a_ContainerPinIdentifier ) { m_Containers[ a_ucContainerIndex ].setPinIdentifier( a_ContainerPinIdentifier ); }
inline bool containerIsImportedSignatureKey( const unsigned char& a_ucContainerIndex ) { return m_Containers[ a_ucContainerIndex ].isImportedSignatureKey( ); }
inline bool containerIsImportedExchangeKey( const unsigned char& a_ucContainerIndex ) { return m_Containers[ a_ucContainerIndex ].isImportedExchangeKey( ); }
inline MiniDriverAuthentication::ROLES containerGetPinIdentifier( const unsigned char& a_ucContainerIndex ) { return m_Containers[ a_ucContainerIndex ].getPinIdentifier( ); }
unsigned char containerGetFree( void );
void print( void );
private:
std::string computeContainerName( const unsigned char* a_pBuffer, const size_t& a_BufferLength );
void write( void );
// Containers managed by the MiniDriver
ARRAY_CONTAINERS m_Containers;
Marshaller::u1Array m_ContainerMapFileBinary;
MiniDriverFiles* m_MiniDriverFiles;
// Disk serialization and deserialization
friend class boost::serialization::access;
template< class Archive > void serialize( Archive &ar, const unsigned int /*version*/ ) {
//Log::begin( "MiniDriverContainerMapFile::serialize" );
ar & m_Containers;
//print( );
ar & m_ContainerMapFileBinary;
//Log::logCK_UTF8CHAR_PTR( "Container Map File Binary", m_ContainerMapFileBinary.GetBuffer( ), m_ContainerMapFileBinary.GetLength( ) );
//Log::end( "MiniDriverContainerMapFile::serialize" );
}
};
BOOST_CLASS_VERSION( MiniDriverContainerMapFile, 1 )
#endif // __GEMALTO_CARD_CACHE__