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
fcf0eddb
Commit
fcf0eddb
authored
Apr 24, 2016
by
Andrea Scarpino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support all algorithm versions
parent
212a43c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
167 additions
and
26 deletions
+167
-26
qml/pages/Settings.qml
qml/pages/Settings.qml
+14
-1
src/mpwmanager.cpp
src/mpwmanager.cpp
+51
-20
src/mpwmanager.h
src/mpwmanager.h
+19
-1
translations/harbour-mpw-it.ts
translations/harbour-mpw-it.ts
+29
-2
translations/harbour-mpw-sv.ts
translations/harbour-mpw-sv.ts
+29
-2
translations/harbour-mpw.ts
translations/harbour-mpw.ts
+25
-0
No files found.
qml/pages/Settings.qml
View file @
fcf0eddb
...
...
@@ -52,6 +52,19 @@ Page {
echoMode
:
TextInput
.
Password
}
ComboBox
{
id
:
version
label
:
qsTr
(
"
Algorithm version
"
)
currentIndex
:
3
menu
:
ContextMenu
{
MenuItem
{
text
:
qsTr
(
"
V0
"
)
}
MenuItem
{
text
:
qsTr
(
"
V1
"
)
}
MenuItem
{
text
:
qsTr
(
"
V2
"
)
}
MenuItem
{
text
:
qsTr
(
"
V3
"
)
}
}
}
Button
{
id
:
save
text
:
qsTr
(
"
Save
"
);
...
...
@@ -59,7 +72,7 @@ Page {
onClicked
:
{
if
(
name
.
text
.
length
>
0
&&
password
.
text
.
length
>
0
)
{
manager
.
setUserData
(
name
.
text
,
password
.
text
);
manager
.
generateMasterKey
(
name
.
text
,
password
.
text
,
version
.
currentIndex
);
pageStack
.
pop
();
}
}
...
...
src/mpwmanager.cpp
View file @
fcf0eddb
...
...
@@ -26,11 +26,6 @@
#include <QDebug>
extern
"C"
{
#include <mpw-algorithm.h>
}
MPWManager
::
MPWManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
...
...
@@ -40,28 +35,72 @@ MPWManager::~MPWManager()
{
}
MPWManager
::
AlgorithmVersion
MPWManager
::
getAlgorithmVersion
()
const
{
return
m_algVersion
;
}
QString
MPWManager
::
getName
()
const
{
return
m_name
;
}
void
MPWManager
::
setUserData
(
const
QString
&
name
,
const
QString
&
password
)
void
MPWManager
::
setAlgorithmVersion
(
AlgorithmVersion
version
)
{
m_algVersion
=
version
;
}
void
MPWManager
::
setName
(
const
QString
&
name
)
{
m_name
=
name
;
}
void
MPWManager
::
generateMasterKey
(
const
QString
&
name
,
const
QString
&
password
,
AlgorithmVersion
version
)
{
setName
(
name
);
setAlgorithmVersion
(
version
);
qDebug
()
<<
"Using algorithm version:"
<<
m_algVersion
;
const
uint8_t
*
k
=
mpw_masterKeyForUser
(
name
.
toUtf8
().
data
(),
password
.
toUtf8
().
data
(),
MPAlgorithmVersionCurrent
);
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"
;
qCritical
()
<<
"Error during master key generation."
;
}
}
MPAlgorithmVersion
MPWManager
::
toMPAlgorithmVersion
(
AlgorithmVersion
version
)
const
{
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
;
}
QString
MPWManager
::
getPassword
(
const
QString
&
site
,
PasswordType
type
,
const
uint
counter
)
const
{
MPSiteType
t
=
0
;
const
char
*
p
=
mpw_passwordForSite
((
const
unsigned
char
*
)
m_key
.
data
(),
site
.
toUtf8
().
data
(),
toMPSiteType
(
type
),
counter
,
MPSiteVariantPassword
,
NULL
,
toMPAlgorithmVersion
(
m_algVersion
));
if
(
p
)
{
return
QString
::
fromUtf8
(
p
);
}
else
{
qCritical
()
<<
"Error during password generation."
;
return
QString
();
}
}
MPSiteType
MPWManager
::
toMPSiteType
(
PasswordType
type
)
const
{
MPSiteType
t
=
MPSiteTypeGeneratedLong
;
switch
(
type
)
{
case
Maximum
:
t
=
MPSiteTypeGeneratedMaximum
;
break
;
case
Long
:
t
=
MPSiteTypeGeneratedLong
;
break
;
...
...
@@ -71,16 +110,8 @@ QString MPWManager::getPassword(const QString &site, PasswordType type, const ui
case
PIN
:
t
=
MPSiteTypeGeneratedPIN
;
break
;
case
Name
:
t
=
MPSiteTypeGeneratedName
;
break
;
case
Phrase
:
t
=
MPSiteTypeGeneratedPhrase
;
break
;
default:
qCritical
()
<<
"Unrecognized password type"
<<
type
;
default:
qCritical
()
<<
"Unrecognized password type
:
"
<<
type
;
}
const
char
*
p
=
mpw_passwordForSite
((
const
unsigned
char
*
)
m_key
.
data
(),
site
.
toUtf8
().
data
(),
t
,
counter
,
MPSiteVariantPassword
,
NULL
,
MPAlgorithmVersionCurrent
);
if
(
p
)
{
return
QString
::
fromUtf8
(
p
);
}
else
{
qCritical
()
<<
"Error during password generation"
;
return
QString
();
}
return
t
;
}
src/mpwmanager.h
View file @
fcf0eddb
...
...
@@ -27,6 +27,11 @@
#include <QObject>
extern
"C"
{
#include <mpw-algorithm.h>
}
class
MPWManager
:
public
QObject
{
Q_OBJECT
...
...
@@ -36,16 +41,29 @@ public:
};
Q_ENUMS
(
PasswordType
)
enum
AlgorithmVersion
{
V0
,
V1
,
V2
,
V3
};
Q_ENUMS
(
AlgorithmVersion
)
explicit
MPWManager
(
QObject
*
parent
=
0
);
virtual
~
MPWManager
();
Q_INVOKABLE
AlgorithmVersion
getAlgorithmVersion
()
const
;
Q_INVOKABLE
QString
getName
()
const
;
Q_INVOKABLE
void
setUserData
(
const
QString
&
name
,
const
QString
&
password
);
Q_INVOKABLE
void
setAlgorithmVersion
(
AlgorithmVersion
version
);
Q_INVOKABLE
void
setName
(
const
QString
&
name
);
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
;
QByteArray
m_key
;
QString
m_name
;
AlgorithmVersion
m_algVersion
;
};
#endif // MPWMANAGER_H
translations/harbour-mpw-it.ts
View file @
fcf0eddb
<
?
xml
version
=
"
1.0
"
?
><!
DOCTYPE
TS
><
TS
language
=
"
it
"
version
=
"
2.1
"
>
<
?
xml
version
=
"
1.0
"
encoding
=
"
utf-8
"
?
>
<!
DOCTYPE
TS
>
<
TS
version
=
"
2.1
"
language
=
"
it
"
>
<
context
>
<
name
>
MainPage
<
/name
>
<
message
>
...
...
@@ -96,8 +98,33 @@
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
61
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
62
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
63
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
64
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
source
>
Save
<
/source
>
<
translation
>
Salva
<
/translation
>
<
/message
>
<
/context
>
<
/TS>
\ No newline at end of file
<
/TS
>
translations/harbour-mpw-sv.ts
View file @
fcf0eddb
<
?
xml
version
=
"
1.0
"
?
><!
DOCTYPE
TS
><
TS
language
=
"
sv
"
version
=
"
2.1
"
>
<
?
xml
version
=
"
1.0
"
encoding
=
"
utf-8
"
?
>
<!
DOCTYPE
TS
>
<
TS
version
=
"
2.1
"
language
=
"
sv
"
>
<
context
>
<
name
>
MainPage
<
/name
>
<
message
>
...
...
@@ -96,8 +98,33 @@
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
61
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
62
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
63
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
64
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
source
>
Save
<
/source
>
<
translation
>
Spara
<
/translation
>
<
/message
>
<
/context
>
<
/TS>
\ No newline at end of file
<
/TS
>
translations/harbour-mpw.ts
View file @
fcf0eddb
...
...
@@ -98,6 +98,31 @@
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
57
"
/>
<
source
>
Algorithm
version
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
61
"
/>
<
source
>
V0
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
62
"
/>
<
source
>
V1
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
63
"
/>
<
source
>
V2
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
64
"
/>
<
source
>
V3
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../qml/pages/Settings.qml
"
line
=
"
70
"
/>
<
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