~nitrokey/nitrokey/release

« back to all changes in this revision

Viewing changes to src/ui/stick20infodialog.cpp

  • Committer: ggkitsas
  • Date: 2015-04-06 11:29:10 UTC
  • Revision ID: git-v1:5264a39ba4fc1982a95a6380bfb5595cfecc6a2e
nsis installer script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Author: Copyright (C) Rudolf Boeddeker  Date: 2013-08-13
3
 
 *
4
 
 * This file is part of Nitrokey 2
5
 
 *
6
 
 * Nitrokey 2  is free software: you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation, either version 3 of the License, or
9
 
 * any later version.
10
 
 *
11
 
 * Nitrokey is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with Nitrokey. If not, see <http://www.gnu.org/licenses/>.
18
 
 */
 
2
* Author: Copyright (C) Rudolf Boeddeker  Date: 2013-08-13
 
3
*
 
4
* This file is part of Nitrokey 2
 
5
*
 
6
* Nitrokey 2  is free software: you can redistribute it and/or modify
 
7
* it under the terms of the GNU General Public License as published by
 
8
* the Free Software Foundation, either version 3 of the License, or
 
9
* any later version.
 
10
*
 
11
* Nitrokey is distributed in the hope that it will be useful,
 
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
* GNU General Public License for more details.
 
15
*
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with Nitrokey. If not, see <http://www.gnu.org/licenses/>.
 
18
*/
19
19
 
20
20
#include "stick20infodialog.h"
21
21
#include "ui_stick20infodialog.h"
22
22
 
23
23
#include "stick20hid.h"
24
24
 
25
 
Stick20InfoDialog::Stick20InfoDialog(QWidget *parent)
26
 
    : QDialog(parent), ui(new Ui::Stick20InfoDialog) {
27
 
  ui->setupUi(this);
28
 
  showStick20Configuration();
29
 
}
30
 
 
31
 
Stick20InfoDialog::~Stick20InfoDialog() { delete ui; }
 
25
 
 
26
Stick20InfoDialog::Stick20InfoDialog(QWidget *parent) :
 
27
    QDialog(parent),
 
28
    ui(new Ui::Stick20InfoDialog)
 
29
{
 
30
    ui->setupUi(this);
 
31
    showStick20Configuration ();
 
32
}
 
33
 
 
34
Stick20InfoDialog::~Stick20InfoDialog()
 
35
{
 
36
    delete ui;
 
37
}
 
38
 
32
39
 
33
40
/*******************************************************************************
34
41
 
43
50
 
44
51
*******************************************************************************/
45
52
 
46
 
void Stick20InfoDialog::showStick20Configuration(void) {
47
 
  QString OutputText;
48
 
 
49
 
  OutputText.append(QString(tr("Nitrokey Storage status\n\n")));
50
 
 
51
 
  if (TRUE == HID_Stick20Configuration_st.StickKeysNotInitiated) {
52
 
    OutputText.append(QString(" ***  Warning: Device is not secure  ***")).append("\n");
53
 
    OutputText.append(QString(" ***       Select -Init keys-        ***"))
54
 
        .append("\n")
55
 
        .append("\n");
56
 
  }
57
 
 
58
 
  OutputText.append(QString("Firmware version     "));
59
 
  OutputText.append(
60
 
      QString("%1").arg(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[0])));
61
 
  OutputText.append(QString("."));
62
 
  OutputText.append(
63
 
      QString("%1").arg(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[1])));
64
 
  OutputText.append(QString("\n"));
65
 
 
66
 
  if (TRUE == HID_Stick20Configuration_st.FirmwareLocked_u8) {
67
 
    OutputText.append(QString("*** Firmware is locked *** ")).append("\n");
68
 
  }
69
 
 
70
 
  if (READ_WRITE_ACTIVE == HID_Stick20Configuration_st.ReadWriteFlagUncryptedVolume_u8) {
71
 
    OutputText.append(QString("Unencrypted volume   READ/WRITE mode ")).append("\n");
72
 
  } else {
73
 
    OutputText.append(QString("Unencrypted volume   READ ONLY mode ")).append("\n");
74
 
  }
75
 
 
76
 
  if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_CRYPTED_VOLUME_BIT_PLACE))) {
77
 
    OutputText.append(QString("Encrypted volume     active")).append("\n");
78
 
  } else {
79
 
    OutputText.append(QString("Encrypted volume     not active")).append("\n");
80
 
  }
81
 
 
82
 
  if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_HIDDEN_VOLUME_BIT_PLACE))) {
83
 
    OutputText.append(QString("Hidden volume        active")).append("\n");
84
 
  }
85
 
 
86
 
  OutputText.append(QString("SD change counter    "));
87
 
  OutputText
88
 
      .append(
89
 
          QString("%1").arg(QString::number(HID_Stick20Configuration_st.NewSDCardFound_u8 >> 1)))
90
 
      .append("\n");
91
 
 
92
 
  OutputText.append(QString("SD erase counter     "));
93
 
  OutputText
94
 
      .append(QString("%1").arg(
95
 
          QString::number(HID_Stick20Configuration_st.SDFillWithRandomChars_u8 >> 1)))
96
 
      .append("\n");
97
 
 
98
 
  OutputText.append(QString("\n"));
99
 
  OutputText.append(QString("SD card info\n"));
100
 
 
101
 
  OutputText.append(QString(" ID     0x"));
102
 
  OutputText
103
 
      .append(
104
 
          QString("%1").arg(QString::number(HID_Stick20Configuration_st.ActiveSD_CardID_u32, 16)))
105
 
      .append("\n");
