Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
harbour-MPW
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Andrea Scarpino
harbour-MPW
Commits
cec9125a
Commit
cec9125a
authored
Apr 26, 2016
by
Andrea Scarpino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make master key generation async
parent
89cf71ba
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
210 additions
and
56 deletions
+210
-56
MPW.pro
MPW.pro
+4
-2
qml/pages/Settings.qml
qml/pages/Settings.qml
+18
-2
src/asyncmasterkey.cpp
src/asyncmasterkey.cpp
+60
-0
src/asyncmasterkey.h
src/asyncmasterkey.h
+52
-0
src/mpwmanager.cpp
src/mpwmanager.cpp
+36
-21
src/mpwmanager.h
src/mpwmanager.h
+13
-4
translations/harbour-mpw-it.ts
translations/harbour-mpw-it.ts
+9
-9
translations/harbour-mpw-sv.ts
translations/harbour-mpw-sv.ts
+9
-9
translations/harbour-mpw.ts
translations/harbour-mpw.ts
+9
-9
No files found.
MPW.pro
View file @
cec9125a
...
...
@@ -4,10 +4,12 @@ CONFIG += sailfishapp
SOURCES
+=
\
src
/
main
.
cpp
\
src
/
mpwmanager
.
cpp
src
/
mpwmanager
.
cpp
\
src
/
asyncmasterkey
.
cpp
HEADERS
+=
\
src
/
mpwmanager
.
h
src
/
mpwmanager
.
h
\
src
/
asyncmasterkey
.
h
OTHER_FILES
+=
\
qml
/
cover
/
CoverPage
.
qml
\
...
...
qml/pages/Settings.qml
View file @
cec9125a
...
...
@@ -26,9 +26,18 @@ import QtQuick 2.0
import
Sailfish
.
Silica
1.0
Page
{
allowedOrientations
:
Orientation
.
All
Connections
{
target
:
manager
onGeneratedMasterKey
:
{
busy
.
visible
=
busy
.
running
=
false
;
name
.
enabled
=
password
.
enabled
=
version
.
enabled
=
true
;
pageStack
.
pop
();
}
}
Column
{
id
:
column
x
:
Theme
.
horizontalPageMargin
...
...
@@ -65,6 +74,12 @@ Page {
}
}
BusyIndicator
{
id
:
busy
visible
:
false
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Button
{
id
:
save
text
:
qsTr
(
"
Save
"
);
...
...
@@ -72,8 +87,9 @@ Page {
onClicked
:
{
if
(
name
.
text
.
length
>
0
&&
password
.
text
.
length
>
0
)
{
name
.
enabled
=
password
.
enabled
=
version
.
enabled
=
false
;
busy
.
visible
=
busy
.
running
=
true
;
manager
.
generateMasterKey
(
name
.
text
,
password
.
text
,
version
.
currentIndex
);
pageStack
.
pop
();
}
}
}
...
...
src/asyncmasterkey.cpp
0 → 100644
View file @
cec9125a
/*
The MIT License (MIT)
Copyright (c) 2016 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "asyncmasterkey.h"
#include <QDebug>
extern
"C"
{
#ifndef MPWALGORITHM_H
#define MPWALGORITHM_H
#include <mpw-algorithm.h>
#endif
}
AsyncMasterKey
::
AsyncMasterKey
(
const
QString
&
name
,
const
QString
&
password
,
MPWManager
::
AlgorithmVersion
version
)
:
m_name
(
name
),
m_password
(
password
),
m_algVersion
(
version
)
{
}
AsyncMasterKey
::~
AsyncMasterKey
()
{
}
void
AsyncMasterKey
::
generate
()
{
const
uint8_t
*
k
=
mpw_masterKeyForUser
(
m_name
.
toUtf8
().
data
(),
m_password
.
toUtf8
().
data
(),
MPWManager
::
toMPAlgorithmVersion
(
m_algVersion
));
QByteArray
*
key
=
0
;
if
(
k
)
{
key
=
new
QByteArray
((
const
char
*
)
k
,
MP_dkLen
);
}
else
{
qCritical
()
<<
"Error during master key generation."
;
}
Q_EMIT
finished
(
key
);
}
src/asyncmasterkey.h
0 → 100644
View file @
cec9125a
/*
The MIT License (MIT)
Copyright (c) 2016 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef ASYNCMASTERKEY_H
#define ASYNCMASTERKEY_H
#include <QObject>
#include "mpwmanager.h"
class
AsyncMasterKey
:
public
QObject
{
Q_OBJECT
public:
explicit
AsyncMasterKey
(
const
QString
&
name
,
const
QString
&
password
,
MPWManager
::
AlgorithmVersion
version
);
virtual
~
AsyncMasterKey
();
Q_SIGNALS:
void
finished
(
QByteArray
*
key
);
public
Q_SLOTS
:
void
generate
();
private:
QString
m_name
;
QString
m_password
;
MPWManager
::
AlgorithmVersion
m_algVersion
;
};
#endif // ASYNCMASTERKEY_H
src/mpwmanager.cpp
View file @
cec9125a
...
...
@@ -25,14 +25,18 @@
#include "mpwmanager.h"
#include <QDebug>
#include <QThread>
#include "asyncmasterkey.h"
MPWManager
::
MPWManager
(
QObject
*
parent
)
:
QObject
(
parent
)
m_key
(
0
),
QObject
(
parent
)
{
}
MPWManager
::~
MPWManager
()
{
delete
m_key
;
}
MPWManager
::
AlgorithmVersion
MPWManager
::
getAlgorithmVersion
()
const
...
...
@@ -47,6 +51,8 @@ QString MPWManager::getName() const
void
MPWManager
::
setAlgorithmVersion
(
AlgorithmVersion
version
)
{
qDebug
()
<<
"Using algorithm version:"
<<
version
;
m_algVersion
=
version
;
}
...
...
@@ -59,34 +65,29 @@ void MPWManager::generateMasterKey(const QString &name, const QString &password,
{
setName
(
name
);
setAlgorithmVersion
(
version
);
qDebug
()
<<
"Using algorithm version:"
<<
m_algVersion
;
const
uint8_t
*
k
=
mpw_masterKeyForUser
(
name
.
toUtf8
().
data
(),
password
.
toUtf8
().
data
(),
toMPAlgorithmVersion
(
version
));
if
(
k
)
{
m_key
=
QByteArray
::
fromRawData
((
const
char
*
)
k
,
MP_dkLen
);
}
else
{
qCritical
()
<<
"Error during master key generation."
;
}
QThread
*
thread
=
new
QThread
;
AsyncMasterKey
*
worker
=
new
AsyncMasterKey
(
name
,
password
,
version
);
worker
->
moveToThread
(
thread
);
connect
(
thread
,
&
QThread
::
started
,
worker
,
&
AsyncMasterKey
::
generate
);
connect
(
worker
,
&
AsyncMasterKey
::
finished
,
this
,
&
MPWManager
::
gotMasterKey
);
connect
(
worker
,
&
AsyncMasterKey
::
finished
,
thread
,
&
QThread
::
quit
);
connect
(
worker
,
&
AsyncMasterKey
::
finished
,
worker
,
&
AsyncMasterKey
::
deleteLater
);
connect
(
thread
,
&
QThread
::
finished
,
thread
,
&
QThread
::
deleteLater
);
thread
->
start
();
}
MPAlgorithmVersion
MPWManager
::
toMPAlgorithmVersion
(
AlgorithmVersion
version
)
const
void
MPWManager
::
gotMasterKey
(
QByteArray
*
key
)
{
MPAlgorithmVersion
v
=
MPAlgorithmVersionCurrent
;
switch
(
version
)
{
case
V0
:
v
=
MPAlgorithmVersion0
;
break
;
case
V1
:
v
=
MPAlgorithmVersion1
;
break
;
case
V2
:
v
=
MPAlgorithmVersion2
;
break
;
case
V3
:
v
=
MPAlgorithmVersion3
;
break
;
default:
qCritical
()
<<
"Unrecognized algorithm version:"
<<
version
;
}
qDebug
()
<<
"Storing master key."
;
m_key
=
key
;
return
v
;
Q_EMIT
generatedMasterKey
()
;
}
QString
MPWManager
::
getPassword
(
const
QString
&
site
,
PasswordType
type
,
const
uint
counter
)
const
{
const
char
*
p
=
mpw_passwordForSite
((
const
unsigned
char
*
)
m_key
.
data
(),
site
.
toUtf8
().
data
(),
const
char
*
p
=
mpw_passwordForSite
((
const
unsigned
char
*
)
m_key
->
data
(),
site
.
toUtf8
().
data
(),
toMPSiteType
(
type
),
counter
,
MPSiteVariantPassword
,
NULL
,
toMPAlgorithmVersion
(
m_algVersion
));
...
...
@@ -98,7 +99,21 @@ QString MPWManager::getPassword(const QString &site, PasswordType type, const ui
}
}
MPSiteType
MPWManager
::
toMPSiteType
(
PasswordType
type
)
const
MPAlgorithmVersion
MPWManager
::
toMPAlgorithmVersion
(
AlgorithmVersion
version
)
{
MPAlgorithmVersion
v
=
MPAlgorithmVersionCurrent
;
switch
(
version
)
{
case
V0
:
v
=
MPAlgorithmVersion0
;
break
;
case
V1
:
v
=
MPAlgorithmVersion1
;
break
;
case
V2
:
v
=
MPAlgorithmVersion2
;
break
;
case
V3
:
v
=
MPAlgorithmVersion3
;
break
;
default:
qCritical
()
<<
"Unrecognized algorithm version:"
<<
version
;
}
return
v
;
}
MPSiteType
MPWManager
::
toMPSiteType
(
PasswordType
type
)
{
MPSiteType
t
=
MPSiteTypeGeneratedLong
;
switch
(
type
)
{
...
...
src/mpwmanager.h
View file @
cec9125a
...
...
@@ -29,7 +29,10 @@
extern
"C"
{
#ifndef MPWALGORITHM_H
#define MPWALGORITHM_H
#include <mpw-algorithm.h>
#endif
}
class
MPWManager
:
public
QObject
...
...
@@ -57,13 +60,19 @@ public:
Q_INVOKABLE
void
generateMasterKey
(
const
QString
&
name
,
const
QString
&
password
,
AlgorithmVersion
version
);
Q_INVOKABLE
QString
getPassword
(
const
QString
&
site
,
PasswordType
type
,
const
uint
counter
)
const
;
private:
MPAlgorithmVersion
toMPAlgorithmVersion
(
AlgorithmVersion
version
)
const
;
MPSiteType
toMPSiteType
(
PasswordType
type
)
const
;
static
MPAlgorithmVersion
toMPAlgorithmVersion
(
AlgorithmVersion
version
);
static
MPSiteType
toMPSiteType
(
PasswordType
type
);
Q_SIGNALS:
void
generatedMasterKey
();
QByteArray
m_key
;
protected
Q_SLOTS
:
void
gotMasterKey
(
QByteArray
*
key
);
private:
QString
m_name
;
AlgorithmVersion
m_algVersion
;
QByteArray
*
m_key
;
};
#endif // MPWMANAGER_H
translations/harbour-mpw-it.ts
View file @
cec9125a
...
...
@@ -82,47 +82,47 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
38
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
47
"
/>
<
source
>
Settings
<
/source
>
<
translation
>
Impostazioni
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
45
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
54
"
/>
<
source
>
Full
name
<
/source
>
<
translation
>
Nome
completo
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
51
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
60
"
/>
<
source
>
Master
password
<
/source
>
<
translation
>
Master
password
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
66
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
1
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
1
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
2
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
2
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
3
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
3
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
4
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
4
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
86
"
/>
<
source
>
Save
<
/source
>
<
translation
>
Salva
<
/translation
>
<
/message
>
...
...
translations/harbour-mpw-sv.ts
View file @
cec9125a
...
...
@@ -82,47 +82,47 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
38
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
47
"
/>
<
source
>
Settings
<
/source
>
<
translation
>
Inst
ä
llningar
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
45
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
54
"
/>
<
source
>
Full
name
<
/source
>
<
translation
>
Fullst
ä
ndigt
namn
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
51
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
60
"
/>
<
source
>
Master
password
<
/source
>
<
translation
>
Huvudl
ö
senord
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
66
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
1
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
1
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
2
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
2
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
3
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
3
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
4
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
4
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
86
"
/>
<
source
>
Save
<
/source
>
<
translation
>
Spara
<
/translation
>
<
/message
>
...
...
translations/harbour-mpw.ts
View file @
cec9125a
...
...
@@ -82,47 +82,47 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
38
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
47
"
/>
<
source
>
Settings
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
45
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
54
"
/>
<
source
>
Full
name
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
51
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
60
"
/>
<
source
>
Master
password
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
66
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
1
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
1
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
2
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
2
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
3
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
3
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
6
4
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
7
4
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
86
"
/>
<
source
>
Save
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment