Added a Security Page for Options to View, Copy and Export own Public Key.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1380 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-07-14 23:11:37 +00:00
parent 1c729b93fc
commit 9c65c694c5
5 changed files with 422 additions and 678 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************
* RShare is distributed under the following license:
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
* Copyright (C) 2006 - 2009 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -19,10 +19,18 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "rsiface/rspeers.h" //for rsPeers variable
#include "rsiface/rsiface.h"
#include <QtGui>
#include <QClipboard>
#include <rshare.h>
#include "CryptographyDialog.h"
#include <sstream>
#include <iostream>
#include <set>
/** Constructor */
CryptographyDialog::CryptographyDialog(QWidget *parent)
@ -34,6 +42,13 @@ CryptographyDialog::CryptographyDialog(QWidget *parent)
/* Create RshareSettings object */
_settings = new RshareSettings();
connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey()));
loadPublicKey();
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -44,7 +59,7 @@ CryptographyDialog::CryptographyDialog(QWidget *parent)
bool
CryptographyDialog::save(QString &errmsg)
{
return true;
}
/** Loads the settings for this page */
@ -54,3 +69,68 @@ CryptographyDialog::load()
}
/** Loads ouer default Puplickey */
void
CryptographyDialog::loadPublicKey()
{
//std::cerr << "CryptoPage() getting Invite" << std::endl;
std::string invite = rsPeers->GetRetroshareInvite();
RsPeerDetails ownDetail;
rsPeers->getPeerDetails(rsPeers->getOwnId(), ownDetail);
invite += LOCAL_IP;
invite += ownDetail.localAddr + ":";
std::ostringstream out;
out << ownDetail.localPort;
invite += out.str() + ";";
invite += "\n";
invite += EXT_IP;
invite += ownDetail.extAddr + ":";
std::ostringstream out2;
out2 << ownDetail.extPort;
invite += out2.str() + ";";
ui.certtextEdit->setText(QString::fromStdString(invite));
ui.certtextEdit->setReadOnly(true);
ui.certtextEdit->setMinimumHeight(200);
//std::cerr << "CryptoPage() getting Invite: " << invite << std::endl;
}
void
CryptographyDialog::copyPublicKey()
{
QMessageBox::information(this,
tr("RetroShare"),
tr("Your Public Key is copied to Clipbard, paste and send it to your"
"friend via email or some other way"));
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ui.certtextEdit->toPlainText());
}
void
CryptographyDialog::exportPublicKey()
{
qDebug() << " exportPulicKey";
QString qdir = QFileDialog::getSaveFileName(this,
"Please choose a filename",
QDir::homePath(),
"RetroShare Certificate (*.pqi)");
if ( rsPeers->SaveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()) )
{
QMessageBox::information(this, tr("RetroShare"),
tr("Certificate file successfully created"),
QMessageBox::Ok, QMessageBox::Ok);
}
else
{
QMessageBox::information(this, tr("RetroShare"),
tr("Sorry, certificate file creation failed"),
QMessageBox::Ok, QMessageBox::Ok);
}
}

View File

