-
Notifications
You must be signed in to change notification settings - Fork 0
/
aboutdialog.cpp
244 lines (182 loc) · 7.23 KB
/
aboutdialog.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* Author: Copyright (C) Rudolf Boeddeker Date: 2014-04-12
*
* This file is part of GPF Crypto Stick.
*
* GPF Crypto Stick is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* GPF Crypto Stick 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GPF Crypto Stick. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include "stick20infodialog.h"
#include "stick20responsedialog.h"
AboutDialog::AboutDialog(Device *global_cryptostick,QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
cryptostick = global_cryptostick;
QPixmap image(":/images/CS_icon.png");
QPixmap small_img = image.scaled(70,70,Qt::KeepAspectRatio,Qt::FastTransformation);
//cryptostick->getStatus();
int majorFirmwareVersion = cryptostick->firmwareVersion[0]/10;
int minorFirmwareVersion = cryptostick->firmwareVersion[0]%10;
ui->IconLabel->setPixmap(small_img);
ui->VersionLabel->setText(tr(GUI_VERSION));
ui->firmwareLabel->setText(QString::number(majorFirmwareVersion).append(".").append(QString::number(minorFirmwareVersion)));
QByteArray cardSerial = QByteArray((char *) cryptostick->cardSerial).toHex();
ui->serialEdit->setText(QString( "%1" ).arg(QString(cardSerial),8,'0'));
ui->ButtonStickStatus->hide();
if (true == cryptostick->isConnected)
{
if (true == cryptostick->activStick20)
{
showStick20Configuration ();
}
else
{
showStick10Configuration ();
ui->ButtonStickStatus->hide();
}
}
else
{
showNoStickFound ();
// ui->ButtonStickStatus->hide();
}
}
AboutDialog::~AboutDialog()
{
delete ui;
}
void AboutDialog::on_ButtonOK_clicked()
{
done (TRUE);
}
/*******************************************************************************
showStick20Configuration
Changes
Date Author Info
02.07.14 RB Function created
Reviews
Date Reviewer Info
*******************************************************************************/
void AboutDialog::showStick20Configuration (void)
{
QString OutputText;
if (99 == HID_Stick20Configuration_st.UserPwRetryCount)
{
OutputText.append(QString("No connection\nPlease retry"));
ui->DeviceStatusLabel->setText(OutputText);
return;
}
if (TRUE == HID_Stick20Configuration_st.StickKeysNotInitiated)
{
OutputText.append(QString(" *** Warning stick is not securce ***")).append("\n");
OutputText.append(QString(" *** Select -Init keys- ***")).append("\n").append("\n");
}
if (TRUE == HID_Stick20Configuration_st.FirmwareLocked_u8)
{
OutputText.append(QString(" *** Firmware is locked *** ")).append("\n");
}
if (0 != (HID_Stick20Configuration_st.NewSDCardFound_u8 & 0x01))
{
OutputText.append(QString(" *** New SD card found ***\n"));
}
if (0 == (HID_Stick20Configuration_st.SDFillWithRandomChars_u8 & 0x01))
{
OutputText.append(QString(" *** Not erased with random chars ***\n"));
}
if (READ_WRITE_ACTIVE == HID_Stick20Configuration_st.ReadWriteFlagUncryptedVolume_u8)
{
OutputText.append(QString("Unencrypted volume READ/WRITE mode ")).append("\n");
}
else
{
OutputText.append(QString("Unencrypted volume READ ONLY mode ")).append("\n");
}
if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_HIDDEN_VOLUME_BIT_PLACE)))
{
OutputText.append(QString("Hidden volume active")).append("\n");
}
else
{
if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_CRYPTED_VOLUME_BIT_PLACE)))
{
OutputText.append(QString("Encrypted volume active")).append("\n");
}
else
{
OutputText.append(QString("Encrypted volume not active")).append("\n");
}
}
OutputText.append(QString("\n"));
OutputText.append(QString("Password retry counter\n"));
OutputText.append(QString("Admin : "));
OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.AdminPwRetryCount))).append("\n");
OutputText.append(QString("User : "));
OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.UserPwRetryCount))).append("\n");
OutputText.append(QString("\n"));
OutputText.append(QString("SD ID 0x"));
OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.ActiveSD_CardID_u32,16))).append("\n");
/*
OutputText.append(QString("SD change counter "));
OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.NewSDCardFound_u8 >> 1))).append("\n");
OutputText.append(QString("SD erase counter "));
OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.SDFillWithRandomChars_u8 >> 1))).append("\n");
*/
ui->DeviceStatusLabel->setText(OutputText);
ui->firmwareLabel->setText(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[0]).append(".").append(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[1])));
ui->serialEdit->setText(QString("%1").sprintf("%08x",HID_Stick20Configuration_st.ActiveSmartCardID_u32));
}
/*******************************************************************************
showStick10Configuration
Changes
Date Author Info
23.07.14 RB Function created
Reviews
Date Reviewer Info
*******************************************************************************/
void AboutDialog::showStick10Configuration (void)
{
QString OutputText;
cryptostick->getPasswordRetryCount();
cryptostick->getUserPasswordRetryCount();
OutputText.append(QString("Password retry counter\n"));
OutputText.append(QString("Admin : "));
OutputText.append(QString("%1").arg(QString::number(cryptostick->passwordRetryCount))).append("\n");
OutputText.append(QString("User : "));
OutputText.append(QString("%1").arg(QString::number(cryptostick->userPasswordRetryCount))).append("\n");
ui->DeviceStatusLabel->setText(OutputText);
}
/*******************************************************************************
showNoStickFound
Changes
Date Author Info
23.07.14 RB Function created
Reviews
Date Reviewer Info
*******************************************************************************/
void AboutDialog::showNoStickFound (void)
{
QString OutputText;
OutputText.append(QString("No Crypto Stick active\n\n"));
ui->DeviceStatusLabel->setText(OutputText);
ui->firmwareLabel->setText("");
ui->serialEdit->setText("");
}
void AboutDialog::on_ButtonStickStatus_clicked()
{
Stick20InfoDialog InfoDialog(this);
InfoDialog.exec();
}