106
 
 
107
 
  if (0 != (HID_Stick20Configuration_st.NewSDCardFound_u8 & 0x01)) {
108
 
    // OutputText.append(QString(" *** New SD card found ***\n"));
109
 
  }
110
 
 
111
 
  if (0 == (HID_Stick20Configuration_st.SDFillWithRandomChars_u8 & 0x01)) {
112
 
    OutputText.append(QString(" *** Storage is not initialized with random data ***\n"));
113
 
  }
114
 
 
115
 
  OutputText.append(QString("\n"));
116
 
  OutputText.append(QString("Smartcard info\n"));
117
 
 
118
 
  OutputText.append(QString(" ID     0x"));
119
 
  OutputText
120
 
      .append(
121
 
          QString("%1").arg(QString::number(HID_Stick20Configuration_st.ActiveSmartCardID_u32, 16)))
122
 
      .append("\n");
123
 
 
124
 
  OutputText.append(QString(" Password retry counter\n"));
125
 
  OutputText.append(QString("  Admin : "));
126
 
  OutputText
127
 
      .append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.AdminPwRetryCount)))
128
 
      .append("\n");
129
 
 
130
 
  OutputText.append(QString("  User  : "));
131
 
  OutputText
132
 
      .append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.UserPwRetryCount)))
133
 
      .append("\n");
134
 
 
135
 
  ui->Infotext->setText(OutputText);
136
 
}
137
 
 
138
 
void Stick20InfoDialog::on_pushButton_clicked() { done(true); }
 
53
 
 
54
void Stick20InfoDialog::showStick20Configuration (void)
 
55
{
 
56
    QString OutputText;
 
57
 
 
58
    OutputText.append(QString("Nitrokey Storage status\n\n"));
 
59
 
 
60
    if (TRUE == HID_Stick20Configuration_st.StickKeysNotInitiated)
 
61
    {
 
62
        OutputText.append(QString(" ***  Warning: Device is not secure  ***")).append("\n");
 
63
        OutputText.append(QString(" ***       Select -Init keys-        ***")).append("\n").append("\n");
 
64
    }
 
65
 
 
66
    OutputText.append(QString("Firmware version     "));
 
67
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[0])));
 
68
    OutputText.append(QString("."));
 
69
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.VersionInfo_au8[1])));
 
70
    OutputText.append(QString("\n"));
 
71
 
 
72
    if (TRUE == HID_Stick20Configuration_st.FirmwareLocked_u8)
 
73
    {
 
74
        OutputText.append(QString("*** Firmware is locked *** ")).append("\n");
 
75
    }
 
76
 
 
77
    if (READ_WRITE_ACTIVE == HID_Stick20Configuration_st.ReadWriteFlagUncryptedVolume_u8)
 
78
    {
 
79
        OutputText.append(QString("Unencrypted volume   READ/WRITE mode ")).append("\n");
 
80
    }
 
81
    else
 
82
    {
 
83
        OutputText.append(QString("Unencrypted volume   READ ONLY mode ")).append("\n");
 
84
    }
 
85
 
 
86
    if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_CRYPTED_VOLUME_BIT_PLACE)))
 
87
    {
 
88
        OutputText.append(QString("Encrypted volume     active")).append("\n");
 
89
    }
 
90
    else
 
91
    {
 
92
        OutputText.append(QString("Encrypted volume     not active")).append("\n");
 
93
    }
 
94
 
 
95
    if (0 != (HID_Stick20Configuration_st.VolumeActiceFlag_u8 & (1 << SD_HIDDEN_VOLUME_BIT_PLACE)))
 
96
    {
 
97
        OutputText.append(QString("Hidden volume        active")).append("\n");
 
98
    }
 
99
 
 
100
 
 
101
 
 
102
    OutputText.append(QString("SD change counter    "));
 
103
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.NewSDCardFound_u8 >> 1))).append("\n");
 
104
 
 
105
    OutputText.append(QString("SD erase counter     "));
 
106
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.SDFillWithRandomChars_u8 >> 1))).append("\n");
 
107
 
 
108
 
 
109
    OutputText.append(QString("\n"));
 
110
    OutputText.append(QString("SD card info\n"));
 
111
 
 
112
    OutputText.append(QString(" ID     0x"));
 
113
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.ActiveSD_CardID_u32,16))).append("\n");
 
114
 
 
115
 
 
116
    if (0 != (HID_Stick20Configuration_st.NewSDCardFound_u8 & 0x01))
 
117
    {
 
118
//        OutputText.append(QString(" *** New SD card found ***\n"));
 
119
    }
 
120
 
 
121
    if (0 == (HID_Stick20Configuration_st.SDFillWithRandomChars_u8 & 0x01))
 
122
    {
 
123
        OutputText.append(QString(" *** Storage is not initialized with random data ***\n"));
 
124
    }
 
125
 
 
126
 
 
127
    OutputText.append(QString("\n"));
 
128
    OutputText.append(QString("Smartcard info\n"));
 
129
 
 
130
    OutputText.append(QString(" ID     0x"));
 
131
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.ActiveSmartCardID_u32,16))).append("\n");
 
132
 
 
133
    OutputText.append(QString(" Password retry counter\n"));
 
134
    OutputText.append(QString("  Admin : "));
 
135
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.AdminPwRetryCount))).append("\n");
 
136
 
 
137
    OutputText.append(QString("  User  : "));
 
138
    OutputText.append(QString("%1").arg(QString::number(HID_Stick20Configuration_st.UserPwRetryCount))).append("\n");
 
139
 
 
140
    ui->Infotext->setText(OutputText);
 
141
 
 
142
}
 
143
 
 
144
void Stick20InfoDialog::on_pushButton_clicked()
 
145
{
 
146
    done(true);
 
147
}