Finished EntropyCollectionDlg.

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@110 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 29f3d8b2b3
commit b9feb0b74d
  1. 29
      src/crypto/yarrow.cpp
  2. 1
      src/crypto/yarrow.h
  3. 7
      src/dialogs/CollectEntropyDlg.cpp
  4. 192
      src/forms/CollectEntropyDlg.ui
  5. 84
      src/forms/PasswordGenDlg.ui
  6. 4
      src/lib/WaitAnimationWidget.cpp
  7. 11
      src/mainwindow.cpp

@ -429,3 +429,32 @@ void strongRandomize(void* buffer, unsigned int length){
for(int i=0; i<length;i++) for(int i=0; i<length;i++)
yarrow256_random(&StrongCtx,1,(quint8*)buffer+i); yarrow256_random(&StrongCtx,1,(quint8*)buffer+i);
} }
void reseedStrongPool(quint8* buffer1,int l1,quint8* buffer2,int l2){
if(l1>l2*4){
yarrow256_update(&StrongCtx,0,100,100,buffer1);
buffer1=buffer1+100;
l1=l1-100;
}
else
{
yarrow256_update(&StrongCtx,1,100,25,buffer2);
buffer2=buffer2+25;
l2=l2-25;
}
if(l1>l2*4){
yarrow256_update(&StrongCtx,0,160,160,buffer1);
l1-=160;
buffer1+=160;
yarrow256_update(&StrongCtx,1,l1,l1,buffer1);
yarrow256_update(&StrongCtx,1,4*l2,l2,buffer2);
}
else{
yarrow256_update(&StrongCtx,0,160,40,buffer2);
l2-=40;
buffer2+=40;
yarrow256_update(&StrongCtx,1,l2*4,l2,buffer2);
yarrow256_update(&StrongCtx,1,l1,l1,buffer1);
}
}

