-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pkcs11ObjectStorage.hpp
108 lines (66 loc) · 2.82 KB
/
Pkcs11ObjectStorage.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
/*
* 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_PKCS11_OBJECT_STORAGE__
#define __GEMALTO_PKCS11_OBJECT_STORAGE__
#include <string>
#include <memory>
#include "cryptoki.h"
#include "Array.hpp"
#include <boost/shared_ptr.hpp>
const int OBJECT_SERIALIZATION_CURRENT_VERSION = 2;
/*
*/
class StorageObject {
public:
StorageObject( );
StorageObject( const StorageObject& a_Object );
virtual ~StorageObject( ) { }
inline bool isModifiable( void ) { return ( ( m_Modifiable == CK_TRUE ) ? true : false ); }
inline bool isToken( void ) { return ( ( m_Token == CK_TRUE ) ? true : false ); }
inline CK_OBJECT_CLASS getClass( void ) { return m_Class; }
inline bool isPrivate( void ) { return ( ( m_Private == CK_TRUE ) ? true : false ); }
inline virtual bool isEqual( StorageObject * that) const { return ( m_Class == that->m_Class ); }
virtual bool compare( const CK_ATTRIBUTE& );
virtual void setAttribute( const CK_ATTRIBUTE&, const bool& );
virtual void getAttribute( CK_ATTRIBUTE_PTR );
virtual void serialize( std::vector< u1 >* );
virtual void deserialize(const std::vector< u1 >&, CK_ULONG_PTR );
//protected:
virtual void print( void );
void putU1ArrayInAttribute( Marshaller::u1Array*, CK_ATTRIBUTE_PTR );
void putU4ArrayInAttribute( Marshaller::u4Array*, CK_ATTRIBUTE_PTR );
void putULongInAttribute( const CK_ULONG&, CK_ATTRIBUTE_PTR );
void putBBoolInAttribute( const CK_BBOOL&, CK_ATTRIBUTE_PTR );
CK_BBOOL readBBoolFromAttribute( const CK_ATTRIBUTE& );
CK_ULONG readULongFromAttribute( const CK_ATTRIBUTE& );
Marshaller::u1Array* readU1ArrayFromAttribute( const CK_ATTRIBUTE& );
Marshaller::u1Array* readDateFromAttribute( const CK_ATTRIBUTE& );
int m_iVersion;
CK_ULONG m_Class;
CK_BBOOL m_Token;
CK_BBOOL m_Private;
CK_BBOOL m_Modifiable;
boost::shared_ptr< Marshaller::u1Array > m_pLabel;
u8 _uniqueId;
// name of the PKCS11 file in the card which contains this object attributes
std::string m_stFileName;
bool m_bOffCardObject;
};
#endif // __GEMALTO_PKCS11_OBJECT_STORAGE__