-
Notifications
You must be signed in to change notification settings - Fork 1
/
MiniDriverPinPolicy.cpp
123 lines (84 loc) · 3.84 KB
/
MiniDriverPinPolicy.cpp
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
/*
* 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
*
*/
#include <memory>
#include "MiniDriverPinPolicy.hpp"
#include "MiniDriverException.hpp"
#include "Log.hpp"
const unsigned char CP_CARD_PIN_POLICY = 0x80;
/*
*/
void MiniDriverPinPolicy::write( void ) {
Marshaller::u1Array b( g_PolicyLenght );
b.SetBuffer( m_ucaPinPolicy.c_array( ) );
try {
m_CardModule->setCardProperty( CP_CARD_PIN_POLICY, &b, m_ucRole );
} catch( MiniDriverException& ) {
Log::error( "MiniDriverPinPolicy::write", "setCardProperty 0x80 failed" );
// PIN policy not supported
//m_ucaPinPolicy.fill( 0 );
}
}
/*
*/
void MiniDriverPinPolicy::read( void ) {
std::auto_ptr< Marshaller::u1Array > b;
try {
b.reset( m_CardModule->getCardProperty( CP_CARD_PIN_POLICY, m_ucRole ) );
if( b.get( ) ) {
memcpy( m_ucaPinPolicy.c_array( ), b->GetBuffer( ), m_ucaPinPolicy.size( ) );
}
} catch( MiniDriverException& ) {
Log::error( "MiniDriverPinPolicy::read", "getCardProperty 0x80 failed" );
// PIN policy not supported
reset( );
}
}
/*
*/
void MiniDriverPinPolicy::print( void ) {
unsigned char a_ucParameterValue = get( PARAMETER_KEY_MAX_ATTEMPS );
Log::log( "PARAMETER_KEY_MAX_ATTEMPS <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_MIN_LENGTH );
Log::log( "PARAMETER_KEY_MIN_LENGTH <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_MAX_LENGTH );
Log::log( "PARAMETER_KEY_MAX_LENGTH <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_CHAR_SET );
Log::log( "PARAMETER_KEY_CHAR_SET <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_COMPLEXITY_RULE_1 );
Log::log( "PARAMETER_KEY_COMPLEXITY_RULE_1 <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_COMPLEXITY_RULE_2 );
Log::log( "PARAMETER_KEY_COMPLEXITY_RULE_2 <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_ADJACENT_ALLOWED );
Log::log( "PARAMETER_KEY_ADJACENT_ALLOWED <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_HISTORY );
Log::log( "PARAMETER_KEY_HISTORY <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_ALLOW_UNBLOCK );
Log::log( "PARAMETER_KEY_ALLOW_UNBLOCK <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_ALLOW_SSO );
Log::log( "PARAMETER_KEY_ALLOW_SSO <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_ONE_OF_EACH_CHAR_SET );
Log::log( "PARAMETER_KEY_ONE_OF_EACH_CHAR_SET <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_MANDATORY_CHAR_SET );
Log::log( "PARAMETER_KEY_MANDATORY_CHAR_SET <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_MAX_SEQUENCE_LEN );
Log::log( "PARAMETER_KEY_MAX_SEQUENCE_LEN <%#02x>", a_ucParameterValue );
a_ucParameterValue = get( PARAMETER_KEY_MAX_ADJACENT_NB );
Log::log( "PARAMETER_KEY_MAX_ADJACENT_NB <%#02x>", a_ucParameterValue );
}