Denio
4 years ago
committed by
GitHub
13 changed files with 944 additions and 162 deletions
@ -1,2 +1,2 @@ |
|||||
break FileSystem::writeContacts |
break FileEncryption::encrypt |
||||
|
|
||||
|
@ -0,0 +1,60 @@ |
|||||
|
#include "passwd.h" |
||||
|
|
||||
|
void PASSWD::show_hex_buff(unsigned char buf[]) |
||||
|
{ |
||||
|
int i; |
||||
|
for (uint8_t i=0; i < crypto_secretstream_xchacha20poly1305_KEYBYTES; i++) |
||||
|
printf("%02X ", buf[i]); |
||||
|
printf("\n"); |
||||
|
} |
||||
|
|
||||
|
const unsigned char* PASSWD::key(QString password) |
||||
|
{ |
||||
|
|
||||
|
int length = password.length(); |
||||
|
|
||||
|
char *sequence = NULL; |
||||
|
sequence = new char[length+1]; |
||||
|
strncpy(sequence, password.toLocal8Bit(), length +1); |
||||
|
|
||||
|
#define MESSAGE ((const unsigned char *) sequence) |
||||
|
#define MESSAGE_LEN length |
||||
|
|
||||
|
unsigned char hash[crypto_secretstream_xchacha20poly1305_KEYBYTES]; |
||||
|
|
||||
|
crypto_hash_sha256(hash, MESSAGE, MESSAGE_LEN); |
||||
|
|
||||
|
qDebug()<<"Generating SaltHash from password: " <<sequence; |
||||
|
|
||||
|
|
||||
|
/////////we use the Hash of the Password as Salt, not perfect but still a good solution.
|
||||
|
|
||||
|
#define PASSWORD sequence |
||||
|
#define KEY_LEN crypto_box_SEEDBYTES |
||||
|
|
||||
|
unsigned char key[KEY_LEN]; |
||||
|
|
||||
|
if (crypto_pwhash |
||||
|
(key, sizeof key, PASSWORD, strlen(PASSWORD), hash, |
||||
|
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, |
||||
|
crypto_pwhash_ALG_DEFAULT) != 0) { |
||||
|
/* out of memory */ |
||||
|
} |
||||
|
|
||||
|
qDebug()<<"Generating cryptographic key from password: " <<sequence; |
||||
|
|
||||
|
|
||||
|
// crypto_generichash(blacke2hash, sizeof hash, MESSAGE, MESSAGE_LEN, NULL, 0);
|
||||
|
|
||||
|
//for(uint8_t i = 0; i < crypto_secretstream_xchacha20poly1305_KEYBYTES/2; i++)
|
||||
|
// hash[i] = blacke2hash[i];
|
||||
|
|
||||
|
// for(uint8_t i = crypto_secretstream_xchacha20poly1305_KEYBYTES/2; i < crypto_secretstream_xchacha20poly1305_KEYBYTES; i++)
|
||||
|
// hash[i] = sha256hash[i];
|
||||
|
|
||||
|
// delete[] sha256hash;
|
||||
|
//delete[] blacke2hash;
|
||||
|
qDebug()<<"secret key generated:\n"; |
||||
|
PASSWD::show_hex_buff(key); |
||||
|
return key; |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
#ifndef PASSWD_H |
||||
|
#define PASSWD_H |
||||
|
#include <stdio.h> |
||||
|
#include <sodium.h> |
||||
|
#include <QString> |
||||
|
|
||||
|
class PASSWD |
||||
|
{ |
||||
|
public: |
||||
|
static void show_hex_buff(unsigned char buf[]); |
||||
|
static const unsigned char* key(QString); |
||||
|
}; |
||||
|
|
||||
|
#endif |
@ -0,0 +1,197 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>removeencryption</class> |
||||
|
<widget class="QDialog" name="removeencryption"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>400</width> |
||||
|
<height>300</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Remove your Wallet encryption</string> |
||||
|
</property> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>50</x> |
||||
|
<y>260</y> |
||||
|
<width>341</width> |
||||
|
<height>32</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>260</x> |
||||
|
<y>170</y> |
||||
|
<width>133</width> |
||||
|
<height>23</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string><html><head/><body><p>16 letters minimum</p></body></html></string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_4"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>229</y> |
||||
|
<width>157</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Confirm Passphrase:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="Line" name="line_2"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>164</y> |
||||
|
<width>382</width> |
||||
|
<height>3</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLineEdit" name="txtConfirmPassword"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>173</x> |
||||
|
<y>229</y> |
||||
|
<width>219</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="echoMode"> |
||||
|
<enum>QLineEdit::Password</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_2"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>56</y> |
||||
|
<width>382</width> |
||||
|
<height>56</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string><html><head/><body><p><span style=" font-size:14pt; color:#ef2929;">WARNING:</span> If yo remove your encryption, all your Data is Plaintext on your Disk!</p></body></html></string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignCenter</set> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="Line" name="line"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>260</y> |
||||
|
<width>382</width> |
||||
|
<height>3</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_3"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>198</y> |
||||
|
<width>157</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Encryption Passphrase:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="lblPasswordMatch"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>175</y> |
||||
|
<width>243</width> |
||||
|
<height>17</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="styleSheet"> |
||||
|
<string notr="true">color: red;</string> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Passphrase don't match</string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignCenter</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLineEdit" name="txtPassword"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>173</x> |
||||
|
<y>198</y> |
||||
|
<width>219</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="echoMode"> |
||||
|
<enum>QLineEdit::Password</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>removeencryption</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>removeencryption</receiver> |
||||
|
<slot>close()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
@ -0,0 +1,184 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>startup</class> |
||||
|
<widget class="QDialog" name="startup"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>400</width> |
||||
|
<height>300</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>SDL Startup Decryption</string> |
||||
|
</property> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>50</x> |
||||
|
<y>260</y> |
||||
|
<width>341</width> |
||||
|
<height>32</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_4"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>229</y> |
||||
|
<width>127</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Confirm Password:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="Line" name="line_2"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>166</y> |
||||
|
<width>382</width> |
||||
|
<height>3</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLineEdit" name="txtConfirmPassword"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>162</x> |
||||
|
<y>229</y> |
||||
|
<width>230</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="echoMode"> |
||||
|
<enum>QLineEdit::Password</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_2"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>58</y> |
||||
|
<width>382</width> |
||||
|
<height>56</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string><html><head/><body><p>If you have forgotten your password, restore your wallet with your seed!</p></body></html></string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignCenter</set> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="Line" name="line"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>260</y> |
||||
|
<width>382</width> |
||||
|
<height>3</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="label_3"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>198</y> |
||||
|
<width>146</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Encryption Password:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="lblPasswordMatch"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>175</y> |
||||
|
<width>382</width> |
||||
|
<height>17</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="styleSheet"> |
||||
|
<string notr="true">color: red;</string> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Passwords don't match</string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignCenter</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLineEdit" name="txtPassword"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>162</x> |
||||
|
<y>198</y> |
||||
|
<width>230</width> |
||||
|
<height>25</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="echoMode"> |
||||
|
<enum>QLineEdit::Password</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>startup</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>startup</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
Loading…
Reference in new issue