@ -185,6 +185,7 @@ do { \
void initYarrow(); void initYarrow();
void randomize(void* buffer, unsigned int length); void randomize(void* buffer, unsigned int length);
void reseedStrongPool(quint8* buffer1,int l1,quint8* buffer2,int l2);
#endif /* NETTLE_YARROW_COMPAT_H_INCLUDED */ #endif /* NETTLE_YARROW_COMPAT_H_INCLUDED */

@ -20,12 +20,13 @@
#include <QPainter> #include <QPainter>
#include <QCursor> #include <QCursor>
#include "crypto/yarrow.h"
#include "CollectEntropyDlg.h" #include "CollectEntropyDlg.h"
#include "main.h" #include "main.h"
CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){ CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){
setupUi(this); setupUi(this);
createBanner(&BannerPixmap,NULL,tr("Entropy Collection"),width()); createBanner(&BannerPixmap,Icon_Key32x32,tr("Entropy Collection"),width());
KeyEntropyBuffer=new unsigned char[105]; KeyEntropyBuffer=new unsigned char[105];
MouseEntropyBuffer=new quint16[210]; MouseEntropyBuffer=new quint16[210];
KeyCounter=0; KeyCounter=0;
@ -72,7 +73,9 @@ void CollectEntropyDlg::updateProgress(){
if(4*KeyCounter+4*MouseCounter>=420){ if(4*KeyCounter+4*MouseCounter>=420){
progressBar->setValue(420); progressBar->setValue(420);
ReseedDone=true; ReseedDone=true;
reseedStrongPool((quint8*)MouseEntropyBuffer,4*MouseCounter,KeyEntropyBuffer,KeyCounter);
Animation->stop();
stackedWidget->setCurrentIndex(1);
} }
else else
progressBar->setValue(4*KeyCounter+4*MouseCounter); progressBar->setValue(4*KeyCounter+4*MouseCounter);

@ -5,22 +5,58 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>476</width> <width>432</width>
<height>279</height> <height>230</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>432</width>
<height>230</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>432</width>
<height>230</height>
</size>
</property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Dialog</string> <string>Random Number Generator</string>
</property> </property>
<widget class="QLabel" name="label" > <layout class="QVBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>9</number>
<x>10</x>
<y>80</y>
<width>411</width>
<height>51</height>
</rect>
</property> </property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>50</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" > <property name="text" >
<string>Collecting entropy... <string>Collecting entropy...
Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected.</string> Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected.</string>
@ -32,54 +68,130 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QDialogButtonBox" name="buttonBox" > </item>
<property name="geometry" > <item>
<rect> <widget class="QProgressBar" name="progressBar" >
<x>20</x> <property name="maximum" >
<y>240</y> <number>420</number>
<width>441</width> </property>
<height>32</height> <property name="value" >
</rect> <number>0</number>
</property> </property>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="format" >
<set>QDialogButtonBox::Ok</set> <string>%v Bits</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="page" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="WaitAnimationWidget" native="1" name="Animation" > <widget class="WaitAnimationWidget" native="1" name="Animation" >
<property name="geometry" > <property name="sizePolicy" >
<rect> <sizepolicy>
<x>8</x> <hsizetype>0</hsizetype>
<y>5</y> <vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>41</width> <width>41</width>
<height>41</height> <height>41</height>
</rect> </size>
</property>
<property name="maximumSize" >
<size>
<width>41</width>
<height>41</height>
</size>
</property> </property>
</widget> </widget>
<widget class="QProgressBar" name="progressBar" > </item>
<property name="geometry" > <item>
<rect> <spacer>
<x>10</x> <property name="orientation" >
<y>140</y> <enum>Qt::Horizontal</enum>
<width>451</width>
<height>23</height>
</rect>
</property> </property>
<property name="maximum" > <property name="sizeType" >
<number>420</number> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="value" > <property name="sizeHint" >
<number>0</number> <size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="Label_Finished" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Verdana'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600; color:#006400;">Random pool successfully reseeded!&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property> </property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="format" > <property name="standardButtons" >
<string>%v Bits</string> <set>QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item>
</layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

@ -1,7 +1,4 @@
<ui version="4.0" stdsetdef="1" > <ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>GenPwDlg</class> <class>GenPwDlg</class>
<widget class="QDialog" name="GenPwDlg" > <widget class="QDialog" name="GenPwDlg" >
<property name="geometry" > <property name="geometry" >
@ -44,6 +41,9 @@
<height>15</height> <height>15</height>
</rect> </rect>
</property> </property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget> </widget>
<widget class="QLineEdit" name="Edit_dest" > <widget class="QLineEdit" name="Edit_dest" >
<property name="geometry" > <property name="geometry" >
@ -68,22 +68,6 @@
<string/> <string/>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="Banner" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>50</height>
</rect>
</property>
<property name="pixmap" >
<pixmap>image0</pixmap>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="ButtonOK" > <widget class="QPushButton" name="ButtonOK" >
<property name="geometry" > <property name="geometry" >
<rect> <rect>
@ -164,6 +148,9 @@
<property name="frameShadow" > <property name="frameShadow" >
<enum>QFrame::Sunken</enum> <enum>QFrame::Sunken</enum>
</property> </property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget> </widget>
<widget class="QGroupBox" name="groupBox1" > <widget class="QGroupBox" name="groupBox1" >
<property name="geometry" > <property name="geometry" >
@ -353,25 +340,6 @@
<string>Length:</string> <string>Length:</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="Check_strongrandom" >
<property name="geometry" >
<rect>
<x>120</x>
<y>250</y>
<width>310</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>Use &quot;/dev/rando&amp;m&quot;</string>
</property>
<property name="shortcut" >
<string>Alt+M</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="Radio_1" > <widget class="QRadioButton" name="Radio_1" >
<property name="geometry" > <property name="geometry" >
<rect> <rect>
@ -404,10 +372,44 @@
<string>Alt+S</string> <string>Alt+S</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="Check_strongrandom" >
<property name="geometry" >
<rect>
<x>120</x>
<y>250</y>
<width>310</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>Force entropy collection</string>
</property>
<property name="shortcut" >
<string>Alt+M</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QLabel" name="Banner" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>50</height>
</rect>
</property>
<property name="pixmap" >
<pixmap/>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
</widget> </widget>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<tabstops> <tabstops>
<tabstop>Radio_1</tabstop> <tabstop>Radio_1</tabstop>
<tabstop>checkBox1</tabstop> <tabstop>checkBox1</tabstop>
@ -427,4 +429,6 @@
<tabstop>ButtonOK</tabstop> <tabstop>ButtonOK</tabstop>
<tabstop>Button_Cancel</tabstop> <tabstop>Button_Cancel</tabstop>
</tabstops> </tabstops>
<resources/>
<connections/>
</ui> </ui>

@ -77,8 +77,8 @@ void WaitAnimationWidget::paintEvent(QPaintEvent* event){
if(timer.isActive()){ if(timer.isActive()){
QPainter painter(this); QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing,true); painter.setRenderHints(QPainter::Antialiasing,true);
painter.setBrush(config.BannerTextColor); painter.setBrush(Qt::black);
painter.setPen(config.BannerTextColor); painter.setPen(Qt::black);
for(int i=0;i<6;i++){ for(int i=0;i<6;i++){
float d=CircSizes[i]*5.0; float d=CircSizes[i]*5.0;
QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d); QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d);

@ -372,17 +372,6 @@ return true;
void KeepassMainWindow::OnFileNewKdb(){ void KeepassMainWindow::OnFileNewKdb(){
//Test
/*
CollectEntropyDlg dialog(this);
dialog.exec();
return;
*/
//~Test
CPasswordDialog dlg(this,true,false,true); CPasswordDialog dlg(this,true,false,true);
dlg.setWindowTitle("New Database"); dlg.setWindowTitle("New Database");
if(dlg.exec()==1){ if(dlg.exec()==1){