@ -1,7 +1,7 @@
/****************************************************************
* RShare is distributed under the following license:
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
* Copyright (C) 2006 - 2009 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -25,10 +25,12 @@
#include <QFileDialog>
#include <gui/Preferences/rsharesettings.h>
#include "gui/connect/ConnectFriendWizard.h"
#include "configpage.h"
#include "ui_CryptographyDialog.h"
class CryptographyDialog : public ConfigPage
{
Q_OBJECT
@ -45,6 +47,12 @@ public:
private slots:
void loadPublicKey();
void copyPublicKey();
void exportPublicKey();
private:
/** A RshareSettings object used for saving/loading settings */

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CryptographyDialog</class>
<widget class="QWidget" name="CryptographyDialog">
@ -5,14 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>617</width>
<height>332</height>
<width>542</width>
<height>355</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -500,437 +499,90 @@
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<widget class="QGroupBox" name="groupBox_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>RSA Key Size</string>
<string>Public Key</string>
</property>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>54</width>
<height>25</height>
</rect>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="certtextEdit"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QPushButton" name="exportkeyButton">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Export my Key as file&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Key Size:</string>
<string>Export Key</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBoxkeysize" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>481</width>
<height>23</height>
</rect>
</property>
<property name="maximum" >
<number>16384</number>
</property>
<property name="minimum" >
<number>384</number>
</property>
<property name="value" >
<number>1024</number>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_7" >
<property name="geometry" >
<rect>
<x>0</x>
<y>200</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Rijndael Mode</string>
</property>
<widget class="QRadioButton" name="radioButton_12" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="copykeyButton">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Copy my Key to Clipboard&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>CBC</string>
<string>Copy Key</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_13" >
<property name="geometry" >
<rect>
<x>210</x>
<y>20</y>
<width>71</width>
<height>18</height>
</rect>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="text" >
<string>ECB</string>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>58</width>
<height>298</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QRadioButton" name="radioButton_14" >
<property name="geometry" >
<rect>
<x>300</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>CFB</string>
</property>
</widget>
<widget class="QLabel" name="label_5" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text" >
<string>Mode:</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_6" >
<property name="geometry" >
<rect>
<x>0</x>
<y>250</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Rijndael Padding</string>
</property>
<widget class="QRadioButton" name="radioButton_15" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>PKCS7</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_16" >
<property name="geometry" >
<rect>
<x>210</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Zeros</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_17" >
<property name="geometry" >
<rect>
<x>300</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>ANSIX923</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_18" >
<property name="geometry" >
<rect>
<x>400</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>ISO10126</string>
</property>
</widget>
<widget class="QLabel" name="label_6" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text" >
<string>Padding:</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
<x>0</x>
<y>100</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Rijndael Feedback Size</string>
</property>
<widget class="QRadioButton" name="radioButton_2" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>128 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_5" >
<property name="geometry" >
<rect>
<x>210</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>192 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_10" >
<property name="geometry" >
<rect>
<x>300</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>256 Bits</string>
</property>
</widget>
<widget class="QLabel" name="label_3" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>82</width>
<height>25</height>
</rect>
</property>
<property name="text" >
<string>Feedback Size:</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4" >
<property name="geometry" >
<rect>
<x>0</x>
<y>50</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Rijndael Block size</string>
</property>
<widget class="QRadioButton" name="radioButton" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>128 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_7" >
<property name="geometry" >
<rect>
<x>230</x>
<y>50</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>192 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_8" >
<property name="geometry" >
<rect>
<x>240</x>
<y>60</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>192 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_4" >
<property name="geometry" >
<rect>
<x>210</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>192 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_9" >
<property name="geometry" >
<rect>
<x>300</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>256 Bits</string>
</property>
</widget>
<widget class="QLabel" name="label_2" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text" >
<string>Block Size:</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_5" >
<property name="geometry" >
<rect>
<x>0</x>
<y>150</y>
<width>611</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Rijndael Key Size</string>
</property>
<widget class="QRadioButton" name="radioButton_3" >
<property name="geometry" >
<rect>
<x>120</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>128 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_11" >
<property name="geometry" >
<rect>
<x>300</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>256 Bits</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_6" >
<property name="geometry" >
<rect>
<x>210</x>
<y>20</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>192 Bits</string>
</property>
</widget>
<widget class="QLabel" name="label_4" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>54</width>
<height>25</height>
</rect>
</property>
<property name="text" >
<string>Key Size:</string>
</property>
</widget>
</widget>
</widget>
<tabstops>
<tabstop>spinBoxkeysize</tabstop>
<tabstop>radioButton</tabstop>
<tabstop>radioButton_4</tabstop>
<tabstop>radioButton_9</tabstop>
<tabstop>radioButton_2</tabstop>
<tabstop>radioButton_5</tabstop>
<tabstop>radioButton_10</tabstop>
<tabstop>radioButton_3</tabstop>
<tabstop>radioButton_6</tabstop>
<tabstop>radioButton_11</tabstop>
<tabstop>radioButton_12</tabstop>
<tabstop>radioButton_13</tabstop>
<tabstop>radioButton_14</tabstop>
<tabstop>radioButton_15</tabstop>
<tabstop>radioButton_16</tabstop>
<tabstop>radioButton_17</tabstop>
<tabstop>radioButton_18</tabstop>
<tabstop>radioButton_8</tabstop>
<tabstop>radioButton_7</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>
</resources>

View File

@ -34,7 +34,7 @@
#define IMAGE_PREFERENCES ":/images/kcmsystem24.png"
#define IMAGE_SERVER ":/images/server_24x24.png"
#define IMAGE_DIRECTORIES ":/images/folder_doments.png"
#define IMAGE_CRYPTOGRAPHY ":/images/cryptography_24x24.png"
#define IMAGE_CRYPTOGRAPHY ":/images/encrypted32.png"
#define IMAGE_LOG ":/images/log_24x24.png"
#define IMAGE_ABOUT ":/images/informations_24x24.png"
#define IMAGE_SAVE ":/images/media-floppy.png"
@ -69,6 +69,9 @@ PreferencesWindow::PreferencesWindow(QWidget *parent, Qt::WFlags flags)
ui.stackPages->add(new NotifyDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_NOTIFY), tr("Notify"), grp));
ui.stackPages->add(new CryptographyDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CRYPTOGRAPHY), tr("Security"), grp));
ui.stackPages->add(new FileAssotiationsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_FILE_ASSOTIATIONS),
tr("File assotiations"), grp));

View File

@ -50,6 +50,7 @@ public:
Directories, /** Directories page. */
Appearance, /** Appearance page. */
Notify, /** Notify page. */
Security, /** Security page. */
FileAssotiations /** File assotiations page. */
};