mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00
Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
abb12accc7 | ||
2779e5b7c7 | |||
3970d485f6 | |||
![]() |
7b888cc4a2 | ||
![]() |
117513d6bf | ||
97511ab290 | |||
3131eca8a1 | |||
91a5507217 | |||
7d904b7120 | |||
![]() |
be72fc4f7e | ||
![]() |
ecba11a9a9 | ||
![]() |
65f2e529f4 | ||
![]() |
29e7b22953 | ||
![]() |
a61d4573a6 | ||
![]() |
ce127f55c8 | ||
![]() |
c982a177f7 | ||
![]() |
401630da1e | ||
a8f8715648 | |||
![]() |
a8a3cd5437 | ||
75e18c859c | |||
c33120ec18 | |||
ec0372accd | |||
aa0b21dd31 | |||
ed766848be | |||
c73ce18368 | |||
d996209888 | |||
00278b8710 | |||
10a4941b26 | |||
c3b8c97eea | |||
8e690747e2 | |||
![]() |
53a54252e3 | ||
278b2759d5 | |||
e495a1c2e7 | |||
536bddf442 | |||
a0d1c82afa | |||
473a3700a7 | |||
![]() |
82ef424365 | ||
7e642e3b73 | |||
d32f312d60 | |||
699452667c |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -36,4 +36,6 @@ Translation/TrlUtil.vshost.exe.manifest
|
||||
/UpgradeLog*.htm
|
||||
packages/
|
||||
project.lock.json
|
||||
AppPackages/
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
*.DotSettings
|
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
@@ -3,14 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePass", "ModernKeePass\ModernKeePass.csproj", "{A0CFC681-769B-405A-8482-0CDEE595A91F}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassApp", "ModernKeePass\ModernKeePassApp.csproj", "{A0CFC681-769B-405A-8482-0CDEE595A91F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib", "ModernKeePassLib\ModernKeePassLib.csproj", "{2E710089-9559-4967-846C-E763DD1F3ACB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{067456C0-086C-46A8-B37F-1405717B7BFC}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{2E710089-9559-4967-846C-E763DD1F3ACB} = {2E710089-9559-4967-846C-E763DD1F3ACB}
|
||||
EndProjectSection
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{0A4279CF-2A67-4868-9906-052E50C25F3B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -64,22 +61,30 @@ Global
|
||||
{2E710089-9559-4967-846C-E763DD1F3ACB}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2E710089-9559-4967-846C-E763DD1F3ACB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2E710089-9559-4967-846C-E763DD1F3ACB}.Release|x86.Build.0 = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x64.Build.0 = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.Build.0 = Debug|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.Build.0 = Debug|x86
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.Build.0 = Release|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.ActiveCfg = Release|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.Build.0 = Release|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.Deploy.0 = Release|x64
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.ActiveCfg = Release|x86
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Build.0 = Release|x86
|
||||
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
1
ModernKeePass/.gitignore
vendored
1
ModernKeePass/.gitignore
vendored
@@ -34,3 +34,4 @@ Translation/TrlUtil.vshost.exe.manifest
|
||||
*.nupkg
|
||||
.vs/
|
||||
/UpgradeLog.htm
|
||||
ModernKeePass_StoreKey.pfx
|
26
ModernKeePass/Actions/ClipboardAction.cs
Normal file
26
ModernKeePass/Actions/ClipboardAction.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
|
||||
namespace ModernKeePass.Actions
|
||||
{
|
||||
public class ClipboardAction : DependencyObject, IAction
|
||||
{
|
||||
public string Text
|
||||
{
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
set { SetValue(TextProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty =
|
||||
DependencyProperty.Register("Text", typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty));
|
||||
|
||||
public object Execute(object sender, object parameter)
|
||||
{
|
||||
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
|
||||
dataPackage.SetText(Text);
|
||||
Clipboard.SetContent(dataPackage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,7 +20,6 @@ namespace ModernKeePass
|
||||
sealed partial class App
|
||||
{
|
||||
public DatabaseHelper Database { get; set; } = new DatabaseHelper();
|
||||
public Dictionary<string, IPwEntity> PendingDeleteEntities = new Dictionary<string, IPwEntity>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
@@ -89,11 +88,11 @@ namespace ModernKeePass
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(Pages.MainPage), lauchActivatedEventArgs.Arguments);
|
||||
}
|
||||
else
|
||||
/*else
|
||||
{
|
||||
// App is "launched" via the Toast Activation event
|
||||
UndoEntityDelete(lauchActivatedEventArgs.Arguments);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
// This is only available on Windows 10...
|
||||
/*else if (e is ToastNotificationActivatedEventArgs)
|
||||
@@ -145,14 +144,5 @@ namespace ModernKeePass
|
||||
Window.Current.Activate();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void UndoEntityDelete(string arguments)
|
||||
{
|
||||
if (arguments == null) return;
|
||||
var args = JsonObject.Parse(arguments);
|
||||
var entity = PendingDeleteEntities[args["entityId"].GetString()];
|
||||
PendingDeleteEntities.Remove(args["entityId"].GetString());
|
||||
entity.UndoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +0,0 @@
|
||||
MainPackage=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.5.0.25_AnyCPU.appx
|
||||
SymbolPackage=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\AppPackages\ModernKeePass_1.5.0.25_Test\ModernKeePass_1.5.0.25_AnyCPU.appxsym
|
||||
ResourcePack=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.5.0.25_scale-140.appx
|
||||
ResourcePack=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.5.0.25_scale-180.appx
|
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.ViewModels;
|
||||
using ModernKeePassLib;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Interfaces;
|
||||
using ModernKeePassLib.Keys;
|
||||
using ModernKeePassLib.Serialization;
|
||||
@@ -12,17 +14,38 @@ namespace ModernKeePass.Common
|
||||
{
|
||||
public enum DatabaseStatus
|
||||
{
|
||||
Error = -3,
|
||||
NoCompositeKey = -2,
|
||||
CompositeKeyError = -1,
|
||||
Closed = 0,
|
||||
Opening = 1,
|
||||
Opened = 2
|
||||
}
|
||||
private PwDatabase _pwDatabase = new PwDatabase();
|
||||
private readonly PwDatabase _pwDatabase = new PwDatabase();
|
||||
private StorageFile _databaseFile;
|
||||
private GroupVm _recycleBin;
|
||||
|
||||
public GroupVm RootGroup { get; set; }
|
||||
|
||||
public GroupVm RecycleBin
|
||||
{
|
||||
get { return _recycleBin; }
|
||||
set
|
||||
{
|
||||
_recycleBin = value;
|
||||
_pwDatabase.RecycleBinUuid = _recycleBin.IdUuid;
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseStatus Status { get; private set; } = DatabaseStatus.Closed;
|
||||
public string Name => DatabaseFile?.Name;
|
||||
|
||||
|
||||
public bool RecycleBinEnabled
|
||||
{
|
||||
get { return _pwDatabase.RecycleBinEnabled; }
|
||||
set { _pwDatabase.RecycleBinEnabled = value; }
|
||||
}
|
||||
|
||||
public StorageFile DatabaseFile
|
||||
{
|
||||
get { return _databaseFile; }
|
||||
@@ -32,19 +55,36 @@ namespace ModernKeePass.Common
|
||||
Status = DatabaseStatus.Opening;
|
||||
}
|
||||
}
|
||||
|
||||
public PwUuid DataCipher
|
||||
{
|
||||
get { return _pwDatabase.DataCipherUuid; }
|
||||
set { _pwDatabase.DataCipherUuid = value; }
|
||||
}
|
||||
|
||||
public PwCompressionAlgorithm CompressionAlgorithm
|
||||
{
|
||||
get { return _pwDatabase.Compression; }
|
||||
set { _pwDatabase.Compression = value; }
|
||||
}
|
||||
|
||||
public KdfParameters KeyDerivation
|
||||
{
|
||||
get { return _pwDatabase.KdfParameters; }
|
||||
set { _pwDatabase.KdfParameters = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open a KeePass database
|
||||
/// </summary>
|
||||
/// <param name="password">The database password</param>
|
||||
/// <param name="key">The database composite key</param>
|
||||
/// <param name="createNew">True to create a new database before opening it</param>
|
||||
/// <returns>An error message, if any</returns>
|
||||
public string Open(string password, bool createNew = false)
|
||||
public void Open(CompositeKey key, bool createNew = false)
|
||||
{
|
||||
var key = new CompositeKey();
|
||||
try
|
||||
{
|
||||
key.AddUserKey(new KcpPassword(password));
|
||||
if (key == null) Status = DatabaseStatus.NoCompositeKey;
|
||||
var ioConnection = IOConnectionInfo.FromFile(DatabaseFile);
|
||||
if (createNew) _pwDatabase.New(ioConnection, key);
|
||||
else _pwDatabase.Open(ioConnection, key, new NullStatusLogger());
|
||||
@@ -52,22 +92,17 @@ namespace ModernKeePass.Common
|
||||
if (_pwDatabase.IsOpen)
|
||||
{
|
||||
Status = DatabaseStatus.Opened;
|
||||
RootGroup = new GroupVm(_pwDatabase.RootGroup, null);
|
||||
RootGroup = new GroupVm(_pwDatabase.RootGroup, null, RecycleBinEnabled ? _pwDatabase.RecycleBinUuid : null);
|
||||
}
|
||||
}
|
||||
catch (ArgumentNullException)
|
||||
{
|
||||
return "Password cannot be empty";
|
||||
}
|
||||
catch (InvalidCompositeKeyException)
|
||||
{
|
||||
return "Wrong password";
|
||||
Status = DatabaseStatus.CompositeKeyError;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
Status = DatabaseStatus.Error;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,10 +119,19 @@ namespace ModernKeePass.Common
|
||||
/// <summary>
|
||||
/// Commit the changes to the currently opened database to file
|
||||
/// </summary>
|
||||
public void Save()
|
||||
public bool Save()
|
||||
{
|
||||
if (_pwDatabase != null && _pwDatabase.IsOpen)
|
||||
if (_pwDatabase == null || !_pwDatabase.IsOpen) return false;
|
||||
try
|
||||
{
|
||||
_pwDatabase.Save(new NullStatusLogger());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageDialogHelper.ShowErrorDialog(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,5 +142,22 @@ namespace ModernKeePass.Common
|
||||
_pwDatabase?.Close();
|
||||
Status = DatabaseStatus.Closed;
|
||||
}
|
||||
|
||||
public void AddDeletedItem(PwUuid id)
|
||||
{
|
||||
_pwDatabase.DeletedObjects.Add(new PwDeletedObject(id, DateTime.UtcNow));
|
||||
}
|
||||
|
||||
public void CreateRecycleBin()
|
||||
{
|
||||
RecycleBin = RootGroup.AddNewGroup("Recycle bin");
|
||||
RecycleBin.IsSelected = true;
|
||||
RecycleBin.IconSymbol = Symbol.Delete;
|
||||
}
|
||||
|
||||
public void UpdateCompositeKey(CompositeKey key)
|
||||
{
|
||||
_pwDatabase.MasterKey = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,17 @@
|
||||
using System;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Common
|
||||
{
|
||||
public static class MessageDialogHelper
|
||||
{
|
||||
public static async void ShowDeleteConfirmationDialog(string text, IPwEntity model, Frame backFrame)
|
||||
public static async void ShowDeleteConfirmationDialog(string actionText, string contentText, UICommandInvokedHandler action)
|
||||
{
|
||||
// Create the message dialog and set its content
|
||||
var messageDialog = new MessageDialog(text);
|
||||
var messageDialog = new MessageDialog(contentText);
|
||||
|
||||
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
|
||||
messageDialog.Commands.Add(new UICommand("Delete", delete =>
|
||||
{
|
||||
ToastNotificationHelper.ShowUndoToast(model);
|
||||
model.MarkForDelete();
|
||||
if (backFrame.CanGoBack) backFrame.GoBack();
|
||||
}));
|
||||
messageDialog.Commands.Add(new UICommand(actionText, action));
|
||||
messageDialog.Commands.Add(new UICommand("Cancel"));
|
||||
|
||||
// Set the command that will be invoked by default
|
||||
@@ -31,5 +23,17 @@ namespace ModernKeePass.Common
|
||||
// Show the message dialog
|
||||
await messageDialog.ShowAsync();
|
||||
}
|
||||
|
||||
public static async void ShowErrorDialog(Exception exception)
|
||||
{
|
||||
// Create the message dialog and set its content
|
||||
var messageDialog = new MessageDialog(exception.Message, "Error occured");
|
||||
|
||||
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
|
||||
messageDialog.Commands.Add(new UICommand("OK"));
|
||||
|
||||
// Show the message dialog
|
||||
await messageDialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace ModernKeePass.Common
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
protected void OnPropertyChanged(string propertyName = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Windows.Data.Json;
|
||||
using Windows.Data.Xml.Dom;
|
||||
using Windows.UI.Notifications;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
@@ -10,67 +9,13 @@ namespace ModernKeePass.Common
|
||||
{
|
||||
public static class ToastNotificationHelper
|
||||
{
|
||||
public static /*async*/ void ShowUndoToast(IPwEntity entity)
|
||||
public static void ShowMovedToast(IPwEntity entity, string action, string text)
|
||||
{
|
||||
// This is for Windows 10
|
||||
// Construct the visuals of the toast
|
||||
/*var visual = new ToastVisual
|
||||
{
|
||||
BindingGeneric = new ToastBindingGeneric
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new AdaptiveText
|
||||
{
|
||||
Text = $"{entityType} {entity.Name} deleted."
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Construct the actions for the toast (inputs and buttons)
|
||||
var actions = new ToastActionsCustom
|
||||
{
|
||||
Buttons =
|
||||
{
|
||||
new ToastButton("Undo", new QueryString
|
||||
{
|
||||
{ "action", "undo" },
|
||||
{ "entityType", entityType },
|
||||
{ "entityId", entity.Id }
|
||||
|
||||
}.ToString())
|
||||
}
|
||||
};
|
||||
|
||||
// Now we can construct the final toast content
|
||||
var toastContent = new ToastContent
|
||||
{
|
||||
Visual = visual,
|
||||
Actions = actions,
|
||||
// Arguments when the user taps body of toast
|
||||
Launch = new QueryString()
|
||||
{
|
||||
{ "action", "undo" },
|
||||
{ "entityType", "group" },
|
||||
{ "entityId", entity.Id }
|
||||
|
||||
}.ToString()
|
||||
};
|
||||
|
||||
// And create the toast notification
|
||||
var toastXml = new XmlDocument();
|
||||
toastXml.LoadXml(toastContent.GetContent());
|
||||
|
||||
var toast = new ToastNotification(toastXml) {ExpirationTime = DateTime.Now.AddSeconds(5)};
|
||||
toast.Dismissed += Toast_Dismissed;
|
||||
*/
|
||||
|
||||
var entityType = entity is GroupVm ? "Group" : "Entry";
|
||||
var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
|
||||
var toastElements = notificationXml.GetElementsByTagName("text");
|
||||
toastElements[0].AppendChild(notificationXml.CreateTextNode($"{entityType} {entity.Name} deleted"));
|
||||
toastElements[1].AppendChild(notificationXml.CreateTextNode("Click me to undo"));
|
||||
toastElements[0].AppendChild(notificationXml.CreateTextNode($"{action} {entityType} {entity.Name}"));
|
||||
toastElements[1].AppendChild(notificationXml.CreateTextNode(text));
|
||||
var toastNode = notificationXml.SelectSingleNode("/toast");
|
||||
|
||||
var launch = new JsonObject
|
||||
@@ -84,19 +29,8 @@ namespace ModernKeePass.Common
|
||||
{
|
||||
ExpirationTime = DateTime.Now.AddSeconds(5)
|
||||
};
|
||||
toast.Dismissed += Toast_Dismissed;
|
||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||
}
|
||||
|
||||
private static void Toast_Dismissed(ToastNotification sender, ToastDismissedEventArgs args)
|
||||
{
|
||||
var toastNode = sender.Content.SelectSingleNode("/toast");
|
||||
if (toastNode == null) return;
|
||||
var launchArguments = JsonObject.Parse(((XmlElement)toastNode).GetAttribute("launch"));
|
||||
var app = (App)Application.Current;
|
||||
var entity = app.PendingDeleteEntities[launchArguments["entityId"].GetString()];
|
||||
app.PendingDeleteEntities.Remove(launchArguments["entityId"].GetString());
|
||||
entity.CommitDelete();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
54
ModernKeePass/Controls/CompositeKeyUserControl.xaml
Normal file
54
ModernKeePass/Controls/CompositeKeyUserControl.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Controls.CompositeKeyUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="120"
|
||||
d:DesignWidth="550" >
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="ErrorColorBrush" Color="Red"/>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToForegroungBrushConverter"/>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:DiscreteIntToSolidColorBrushConverter x:Key="DiscreteIntToSolidColorBrushConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="Grid">
|
||||
<!-- DataContext is not set at the root of the control because of issues happening when displaying it -->
|
||||
<Grid.DataContext>
|
||||
<viewModels:CompositeKeyVm />
|
||||
</Grid.DataContext>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="45" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{Binding HasPassword, Mode=TwoWay}" />
|
||||
<PasswordBox Grid.Row="0" Grid.Column="1" x:Name="PasswordBox" Password="{Binding Password, Mode=TwoWay}" Height="30" IsEnabled="{Binding HasPassword}" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" BorderBrush="{Binding StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" >
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding HasPassword}" Value="True">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=PasswordBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<ProgressBar Grid.Row="0" Grid.Column="1"
|
||||
Maximum="128" VerticalAlignment="Bottom"
|
||||
Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}"
|
||||
Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushConverter}}"
|
||||
Visibility="{Binding ShowComplexityIndicator, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding HasKeyFile, Mode=TwoWay}" />
|
||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="{Binding KeyFileText}" IsEnabled="{Binding HasKeyFile}" Click="KeyFileButton_Click" />
|
||||
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" IsEnabled="{Binding IsValid}" />
|
||||
<TextBlock Grid.Column="1" Grid.Row="2" Height="28" FontSize="14" FontWeight="Light" HorizontalAlignment="Right" Text="{Binding Status}" Foreground="{Binding StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -1,16 +1,19 @@
|
||||
using System;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Events;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Controls
|
||||
{
|
||||
public sealed partial class OpenDatabaseUserControl
|
||||
public sealed partial class CompositeKeyUserControl
|
||||
{
|
||||
public CompositeKeyVm Model => Grid.DataContext as CompositeKeyVm;
|
||||
|
||||
public bool CreateNew
|
||||
{
|
||||
get { return (bool)GetValue(CreateNewProperty); }
|
||||
@@ -20,22 +23,24 @@ namespace ModernKeePass.Controls
|
||||
DependencyProperty.Register(
|
||||
"CreateNew",
|
||||
typeof(bool),
|
||||
typeof(OpenDatabaseUserControl),
|
||||
typeof(CompositeKeyUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
|
||||
public string Password
|
||||
public bool UpdateKey
|
||||
{
|
||||
get { return (string)GetValue(PasswordProperty); }
|
||||
set { SetValue(PasswordProperty, value); }
|
||||
get { return (bool)GetValue(UpdateKeyProperty); }
|
||||
set { SetValue(UpdateKeyProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty PasswordProperty =
|
||||
public static readonly DependencyProperty UpdateKeyProperty =
|
||||
DependencyProperty.Register(
|
||||
"Password",
|
||||
typeof(string),
|
||||
typeof(OpenDatabaseUserControl),
|
||||
new PropertyMetadata(string.Empty, (o, args) => { }));
|
||||
"UpdateKey",
|
||||
typeof(bool),
|
||||
typeof(CompositeKeyUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
|
||||
public OpenDatabaseUserControl()
|
||||
public bool ShowComplexityIndicator => CreateNew || UpdateKey;
|
||||
|
||||
public CompositeKeyUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -48,26 +53,33 @@ namespace ModernKeePass.Controls
|
||||
private void OpenButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ValidationChecking?.Invoke(this, new EventArgs());
|
||||
var app = (App)Application.Current;
|
||||
StatusTextBlock.Text = app.Database.Open(PasswordBox.Password, CreateNew);
|
||||
if (app.Database.Status == DatabaseHelper.DatabaseStatus.Opened)
|
||||
|
||||
if (UpdateKey) Model.UpdateKey();
|
||||
else if (Model.OpenDatabase(CreateNew))
|
||||
{
|
||||
ValidationChecked?.Invoke(this, new PasswordEventArgs(app.Database.RootGroup));
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(PasswordBox, "Error", true);
|
||||
ValidationChecked?.Invoke(this, new PasswordEventArgs(Model.RootGroup));
|
||||
}
|
||||
}
|
||||
|
||||
private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Enter) OpenButton_OnClick(null, null);
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(PasswordBox, "Normal", true);
|
||||
StatusTextBlock.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private async void KeyFileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
picker.FileTypeFilter.Add(".key");
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return;
|
||||
Model.KeyFile = file;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,349 +0,0 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Controls.OpenDatabaseUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="60"
|
||||
d:DesignWidth="550" >
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="ErrorColorBrush" Color="Red"/>
|
||||
<Style TargetType="PasswordBox" x:Name="PasswordBoxWithButtonStyle">
|
||||
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}" />
|
||||
<Setter Property="Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}" />
|
||||
<Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource TextBoxBorderThemeBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}" />
|
||||
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
|
||||
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
|
||||
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="PasswordBox">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<Style x:Name="RevealButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverBackgroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0" />
|
||||
<DoubleAnimation Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border x:Name="BorderElement"
|
||||
BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"/>
|
||||
<Border x:Name="BackgroundElement"
|
||||
Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}"
|
||||
Margin="{TemplateBinding BorderThickness}">
|
||||
<TextBlock x:Name="GlyphElement"
|
||||
Foreground="{ThemeResource TextBoxButtonForegroundThemeBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontStyle="Normal"
|
||||
Text=""
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Name="GotoButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" >
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedBackgroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverBackgroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPointerOverForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedBackgroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxButtonPressedForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0" />
|
||||
<DoubleAnimation Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border x:Name="BorderElement"
|
||||
BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"/>
|
||||
<Border x:Name="BackgroundElement"
|
||||
Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}"
|
||||
Margin="{TemplateBinding BorderThickness}">
|
||||
<TextBlock x:Name="GlyphElement"
|
||||
Foreground="{ThemeResource TextBoxButtonForegroundThemeBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontStyle="Normal"
|
||||
Text=""
|
||||
Padding="4,0,4,0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter"
|
||||
Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Normal">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0"
|
||||
To="{ThemeResource TextControlBackgroundThemeOpacity}" />
|
||||
<DoubleAnimation Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0"
|
||||
To="{ThemeResource TextControlBorderThemeOpacity}" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0"
|
||||
To="{ThemeResource TextControlPointerOverBackgroundThemeOpacity}" />
|
||||
<DoubleAnimation Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0"
|
||||
To="{ThemeResource TextControlPointerOverBorderThemeOpacity}" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Error">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
|
||||
Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ErrorColorBrush}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Focused" />
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="ButtonStates">
|
||||
<VisualState x:Name="ButtonVisible">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RevealButton"
|
||||
Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0">
|
||||
<DiscreteObjectKeyFrame.Value>
|
||||
<Visibility>Visible</Visibility>
|
||||
</DiscreteObjectKeyFrame.Value>
|
||||
</DiscreteObjectKeyFrame>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="ButtonCollapsed" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border x:Name="BackgroundElement"
|
||||
Grid.Row="1"
|
||||
Background="{TemplateBinding Background}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="1"/>
|
||||
<Border x:Name="BorderElement"
|
||||
Grid.Row="1"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="1"/>
|
||||
<ContentPresenter x:Name="HeaderContentPresenter"
|
||||
Grid.Row="0"
|
||||
Foreground="{ThemeResource TextBoxForegroundHeaderThemeBrush}"
|
||||
Margin="0,4,0,4"
|
||||
Grid.ColumnSpan="3"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
FontWeight="Semilight" />
|
||||
<ScrollViewer x:Name="ContentElement"
|
||||
Grid.Row="1"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
ZoomMode="Disabled"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
<ContentControl x:Name="PlaceholderTextContentPresenter"
|
||||
Grid.Row="1"
|
||||
Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
Grid.ColumnSpan="3"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Button x:Name="RevealButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource RevealButtonStyle}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
IsTabStop="False"
|
||||
Grid.Column="1"
|
||||
Visibility="Collapsed"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
VerticalAlignment="Stretch"/>
|
||||
<Button x:Name="GotoButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource GotoButtonStyle}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
IsTabStop="False"
|
||||
Grid.Column="2"
|
||||
Visibility="Visible"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
VerticalAlignment="Stretch"
|
||||
Click="OpenButton_OnClick" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<StackPanel>
|
||||
<PasswordBox x:Name="PasswordBox" Password="{Binding Password, ElementName=UserControl, Mode=TwoWay}" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" Style="{StaticResource PasswordBoxWithButtonStyle}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding Visibility, ElementName=UserControl}" Value="Visible">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=PasswordBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<TextBlock x:Name="StatusTextBlock" Height="28" Foreground="{ThemeResource ErrorColorBrush}" FontSize="14" FontWeight="Light" TextWrapping="WrapWholeWords" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
@@ -6,15 +6,38 @@ namespace ModernKeePass.Controls
|
||||
{
|
||||
public class TextBoxWithButton : TextBox
|
||||
{
|
||||
public event EventHandler<RoutedEventArgs> GotoClick;
|
||||
/*public Symbol ButtonSymbol
|
||||
{
|
||||
get { return (Symbol)GetValue(ButtonSymbolProperty); }
|
||||
set { SetValue(ButtonSymbolProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonSymbolProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonSymbol",
|
||||
typeof(Symbol),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(Symbol.Delete, (o, args) => { }));*/
|
||||
|
||||
public string ButtonSymbol
|
||||
{
|
||||
get { return (string)GetValue(ButtonSymbolProperty); }
|
||||
set { SetValue(ButtonSymbolProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonSymbolProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonSymbol",
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata("", (o, args) => { }));
|
||||
public event EventHandler<RoutedEventArgs> ButtonClick;
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
var extraButton = GetTemplateChild("GotoButton") as Button;
|
||||
if (extraButton != null)
|
||||
var actionButton = GetTemplateChild("ActionButton") as Button;
|
||||
if (actionButton != null)
|
||||
{
|
||||
extraButton.Click += (sender, e) => GotoClick?.Invoke(sender, e);
|
||||
actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,15 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public class TextToFontStyleConverter : IValueConverter
|
||||
public class BooleanToFontStyleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var compareValue = parameter as string;
|
||||
var text = value as string;
|
||||
return string.Compare(text, compareValue, StringComparison.OrdinalIgnoreCase) == 0
|
||||
? FontStyle.Italic
|
||||
: FontStyle.Normal;
|
||||
var boolean = value is bool ? (bool)value : false;
|
||||
return boolean ? FontStyle.Italic : FontStyle.Normal;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public class DiscreteIntToSolidColorBrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var status = System.Convert.ToInt32(value);
|
||||
switch (status)
|
||||
{
|
||||
case 1: return new SolidColorBrush(Colors.Red);
|
||||
case 3: return new SolidColorBrush(Colors.Yellow);
|
||||
case 5: return new SolidColorBrush(Colors.Green);
|
||||
default: return new SolidColorBrush(Colors.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public class DoubleToForegroungBrushComplexityConverter : IValueConverter
|
||||
public class DoubleToSolidColorBrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
@@ -21,7 +21,6 @@ namespace ModernKeePass.Converters
|
||||
{
|
||||
return new SolidColorBrush(Color.FromArgb(255, 0, byte.MaxValue, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
18
ModernKeePass/Converters/NullToBooleanConverter.cs
Normal file
18
ModernKeePass/Converters/NullToBooleanConverter.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public class NullToBooleanConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return value != null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,14 +6,33 @@ namespace ModernKeePass.Interfaces
|
||||
public interface IPwEntity
|
||||
{
|
||||
GroupVm ParentGroup { get; }
|
||||
GroupVm PreviousGroup { get; }
|
||||
Symbol IconSymbol { get; }
|
||||
string Id { get; }
|
||||
string Name { get; set; }
|
||||
string Path { get; }
|
||||
bool IsEditMode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Move a entity to the destination group
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination to move the entity to</param>
|
||||
void Move(GroupVm destination);
|
||||
/// <summary>
|
||||
/// Delete from Model
|
||||
/// </summary>
|
||||
void CommitDelete();
|
||||
/// <summary>
|
||||
/// Restore ViewModel
|
||||
/// </summary>
|
||||
void UndoDelete();
|
||||
/// <summary>
|
||||
/// Save changes to Model
|
||||
/// </summary>
|
||||
void Save();
|
||||
/// <summary>
|
||||
/// Delete from ViewModel
|
||||
/// </summary>
|
||||
void MarkForDelete();
|
||||
}
|
||||
}
|
@@ -78,5 +78,400 @@ namespace ModernKeePass.Mappings
|
||||
default: return Symbol.Stop;
|
||||
}
|
||||
}
|
||||
|
||||
public static PwIcon GetIconFromSymbol(Symbol symbol)
|
||||
{
|
||||
switch (symbol)
|
||||
{
|
||||
/*case Symbol.Previous:
|
||||
break;
|
||||
case Symbol.Next:
|
||||
break;
|
||||
case Symbol.Play:
|
||||
break;
|
||||
case Symbol.Pause:
|
||||
break;
|
||||
case Symbol.Edit:
|
||||
break;
|
||||
case Symbol.Save:
|
||||
break;
|
||||
case Symbol.Clear:
|
||||
break;*/
|
||||
case Symbol.Delete:
|
||||
return PwIcon.TrashBin;
|
||||
/*case Symbol.Remove:
|
||||
break;
|
||||
case Symbol.Add:
|
||||
break;
|
||||
case Symbol.Cancel:
|
||||
break;
|
||||
case Symbol.Accept:
|
||||
break;
|
||||
case Symbol.More:
|
||||
break;
|
||||
case Symbol.Redo:
|
||||
break;
|
||||
case Symbol.Undo:
|
||||
break;
|
||||
case Symbol.Home:
|
||||
break;
|
||||
case Symbol.Up:
|
||||
break;
|
||||
case Symbol.Forward:
|
||||
break;
|
||||
case Symbol.Back:
|
||||
break;
|
||||
case Symbol.Favorite:
|
||||
break;
|
||||
case Symbol.Camera:
|
||||
break;
|
||||
case Symbol.Setting:
|
||||
break;
|
||||
case Symbol.Video:
|
||||
break;
|
||||
case Symbol.Sync:
|
||||
break;
|
||||
case Symbol.Download:
|
||||
break;
|
||||
case Symbol.Mail:
|
||||
break;
|
||||
case Symbol.Find:
|
||||
break;
|
||||
case Symbol.Help:
|
||||
break;
|
||||
case Symbol.Upload:
|
||||
break;
|
||||
case Symbol.Emoji:
|
||||
break;
|
||||
case Symbol.TwoPage:
|
||||
break;
|
||||
case Symbol.LeaveChat:
|
||||
break;
|
||||
case Symbol.MailForward:
|
||||
break;
|
||||
case Symbol.Clock:
|
||||
break;
|
||||
case Symbol.Send:
|
||||
break;
|
||||
case Symbol.Crop:
|
||||
break;
|
||||
case Symbol.RotateCamera:
|
||||
break;
|
||||
case Symbol.People:
|
||||
break;
|
||||
case Symbol.OpenPane:
|
||||
break;
|
||||
case Symbol.ClosePane:
|
||||
break;
|
||||
case Symbol.World:
|
||||
break;
|
||||
case Symbol.Flag:
|
||||
break;
|
||||
case Symbol.PreviewLink:
|
||||
break;
|
||||
case Symbol.Globe:
|
||||
break;
|
||||
case Symbol.Trim:
|
||||
break;
|
||||
case Symbol.AttachCamera:
|
||||
break;
|
||||
case Symbol.ZoomIn:
|
||||
break;
|
||||
case Symbol.Bookmarks:
|
||||
break;
|
||||
case Symbol.Document:
|
||||
break;
|
||||
case Symbol.ProtectedDocument:
|
||||
break;
|
||||
case Symbol.Page:
|
||||
break;
|
||||
case Symbol.Bullets:
|
||||
break;
|
||||
case Symbol.Comment:
|
||||
break;
|
||||
case Symbol.MailFilled:
|
||||
break;
|
||||
case Symbol.ContactInfo:
|
||||
break;
|
||||
case Symbol.HangUp:
|
||||
break;
|
||||
case Symbol.ViewAll:
|
||||
break;
|
||||
case Symbol.MapPin:
|
||||
break;
|
||||
case Symbol.Phone:
|
||||
break;
|
||||
case Symbol.VideoChat:
|
||||
break;
|
||||
case Symbol.Switch:
|
||||
break;
|
||||
case Symbol.Contact:
|
||||
break;
|
||||
case Symbol.Rename:
|
||||
break;
|
||||
case Symbol.Pin:
|
||||
break;
|
||||
case Symbol.MusicInfo:
|
||||
break;
|
||||
case Symbol.Go:
|
||||
break;
|
||||
case Symbol.Keyboard:
|
||||
break;
|
||||
case Symbol.DockLeft:
|
||||
break;
|
||||
case Symbol.DockRight:
|
||||
break;
|
||||
case Symbol.DockBottom:
|
||||
break;
|
||||
case Symbol.Remote:
|
||||
break;
|
||||
case Symbol.Refresh:
|
||||
break;
|
||||
case Symbol.Rotate:
|
||||
break;
|
||||
case Symbol.Shuffle:
|
||||
break;
|
||||
case Symbol.List:
|
||||
break;
|
||||
case Symbol.Shop:
|
||||
break;
|
||||
case Symbol.SelectAll:
|
||||
break;
|
||||
case Symbol.Orientation:
|
||||
break;
|
||||
case Symbol.Import:
|
||||
break;
|
||||
case Symbol.ImportAll:
|
||||
break;
|
||||
case Symbol.BrowsePhotos:
|
||||
break;
|
||||
case Symbol.WebCam:
|
||||
break;
|
||||
case Symbol.Pictures:
|
||||
break;
|
||||
case Symbol.SaveLocal:
|
||||
break;
|
||||
case Symbol.Caption:
|
||||
break;
|
||||
case Symbol.Stop:
|
||||
break;
|
||||
case Symbol.ShowResults:
|
||||
break;
|
||||
case Symbol.Volume:
|
||||
break;
|
||||
case Symbol.Repair:
|
||||
break;
|
||||
case Symbol.Message:
|
||||
break;
|
||||
case Symbol.Page2:
|
||||
break;
|
||||
case Symbol.CalendarDay:
|
||||
break;
|
||||
case Symbol.CalendarWeek:
|
||||
break;
|
||||
case Symbol.Calendar:
|
||||
break;
|
||||
case Symbol.Character:
|
||||
break;
|
||||
case Symbol.MailReplyAll:
|
||||
break;
|
||||
case Symbol.Read:
|
||||
break;
|
||||
case Symbol.Link:
|
||||
break;
|
||||
case Symbol.Account:
|
||||
break;
|
||||
case Symbol.ShowBcc:
|
||||
break;
|
||||
case Symbol.HideBcc:
|
||||
break;
|
||||
case Symbol.Cut:
|
||||
break;
|
||||
case Symbol.Attach:
|
||||
break;
|
||||
case Symbol.Paste:
|
||||
break;
|
||||
case Symbol.Filter:
|
||||
break;
|
||||
case Symbol.Copy:
|
||||
break;
|
||||
case Symbol.Emoji2:
|
||||
break;
|
||||
case Symbol.Important:
|
||||
break;
|
||||
case Symbol.MailReply:
|
||||
break;
|
||||
case Symbol.SlideShow:
|
||||
break;
|
||||
case Symbol.Sort:
|
||||
break;
|
||||
case Symbol.Manage:
|
||||
break;
|
||||
case Symbol.AllApps:
|
||||
break;
|
||||
case Symbol.DisconnectDrive:
|
||||
break;
|
||||
case Symbol.MapDrive:
|
||||
break;
|
||||
case Symbol.NewWindow:
|
||||
break;
|
||||
case Symbol.OpenWith:
|
||||
break;
|
||||
case Symbol.ContactPresence:
|
||||
break;
|
||||
case Symbol.Priority:
|
||||
break;
|
||||
case Symbol.GoToToday:
|
||||
break;
|
||||
case Symbol.Font:
|
||||
break;
|
||||
case Symbol.FontColor:
|
||||
break;
|
||||
case Symbol.Contact2:
|
||||
break;
|
||||
case Symbol.Folder:
|
||||
break;
|
||||
case Symbol.Audio:
|
||||
break;
|
||||
case Symbol.Placeholder:
|
||||
break;
|
||||
case Symbol.View:
|
||||
break;
|
||||
case Symbol.SetLockScreen:
|
||||
break;
|
||||
case Symbol.SetTile:
|
||||
break;
|
||||
case Symbol.ClosedCaption:
|
||||
break;
|
||||
case Symbol.StopSlideShow:
|
||||
break;
|
||||
case Symbol.Permissions:
|
||||
break;
|
||||
case Symbol.Highlight:
|
||||
break;
|
||||
case Symbol.DisableUpdates:
|
||||
break;
|
||||
case Symbol.UnFavorite:
|
||||
break;
|
||||
case Symbol.UnPin:
|
||||
break;
|
||||
case Symbol.OpenLocal:
|
||||
break;
|
||||
case Symbol.Mute:
|
||||
break;
|
||||
case Symbol.Italic:
|
||||
break;
|
||||
case Symbol.Underline:
|
||||
break;
|
||||
case Symbol.Bold:
|
||||
break;
|
||||
case Symbol.MoveToFolder:
|
||||
break;
|
||||
case Symbol.LikeDislike:
|
||||
break;
|
||||
case Symbol.Dislike:
|
||||
break;
|
||||
case Symbol.Like:
|
||||
break;
|
||||
case Symbol.AlignRight:
|
||||
break;
|
||||
case Symbol.AlignCenter:
|
||||
break;
|
||||
case Symbol.AlignLeft:
|
||||
break;
|
||||
case Symbol.Zoom:
|
||||
break;
|
||||
case Symbol.ZoomOut:
|
||||
break;
|
||||
case Symbol.OpenFile:
|
||||
break;
|
||||
case Symbol.OtherUser:
|
||||
break;
|
||||
case Symbol.Admin:
|
||||
break;
|
||||
case Symbol.Street:
|
||||
break;
|
||||
case Symbol.Map:
|
||||
break;
|
||||
case Symbol.ClearSelection:
|
||||
break;
|
||||
case Symbol.FontDecrease:
|
||||
break;
|
||||
case Symbol.FontIncrease:
|
||||
break;
|
||||
case Symbol.FontSize:
|
||||
break;
|
||||
case Symbol.CellPhone:
|
||||
break;
|
||||
case Symbol.ReShare:
|
||||
break;
|
||||
case Symbol.Tag:
|
||||
break;
|
||||
case Symbol.RepeatOne:
|
||||
break;
|
||||
case Symbol.RepeatAll:
|
||||
break;
|
||||
case Symbol.OutlineStar:
|
||||
break;
|
||||
case Symbol.SolidStar:
|
||||
break;
|
||||
case Symbol.Calculator:
|
||||
break;
|
||||
case Symbol.Directions:
|
||||
break;
|
||||
case Symbol.Target:
|
||||
break;
|
||||
case Symbol.Library:
|
||||
break;
|
||||
case Symbol.PhoneBook:
|
||||
break;
|
||||
case Symbol.Memo:
|
||||
break;
|
||||
case Symbol.Microphone:
|
||||
break;
|
||||
case Symbol.PostUpdate:
|
||||
break;
|
||||
case Symbol.BackToWindow:
|
||||
break;
|
||||
case Symbol.FullScreen:
|
||||
break;
|
||||
case Symbol.NewFolder:
|
||||
break;
|
||||
case Symbol.CalendarReply:
|
||||
break;
|
||||
case Symbol.UnSyncFolder:
|
||||
break;
|
||||
case Symbol.ReportHacked:
|
||||
break;
|
||||
case Symbol.SyncFolder:
|
||||
break;
|
||||
case Symbol.BlockContact:
|
||||
break;
|
||||
case Symbol.SwitchApps:
|
||||
break;
|
||||
case Symbol.AddFriend:
|
||||
break;
|
||||
case Symbol.TouchPointer:
|
||||
break;
|
||||
case Symbol.GoToStart:
|
||||
break;
|
||||
case Symbol.ZeroBars:
|
||||
break;
|
||||
case Symbol.OneBar:
|
||||
break;
|
||||
case Symbol.TwoBars:
|
||||
break;
|
||||
case Symbol.ThreeBars:
|
||||
break;
|
||||
case Symbol.FourBars:
|
||||
break;
|
||||
case Symbol.Scan:
|
||||
break;
|
||||
case Symbol.Preview:
|
||||
break;*/
|
||||
default:
|
||||
return PwIcon.Folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp70</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=viewmodels_005Citems/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@@ -108,6 +108,7 @@
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Actions\ClipboardAction.cs" />
|
||||
<Compile Include="Actions\SetupFocusAction.cs" />
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
@@ -120,20 +121,28 @@
|
||||
<Compile Include="Common\RelayCommand.cs" />
|
||||
<Compile Include="Common\SuspensionManager.cs" />
|
||||
<Compile Include="Common\ToastNotificationHelper.cs" />
|
||||
<Compile Include="Converters\DiscreteIntToSolidColorBrushConverter.cs" />
|
||||
<Compile Include="Converters\NullToBooleanConverter.cs" />
|
||||
<Compile Include="Interfaces\IHasSelectableObject.cs" />
|
||||
<Compile Include="Interfaces\ISelectableModel.cs" />
|
||||
<Compile Include="Pages\BasePages\LayoutAwarePageBase.cs" />
|
||||
<Compile Include="Pages\SettingsPageFrames\SettingsDatabasePage.xaml.cs">
|
||||
<DependentUpon>SettingsDatabasePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\SettingsPageFrames\SettingsSecurityPage.xaml.cs">
|
||||
<DependentUpon>SettingsSecurityPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TemplateSelectors\FirstItemDataTemplateSelector.cs" />
|
||||
<Compile Include="Controls\ListViewWithDisable.cs" />
|
||||
<Compile Include="Controls\OpenDatabaseUserControl.xaml.cs">
|
||||
<DependentUpon>OpenDatabaseUserControl.xaml</DependentUpon>
|
||||
<Compile Include="Controls\CompositeKeyUserControl.xaml.cs">
|
||||
<DependentUpon>CompositeKeyUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\TextBoxWithButton.cs" />
|
||||
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\ColorToBrushConverter.cs" />
|
||||
<Compile Include="Converters\DoubleToForegroungBrushComplexityConverter.cs" />
|
||||
<Compile Include="Converters\DoubleToSolidColorBrushConverter.cs" />
|
||||
<Compile Include="Converters\InverseBooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\TextToFontStyleConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToFontStyleConverter.cs" />
|
||||
<Compile Include="Converters\PluralizationConverter.cs" />
|
||||
<Compile Include="Converters\ProgressBarLegalValuesConverter.cs" />
|
||||
<Compile Include="Converters\TextToWidthConverter.cs" />
|
||||
@@ -157,6 +166,8 @@
|
||||
<DependentUpon>WelcomePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewModels\AboutVm.cs" />
|
||||
<Compile Include="ViewModels\CompositeKeyVm.cs" />
|
||||
<Compile Include="ViewModels\Items\ListMenuItemVm.cs" />
|
||||
<Compile Include="ViewModels\Items\MainMenuItemVm.cs" />
|
||||
<Compile Include="ViewModels\Items\RecentItemVm.cs" />
|
||||
<Compile Include="Pages\EntryDetailPage.xaml.cs">
|
||||
@@ -177,11 +188,13 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ViewModels\EntryVm.cs" />
|
||||
<Compile Include="ViewModels\GroupVm.cs" />
|
||||
<Compile Include="ViewModels\SettingsVm.cs" />
|
||||
<Compile Include="ViewModels\MainVm.cs" />
|
||||
<Compile Include="ViewModels\NewVm.cs" />
|
||||
<Compile Include="ViewModels\OpenVm.cs" />
|
||||
<Compile Include="ViewModels\RecentVm.cs" />
|
||||
<Compile Include="ViewModels\SaveVm.cs" />
|
||||
<Compile Include="ViewModels\Items\SettingsDatabaseVm.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
@@ -201,7 +214,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Controls\OpenDatabaseUserControl.xaml">
|
||||
<Page Include="Controls\CompositeKeyUserControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@@ -245,6 +258,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\SettingsPageFrames\SettingsDatabasePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\SettingsPageFrames\SettingsSecurityPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Styles\HamburgerButtonStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -275,6 +296,10 @@
|
||||
<HintPath>..\packages\Microsoft.Toolkit.Uwp.Notifications.2.0.0\lib\dotnet\Microsoft.Toolkit.Uwp.Notifications.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ModernKeePassLib, Version=2.37.0.2000, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ModernKeePassLib.2.37.6000\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -284,7 +309,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Validation.2.4.15\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
|
||||
<HintPath>..\packages\Validation.2.4.18\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@@ -335,15 +360,6 @@
|
||||
<Content Include="Assets\Wide310x150Logo.scale-180.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-80.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ModernKeePassLib\ModernKeePassLib.csproj">
|
||||
<Project>{2e710089-9559-4967-846c-e763dd1f3acb}</Project>
|
||||
<Name>ModernKeePassLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Pages\SettingsPageFrames\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
||||
<VisualStudioVersion>12.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
|
||||
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.5.0.25" />
|
||||
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.8.0.28" />
|
||||
<Properties>
|
||||
<DisplayName>ModernKeePass</DisplayName>
|
||||
<PublisherDisplayName>wismna</PublisherDisplayName>
|
||||
|
@@ -5,7 +5,6 @@ using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Pages.BasePages
|
||||
{
|
||||
|
@@ -16,7 +16,8 @@
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
|
||||
<converters:DoubleToForegroungBrushComplexityConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
|
||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||
<Style TargetType="PasswordBox" x:Name="PasswordBoxWithButtonStyle">
|
||||
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
|
||||
@@ -348,6 +349,8 @@
|
||||
<CheckBox IsChecked="{Binding SpacePatternSelected, Mode=TwoWay}" Content="Space ( )"/>
|
||||
<CheckBox IsChecked="{Binding SpecialPatternSelected, Mode=TwoWay}" Content="Special (!, $, %, ...)"/>
|
||||
<CheckBox IsChecked="{Binding BracketsPatternSelected, Mode=TwoWay}" Content="Brackets ([], {}, (), ...)"/>
|
||||
<TextBlock Text="Also add these characters:" Margin="0,5,0,0"/>
|
||||
<TextBox Text="{Binding CustomChars, Mode=TwoWay}" />
|
||||
<Button Content="Generate">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
@@ -379,13 +382,13 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<!--<AppBarButton Icon="Setting" Label="Settings">
|
||||
<AppBarButton Icon="Setting" Label="Settings">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.SettingsPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>-->
|
||||
</AppBarButton>
|
||||
</CommandBar.SecondaryCommands>
|
||||
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
@@ -394,6 +397,13 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarToggleButton>
|
||||
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:CallMethodAction MethodName="UndoDelete" TargetObject="{Binding}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Delete" Label="Delete" Click="DeleteButton_Click" />
|
||||
</CommandBar>
|
||||
</Page.BottomAppBar>
|
||||
@@ -404,7 +414,7 @@
|
||||
</TransitionCollection>
|
||||
</Grid.ChildrenTransitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
@@ -418,14 +428,26 @@
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock TextWrapping="Wrap" Text="User name or login" FontSize="18"/>
|
||||
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" />
|
||||
<local:TextBoxWithButton HorizontalAlignment="Left" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{Binding UserName}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:TextBoxWithButton>
|
||||
<TextBlock TextWrapping="Wrap" Text="Password" FontSize="18"/>
|
||||
<PasswordBox HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Style="{StaticResource PasswordBoxWithButtonStyle}" />
|
||||
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<local:TextBoxWithButton HorizontalAlignment="Left" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{Binding Password}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:TextBoxWithButton>
|
||||
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" />
|
||||
<CheckBox HorizontalAlignment="Left" Margin="-3,0,0,0" Content="Show password" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}" IsEnabled="{Binding IsRevealPasswordEnabled}" />
|
||||
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
|
||||
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" />
|
||||
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" ButtonClick="UrlButton_Click" ButtonSymbol="" />
|
||||
<TextBlock TextWrapping="Wrap" Text="Notes" FontSize="18"/>
|
||||
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" />
|
||||
<CheckBox FontSize="18" IsChecked="{Binding HasExpirationDate, Mode=TwoWay}" Content="Expiration date"/>
|
||||
@@ -450,7 +472,7 @@
|
||||
<Button Grid.Column="0"
|
||||
x:Name="BackButton"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Height="40"
|
||||
Height="50"
|
||||
Width="50"
|
||||
VerticalAlignment="Center"
|
||||
AutomationProperties.Name="Back"
|
||||
@@ -459,25 +481,27 @@
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<SymbolIcon Symbol="Back" />
|
||||
</Button>
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
x:Name="TitleTextBox"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
Background="Transparent"
|
||||
IsHitTestVisible="{Binding IsEditMode}"
|
||||
BorderThickness="0"
|
||||
FontSize="24"
|
||||
FontWeight="SemiBold"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalAlignment="Center"
|
||||
PlaceholderText="New group name...">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding IsEditMode}" Value="True">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<StackPanel Grid.Column="1" >
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
Background="Transparent"
|
||||
IsHitTestVisible="{Binding IsEditMode}"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalAlignment="Center"
|
||||
PlaceholderText="New entry name...">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding IsEditMode}" Value="True">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock FontSize="12" Text="{Binding Path}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -18,21 +16,19 @@ namespace ModernKeePass.Pages
|
||||
/// </summary>
|
||||
public sealed partial class EntryDetailPage
|
||||
{
|
||||
private NavigationHelper navigationHelper;
|
||||
|
||||
public EntryVm Model => (EntryVm) DataContext;
|
||||
|
||||
/// <summary>
|
||||
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
|
||||
/// gestion de la durée de vie des processus
|
||||
/// </summary>
|
||||
public NavigationHelper NavigationHelper => navigationHelper;
|
||||
public NavigationHelper NavigationHelper { get; }
|
||||
|
||||
public EntryDetailPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
navigationHelper = new NavigationHelper(this);
|
||||
navigationHelper.LoadState += navigationHelper_LoadState;
|
||||
NavigationHelper = new NavigationHelper(this);
|
||||
NavigationHelper.LoadState += navigationHelper_LoadState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -61,21 +57,37 @@ namespace ModernKeePass.Pages
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedTo(e);
|
||||
NavigationHelper.OnNavigatedTo(e);
|
||||
if (!(e.Parameter is EntryVm)) return;
|
||||
DataContext = (EntryVm)e.Parameter;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedFrom(e);
|
||||
NavigationHelper.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageDialogHelper.ShowDeleteConfirmationDialog("Are you sure you want to delete this entry?", Model, Frame);
|
||||
var isRecycleBinEnabled = ((App)Application.Current).Database.RecycleBinEnabled && !Model.ParentGroup.IsSelected;
|
||||
var message = isRecycleBinEnabled
|
||||
? "Are you sure you want to send this entry to the recycle bin?"
|
||||
: "Are you sure you want to delete this entry?";
|
||||
var text = isRecycleBinEnabled ? "Item moved to the Recycle bin" : "Item permanently removed";
|
||||
MessageDialogHelper.ShowDeleteConfirmationDialog("Delete", message, a =>
|
||||
{
|
||||
ToastNotificationHelper.ShowMovedToast(Model, "Deleting", text);
|
||||
Model.MarkForDelete();
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
});
|
||||
}
|
||||
|
||||
private void RestoreButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToastNotificationHelper.ShowMovedToast(Model, "Restored", "Item returned to its original group");
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
}
|
||||
|
||||
private async void UrlButton_Click(object sender, RoutedEventArgs e)
|
||||
|
@@ -16,7 +16,9 @@
|
||||
<SolidColorBrush x:Key="Transparent" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="SystemColor" Color="{StaticResource SystemColorButtonFaceColor}" />
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||
<converters:TextToFontStyleConverter x:Key="TextToFontStyleConverter"/>
|
||||
<converters:BooleanToFontStyleConverter x:Key="BooleanToFontStyleConverter"/>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:GroupVm />
|
||||
@@ -32,13 +34,13 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<!--<AppBarButton Icon="Setting" Label="Settings">
|
||||
<AppBarButton Icon="Setting" Label="Settings">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.SettingsPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>-->
|
||||
</AppBarButton>
|
||||
</CommandBar.SecondaryCommands>
|
||||
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
@@ -47,6 +49,13 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarToggleButton>
|
||||
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:CallMethodAction MethodName="UndoDelete" TargetObject="{Binding}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="DeleteButton_Click" />
|
||||
</CommandBar>
|
||||
</Page.BottomAppBar>
|
||||
@@ -71,7 +80,7 @@
|
||||
</TransitionCollection>
|
||||
</Grid.ChildrenTransitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1">
|
||||
@@ -101,8 +110,7 @@
|
||||
<DataTemplate x:Name="Expanded">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0" />
|
||||
<TextBlock Text="{Binding Name}" FontWeight="{Binding FontWeight}" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" FontStyle="{Binding Name, ConverterParameter=Recycle Bin, Converter={StaticResource TextToFontStyleConverter}}" />
|
||||
<!--<TextBlock Text="{Binding EntryCount}" HorizontalAlignment="Right" VerticalAlignment="Center" />-->
|
||||
<TextBlock Text="{Binding Name}" FontWeight="{Binding FontWeight}" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" FontStyle="{Binding IsSelected, Converter={StaticResource BooleanToFontStyleConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.Resources>
|
||||
@@ -161,12 +169,12 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" RenderTransformOrigin="0.5,0.5" Foreground="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" >
|
||||
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" RenderTransformOrigin="0.5,0.5" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" >
|
||||
<SymbolIcon.RenderTransform>
|
||||
<CompositeTransform ScaleX="2" TranslateX="0" TranslateY="0" ScaleY="2"/>
|
||||
</SymbolIcon.RenderTransform>
|
||||
</SymbolIcon>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold" Style="{ThemeResource TitleTextBlockStyle}" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="13,0,0,5"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold" Style="{ThemeResource TitleTextBlockStyle}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="13,0,0,5"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
@@ -189,10 +197,7 @@
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,10,0,0" >
|
||||
<TextBlock x:Name="NameTextBlock" Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource TextBoxForegroundThemeBrush}, Converter={StaticResource ColorToBrushConverter}}"/>
|
||||
<!--<Line Visibility="{Binding HasExpired, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,-10,0,0" Stretch="Fill" Stroke="{Binding ForegroundColor, ConverterParameter={StaticResource TextBoxForegroundThemeBrush}, Converter={StaticResource ColorToBrushConverter}}" StrokeThickness="1" X1="1" Width="{Binding Name, Converter={StaticResource TextToWidthConverter}, ConverterParameter=7}" HorizontalAlignment="Left" VerticalAlignment="Center" />-->
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
<!--<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||
<TextBlock Text="{Binding GroupCount, ConverterParameter=group\,groups, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />-->
|
||||
<TextBlock Text="{Binding UserName}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||
<TextBlock Text="{Binding Url}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||
</StackPanel>
|
||||
@@ -263,7 +268,7 @@
|
||||
<Button Grid.Column="0"
|
||||
x:Name="BackButton"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Height="40"
|
||||
Height="50"
|
||||
Width="50"
|
||||
VerticalAlignment="Center"
|
||||
AutomationProperties.Name="Back"
|
||||
@@ -272,25 +277,27 @@
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<SymbolIcon Symbol="Back" />
|
||||
</Button>
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
x:Name="TitleTextBox"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
Background="Transparent"
|
||||
IsHitTestVisible="{Binding IsEditMode}"
|
||||
BorderThickness="0"
|
||||
FontSize="24"
|
||||
FontWeight="SemiBold"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalAlignment="Center"
|
||||
PlaceholderText="New group name...">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding IsEditMode}" Value="True">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<StackPanel Grid.Column="1" >
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
Background="Transparent"
|
||||
IsHitTestVisible="{Binding IsEditMode}"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalAlignment="Center"
|
||||
PlaceholderText="New group name...">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{Binding IsEditMode}" Value="True">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock FontSize="12" Text="{Binding Path}" />
|
||||
</StackPanel>
|
||||
<SearchBox Grid.Column="2" PlaceholderText="Search..." Width="350" Background="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" BorderThickness="0" FontSize="18" SuggestionsRequested="SearchBox_OnSuggestionsRequested" SearchHistoryEnabled="False" ResultSuggestionChosen="SearchBox_OnResultSuggestionChosen" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -75,8 +72,7 @@ namespace ModernKeePass.Pages
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -87,7 +83,7 @@ namespace ModernKeePass.Pages
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
group = Model.CreateNewGroup();
|
||||
group = Model.AddNewGroup();
|
||||
break;
|
||||
default:
|
||||
group = LeftListView.SelectedItem as GroupVm;
|
||||
@@ -104,7 +100,7 @@ namespace ModernKeePass.Pages
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
entry = Model.CreateNewEntry();
|
||||
entry = Model.AddNewEntry();
|
||||
break;
|
||||
default:
|
||||
entry = GridView.SelectedItem as EntryVm;
|
||||
@@ -115,9 +111,25 @@ namespace ModernKeePass.Pages
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageDialogHelper.ShowDeleteConfirmationDialog("Are you sure you want to delete the whole group and all its entries?", Model, Frame);
|
||||
var isRecycleBinEnabled = ((App)Application.Current).Database.RecycleBinEnabled && !Model.IsSelected && !Model.ParentGroup.IsSelected;
|
||||
var message = isRecycleBinEnabled
|
||||
? "Are you sure you want to send the whole group and all its entries to the recycle bin?"
|
||||
: "Are you sure you want to delete the whole group and all its entries?";
|
||||
var text = isRecycleBinEnabled ? "Item moved to the Recycle bin" : "Item permanently removed";
|
||||
MessageDialogHelper.ShowDeleteConfirmationDialog("Delete", message, a =>
|
||||
{
|
||||
ToastNotificationHelper.ShowMovedToast(Model, "Deleting", text);
|
||||
Model.MarkForDelete();
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void RestoreButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ToastNotificationHelper.ShowMovedToast(Model, "Restored", "Item returned to its original group");
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
}
|
||||
|
||||
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
|
||||
{
|
||||
// We need to synchronize the two lists (zoomed-in and zoomed-out) because the source is different
|
||||
|
@@ -130,12 +130,6 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuListView" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuFrame" Storyboard.TargetProperty="(Grid.Row)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuFrame" Storyboard.TargetProperty="(Grid.RowSpan)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>-->
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitlePanel" Storyboard.TargetProperty="(Grid.Column)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
@@ -148,9 +142,6 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageTitleTextBlock" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="60,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuFrame" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="10,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>-->
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
@@ -32,7 +32,7 @@
|
||||
<Run Text="Dominik Reichl for the KeePass application and file format"/>
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
|
||||
<Run Text="ArtjomP for his PCL adapatation of the KeePass Library"/>
|
||||
<Run Text="David Lechner for his PCL adapatation of the KeePass Library and his correlated tests"/>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Page>
|
||||
|
@@ -7,12 +7,11 @@
|
||||
xmlns:local="using:ModernKeePass.Controls"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
|
||||
<converters:DoubleToForegroungBrushComplexityConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:NewVm />
|
||||
@@ -24,16 +23,15 @@
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<local:OpenDatabaseUserControl Password="{Binding Password, Mode=TwoWay}" CreateNew="True" >
|
||||
<local:CompositeKeyUserControl CreateNew="True" >
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<Core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<Core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||
</Core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:OpenDatabaseUserControl>
|
||||
<TextBlock >Password complexity</TextBlock>
|
||||
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="500" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" />
|
||||
</local:CompositeKeyUserControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Page>
|
||||
|
||||
|
@@ -24,13 +24,13 @@
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<local:OpenDatabaseUserControl>
|
||||
<local:CompositeKeyUserControl>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<Core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<Core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||
</Core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:OpenDatabaseUserControl>
|
||||
</local:CompositeKeyUserControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
@@ -6,7 +6,8 @@
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:local="using:ModernKeePass.Controls"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
@@ -33,13 +34,13 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{Binding Name}" Padding="5,0,0,0" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
|
||||
<local:OpenDatabaseUserControl Grid.Row="2" x:Name="DatabaseUserControl" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecking="OpenDatabaseUserControl_OnValidationChecking" >
|
||||
<local:CompositeKeyUserControl Grid.Row="2" x:Name="DatabaseUserControl" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecking="OpenDatabaseUserControl_OnValidationChecking">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<Core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<Core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||
</Core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:OpenDatabaseUserControl>
|
||||
</local:CompositeKeyUserControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.ViewModels;
|
||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Pages
|
||||
{
|
||||
@@ -13,25 +11,17 @@ namespace ModernKeePass.Pages
|
||||
/// </summary>
|
||||
public sealed partial class RecentDatabasesPage
|
||||
{
|
||||
private Frame _mainFrame;
|
||||
|
||||
public RecentVm Model => (RecentVm)DataContext;
|
||||
|
||||
public RecentDatabasesPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
_mainFrame = e.Parameter as Frame;
|
||||
}
|
||||
|
||||
private void OpenDatabaseUserControl_OnValidationChecking(object sender, EventArgs e)
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.Database.DatabaseFile = Model.SelectedItem.DatabaseFile;
|
||||
app.Database.DatabaseFile = ((RecentItemVm)Model.SelectedItem).DatabaseFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,144 +1,111 @@
|
||||
<Page
|
||||
x:Name="pageRoot"
|
||||
x:Class="ModernKeePass.Pages.SettingsPage"
|
||||
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
|
||||
<basePages:LayoutAwarePageBase
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:ModernKeePass.Pages"
|
||||
xmlns:common="using:ModernKeePass.Common"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:basePages="using:ModernKeePass.Pages.BasePages"
|
||||
xmlns:controls="using:ModernKeePass.Controls"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
x:Name="PageRoot"
|
||||
x:Class="ModernKeePass.Pages.SettingsPage"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<!-- Collection of items displayed by this page -->
|
||||
<CollectionViewSource
|
||||
x:Name="itemsViewSource"
|
||||
Source="{Binding Items}"/>
|
||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" >
|
||||
</CollectionViewSource>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:SettingsVM />
|
||||
</Page.DataContext>
|
||||
|
||||
<!--
|
||||
This grid acts as a root panel for the page that defines two rows:
|
||||
* Row 0 contains the back button and page title
|
||||
* Row 1 contains the rest of the page layout
|
||||
-->
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</Page.Background>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ChildrenTransitions>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</Grid.ChildrenTransitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="140"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="primaryColumn" Width="420"/>
|
||||
<ColumnDefinition x:Name="secondaryColumn" Width="*"/>
|
||||
<ColumnDefinition x:Name="PrimaryColumn" Width="250" />
|
||||
<ColumnDefinition x:Name="SecondaryColumn" Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Back button and page title -->
|
||||
<Grid x:Name="titlePanel">
|
||||
<Grid x:Name="TitlePanel" Background="{ThemeResource AppBarBackgroundThemeBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
VerticalAlignment="Top"
|
||||
AutomationProperties.Name="Back"
|
||||
AutomationProperties.AutomationId="BackButton"
|
||||
AutomationProperties.ItemType="Navigation Button"/>
|
||||
<TextBlock x:Name="pageTitle" Text="{Binding Title}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
||||
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,0,40"/>
|
||||
<Button x:Name="BackButton"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Height="50"
|
||||
AutomationProperties.Name="Back"
|
||||
AutomationProperties.AutomationId="BackButton"
|
||||
AutomationProperties.ItemType="Navigation Button"
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<SymbolIcon Symbol="Back" />
|
||||
</Button>
|
||||
<TextBlock x:Name="TitleTextBox" Text="Settings" Grid.Column="1" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
|
||||
<!-- Vertical scrolling item list -->
|
||||
<ListView
|
||||
x:Name="itemListView"
|
||||
AutomationProperties.AutomationId="ItemsListView"
|
||||
AutomationProperties.Name="Items"
|
||||
TabIndex="1"
|
||||
<controls:ListViewWithDisable
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Margin="-10,-10,0,0"
|
||||
Padding="120,0,0,60"
|
||||
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
|
||||
IsSwipeEnabled="False"
|
||||
SelectionChanged="ItemListView_SelectionChanged">
|
||||
<ListView.ItemTemplate>
|
||||
x:Name="MenuListView"
|
||||
SelectionChanged="MenuListView_SelectionChanged"
|
||||
Background="{ThemeResource AppBarBackgroundThemeBrush}"
|
||||
ItemsSource="{Binding Source={StaticResource MenuItemsSource}}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<controls:ListViewWithDisable.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="60" Height="60">
|
||||
<Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Margin="10,0,0,0">
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" MaxHeight="40"/>
|
||||
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding SymbolIcon}" />
|
||||
<TextBlock Text="{Binding Title}" Margin="10,5,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="FrameworkElement">
|
||||
<Setter Property="Margin" Value="0,0,0,10"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
|
||||
|
||||
<!-- Details for selected item -->
|
||||
<ScrollViewer
|
||||
x:Name="itemDetail"
|
||||
AutomationProperties.AutomationId="ItemDetailScrollViewer"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"
|
||||
Padding="60,0,66,0"
|
||||
DataContext="{Binding SelectedItem, ElementName=itemListView}"
|
||||
HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Enabled"
|
||||
ScrollViewer.ZoomMode="Disabled">
|
||||
|
||||
<Grid x:Name="itemDetailGrid" Margin="0,60,0,50">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image Grid.Row="1" Margin="0,0,20,0" Width="180" Height="180" Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
|
||||
<StackPanel x:Name="itemDetailTitlePanel" Grid.Row="1" Grid.Column="1">
|
||||
<TextBlock x:Name="itemTitle" Margin="0,-10,0,0" Text="{Binding Title}" Style="{StaticResource SubheaderTextBlockStyle}"/>
|
||||
<TextBlock x:Name="itemSubtitle" Margin="0,0,0,20" Text="{Binding Subtitle}" Style="{StaticResource SubtitleTextBlockStyle}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Text="{Binding Content}" Style="{StaticResource BodyTextBlockStyle}"/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</controls:ListViewWithDisable.ItemTemplate>
|
||||
<controls:ListViewWithDisable.GroupStyle>
|
||||
<GroupStyle HidesIfEmpty="True">
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Background="DarkGray" Margin="20,0,0,0">
|
||||
<Border Height="1" Width="300" HorizontalAlignment="Stretch"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</controls:ListViewWithDisable.GroupStyle>
|
||||
</controls:ListViewWithDisable>
|
||||
<TextBlock x:Name="PageTitleTextBlock" Grid.Column="1" Grid.Row="0" FontSize="24" VerticalAlignment="Center" Margin="10,0,0,0" >
|
||||
<Run Text="{Binding SelectedItem}" />
|
||||
</TextBlock>
|
||||
<Frame x:Name="MenuFrame" Grid.Column="1" Grid.Row="1" Margin="0,10,0,0" />
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
|
||||
<!-- Visual states reflect the application's view state -->
|
||||
<VisualStateGroup x:Name="ViewStates">
|
||||
<VisualState x:Name="PrimaryView" />
|
||||
<VisualState x:Name="SinglePane">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PrimaryColumn" Storyboard.TargetProperty="Width">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="secondaryColumn" Storyboard.TargetProperty="Width">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondaryColumn" Storyboard.TargetProperty="Width">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Visibility">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuFrame" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Padding">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageTitleTextBlock" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuListView" Storyboard.TargetProperty="Padding">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="120,0,90,60"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
@@ -152,30 +119,27 @@
|
||||
-->
|
||||
<VisualState x:Name="SinglePane_Detail">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PrimaryColumn" Storyboard.TargetProperty="Width">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuListView" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.Row)">
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitlePanel" Storyboard.TargetProperty="(Grid.Column)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.RowSpan)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackButton" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="titlePanel" Storyboard.TargetProperty="(Grid.Column)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleTextBox" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetailGrid" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,60"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Padding">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="120,0,90,0"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageTitleTextBlock" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="60,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
</Page>
|
||||
</basePages:LayoutAwarePageBase>
|
||||
|
@@ -1,20 +1,5 @@
|
||||
using ModernKeePass.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Windows.Input;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.ViewManagement;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Split Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234234
|
||||
|
||||
@@ -24,232 +9,23 @@ namespace ModernKeePass.Pages
|
||||
/// A page that displays a group title, a list of items within the group, and details for
|
||||
/// the currently selected item.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsPage : Page
|
||||
public sealed partial class SettingsPage
|
||||
{
|
||||
private NavigationHelper navigationHelper;
|
||||
private ObservableDictionary defaultViewModel = new ObservableDictionary();
|
||||
|
||||
/// <summary>
|
||||
/// This can be changed to a strongly typed view model.
|
||||
/// </summary>
|
||||
public ObservableDictionary DefaultViewModel
|
||||
{
|
||||
get { return this.defaultViewModel; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NavigationHelper is used on each page to aid in navigation and
|
||||
/// process lifetime management
|
||||
/// </summary>
|
||||
public NavigationHelper NavigationHelper
|
||||
{
|
||||
get { return this.navigationHelper; }
|
||||
}
|
||||
public new SettingsVM Model => (SettingsVM)DataContext;
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Setup the navigation helper
|
||||
this.navigationHelper = new NavigationHelper(this);
|
||||
this.navigationHelper.LoadState += navigationHelper_LoadState;
|
||||
this.navigationHelper.SaveState += navigationHelper_SaveState;
|
||||
|
||||
// Setup the logical page navigation components that allow
|
||||
// the page to only show one pane at a time.
|
||||
this.navigationHelper.GoBackCommand = new ModernKeePass.Common.RelayCommand(() => this.GoBack(), () => this.CanGoBack());
|
||||
this.itemListView.SelectionChanged += itemListView_SelectionChanged;
|
||||
|
||||
// Start listening for Window size changes
|
||||
// to change from showing two panes to showing a single pane
|
||||
Window.Current.SizeChanged += Window_SizeChanged;
|
||||
this.InvalidateVisualState();
|
||||
InitializeComponent();
|
||||
ListView = MenuListView;
|
||||
ListViewSource = MenuItemsSource;
|
||||
}
|
||||
|
||||
void itemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
||||
private void MenuListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (this.UsingLogicalPageNavigation())
|
||||
{
|
||||
this.navigationHelper.GoBackCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
ListView_SelectionChanged(sender, e);
|
||||
var selectedItem = Model.SelectedItem as ListMenuItemVm;
|
||||
if (selectedItem == null) return;
|
||||
MenuFrame?.Navigate(selectedItem.PageType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the page with content passed during navigation. Any saved state is also
|
||||
/// provided when recreating a page from a prior session.
|
||||
/// </summary>
|
||||
/// <param name="sender">
|
||||
/// The source of the event; typically <see cref="Common.NavigationHelper"/>
|
||||
/// </param>
|
||||
/// <param name="e">Event data that provides both the navigation parameter passed to
|
||||
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
|
||||
/// a dictionary of state preserved by this page during an earlier
|
||||
/// session. The state will be null the first time a page is visited.</param>
|
||||
private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
|
||||
{
|
||||
// TODO: Assign a bindable group to Me.DefaultViewModel("Group")
|
||||
// TODO: Assign a collection of bindable items to Me.DefaultViewModel("Items")
|
||||
|
||||
if (e.PageState == null)
|
||||
{
|
||||
// When this is a new page, select the first item automatically unless logical page
|
||||
// navigation is being used (see the logical page navigation #region below.)
|
||||
if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null)
|
||||
{
|
||||
this.itemsViewSource.View.MoveCurrentToFirst();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restore the previously saved state associated with this page
|
||||
if (e.PageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null)
|
||||
{
|
||||
// TODO: Invoke Me.itemsViewSource.View.MoveCurrentTo() with the selected
|
||||
// item as specified by the value of pageState("SelectedItem")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preserves state associated with this page in case the application is suspended or the
|
||||
/// page is discarded from the navigation cache. Values must conform to the serialization
|
||||
/// requirements of <see cref="Common.SuspensionManager.SessionState"/>.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event; typically <see cref="Common.NavigationHelper"/></param>
|
||||
/// <param name="e">Event data that provides an empty dictionary to be populated with
|
||||
/// serializable state.</param>
|
||||
private void navigationHelper_SaveState(object sender, SaveStateEventArgs e)
|
||||
{
|
||||
if (this.itemsViewSource.View != null)
|
||||
{
|
||||
// TODO: Derive a serializable navigation parameter and assign it to
|
||||
// pageState("SelectedItem")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region Logical page navigation
|
||||
|
||||
// The split page is designed so that when the Window does have enough space to show
|
||||
// both the list and the details, only one pane will be shown at at time.
|
||||
//
|
||||
// This is all implemented with a single physical page that can represent two logical
|
||||
// pages. The code below achieves this goal without making the user aware of the
|
||||
// distinction.
|
||||
|
||||
private const int MinimumWidthForSupportingTwoPanes = 768;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked to determine whether the page should act as one logical page or two.
|
||||
/// </summary>
|
||||
/// <returns>True if the window should show act as one logical page, false
|
||||
/// otherwise.</returns>
|
||||
private bool UsingLogicalPageNavigation()
|
||||
{
|
||||
return Window.Current.Bounds.Width < MinimumWidthForSupportingTwoPanes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked with the Window changes size
|
||||
/// </summary>
|
||||
/// <param name="sender">The current Window</param>
|
||||
/// <param name="e">Event data that describes the new size of the Window</param>
|
||||
private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
|
||||
{
|
||||
this.InvalidateVisualState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when an item within the list is selected.
|
||||
/// </summary>
|
||||
/// <param name="sender">The GridView displaying the selected item.</param>
|
||||
/// <param name="e">Event data that describes how the selection was changed.</param>
|
||||
private void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
// Invalidate the view state when logical page navigation is in effect, as a change
|
||||
// in selection may cause a corresponding change in the current logical page. When
|
||||
// an item is selected this has the effect of changing from displaying the item list
|
||||
// to showing the selected item's details. When the selection is cleared this has the
|
||||
// opposite effect.
|
||||
if (this.UsingLogicalPageNavigation()) this.InvalidateVisualState();
|
||||
}
|
||||
|
||||
private bool CanGoBack()
|
||||
{
|
||||
if (this.UsingLogicalPageNavigation() && this.itemListView.SelectedItem != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.navigationHelper.CanGoBack();
|
||||
}
|
||||
}
|
||||
private void GoBack()
|
||||
{
|
||||
if (this.UsingLogicalPageNavigation() && this.itemListView.SelectedItem != null)
|
||||
{
|
||||
// When logical page navigation is in effect and there's a selected item that
|
||||
// item's details are currently displayed. Clearing the selection will return to
|
||||
// the item list. From the user's point of view this is a logical backward
|
||||
// navigation.
|
||||
this.itemListView.SelectedItem = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.navigationHelper.GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
private void InvalidateVisualState()
|
||||
{
|
||||
var visualState = DetermineVisualState();
|
||||
VisualStateManager.GoToState(this, visualState, false);
|
||||
this.navigationHelper.GoBackCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked to determine the name of the visual state that corresponds to an application
|
||||
/// view state.
|
||||
/// </summary>
|
||||
/// <returns>The name of the desired visual state. This is the same as the name of the
|
||||
/// view state except when there is a selected item in portrait and snapped views where
|
||||
/// this additional logical page is represented by adding a suffix of _Detail.</returns>
|
||||
private string DetermineVisualState()
|
||||
{
|
||||
if (!UsingLogicalPageNavigation())
|
||||
return "PrimaryView";
|
||||
|
||||
// Update the back button's enabled state when the view state changes
|
||||
var logicalPageBack = this.UsingLogicalPageNavigation() && this.itemListView.SelectedItem != null;
|
||||
|
||||
return logicalPageBack ? "SinglePane_Detail" : "SinglePane";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NavigationHelper registration
|
||||
|
||||
/// The methods provided in this section are simply used to allow
|
||||
/// NavigationHelper to respond to the page's navigation methods.
|
||||
///
|
||||
/// Page specific logic should be placed in event handlers for the
|
||||
/// <see cref="Common.NavigationHelper.LoadState"/>
|
||||
/// and <see cref="Common.NavigationHelper.SaveState"/>.
|
||||
/// The navigation parameter is available in the LoadState method
|
||||
/// in addition to page state preserved during an earlier session.
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Pages.SettingsDatabasePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
|
||||
<CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
|
||||
<CollectionViewSource x:Name="Compressions" Source="{Binding Compressions}" />
|
||||
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:SettingsDatabaseVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<ToggleSwitch Header="Recycle bin" OffContent="Disabled" OnContent="Enabled" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" />
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsEnabled="{Binding HasRecycleBin}" />
|
||||
<TextBlock Text="Encryption Algorithm" FontSize="14" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" SelectedIndex="{Binding CipherIndex, Mode=TwoWay}" />
|
||||
<TextBlock Text="Compression Algorithm" FontSize="14" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" />
|
||||
<TextBlock Text="Key Derivation Algorithm" FontSize="14" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding KeyDerivationName, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsDatabasePage
|
||||
{
|
||||
public SettingsDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Pages.SettingsSecurityPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:ModernKeePass.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<TextBlock Text="Change database security options" />
|
||||
<local:CompositeKeyUserControl UpdateKey="True" />
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsSecurityPage
|
||||
{
|
||||
public SettingsSecurityPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,6 +24,6 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||
[assembly: AssemblyVersion("1.8.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0.0")]
|
||||
[assembly: ComVisible(false)]
|
@@ -1,8 +1,9 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:ModernKeePass.Controls">
|
||||
|
||||
<Style TargetType="TextBox" x:Name="TextBoxWithButtonStyle">
|
||||
<Style TargetType="controls:TextBoxWithButton" x:Name="TextBoxWithButtonStyle">
|
||||
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}" />
|
||||
@@ -18,10 +19,10 @@
|
||||
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<ControlTemplate TargetType="controls:TextBoxWithButton">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<Style x:Name="GotoButtonStyle" TargetType="Button">
|
||||
<Style x:Name="ActionButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
@@ -87,7 +88,7 @@
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontStyle="Normal"
|
||||
Text=""
|
||||
Text="{TemplateBinding Content}"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
</Border>
|
||||
@@ -148,7 +149,7 @@
|
||||
<VisualStateGroup x:Name="ButtonStates">
|
||||
<VisualState x:Name="ButtonVisible">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GotoButton"
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ActionButton"
|
||||
Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0">
|
||||
<DiscreteObjectKeyFrame.Value>
|
||||
@@ -212,14 +213,15 @@
|
||||
Grid.ColumnSpan="2"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Button x:Name="GotoButton"
|
||||
<Button x:Name="ActionButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource GotoButtonStyle}"
|
||||
Style="{StaticResource ActionButtonStyle}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
IsTabStop="False"
|
||||
Grid.Column="1"
|
||||
Visibility="Collapsed"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
Content="{TemplateBinding ButtonSymbol}"
|
||||
VerticalAlignment="Stretch"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
134
ModernKeePass/ViewModels/CompositeKeyVm.cs
Normal file
134
ModernKeePass/ViewModels/CompositeKeyVm.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System.Text;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Keys;
|
||||
using ModernKeePassLib.Serialization;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class CompositeKeyVm: NotifyPropertyChangedBase
|
||||
{
|
||||
public enum StatusTypes
|
||||
{
|
||||
Normal = 0,
|
||||
Error = 1,
|
||||
Warning = 3,
|
||||
Success = 5
|
||||
}
|
||||
|
||||
private readonly App _app = Application.Current as App;
|
||||
private bool _hasPassword;
|
||||
private bool _hasKeyFile;
|
||||
private string _password = string.Empty;
|
||||
private string _status;
|
||||
private StatusTypes _statusType;
|
||||
private StorageFile _keyFile;
|
||||
private string _keyFileText = "Select key file from disk...";
|
||||
|
||||
public bool HasPassword
|
||||
{
|
||||
get { return _hasPassword; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref _hasPassword, value);
|
||||
OnPropertyChanged("IsValid");
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasKeyFile
|
||||
{
|
||||
get { return _hasKeyFile; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref _hasKeyFile, value);
|
||||
OnPropertyChanged("IsValid");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsValid => HasPassword || HasKeyFile && KeyFile != null;
|
||||
|
||||
public string Status
|
||||
{
|
||||
get { return _status; }
|
||||
set { SetProperty(ref _status, value); }
|
||||
}
|
||||
|
||||
public int StatusType
|
||||
{
|
||||
get { return (int)_statusType; }
|
||||
set { SetProperty(ref _statusType, (StatusTypes)value); }
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return _password; }
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
OnPropertyChanged("PasswordComplexityIndicator");
|
||||
StatusType = (int)StatusTypes.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
public StorageFile KeyFile
|
||||
{
|
||||
get { return _keyFile; }
|
||||
set
|
||||
{
|
||||
_keyFile = value;
|
||||
KeyFileText = value?.Name;
|
||||
OnPropertyChanged("IsValid");
|
||||
}
|
||||
}
|
||||
|
||||
public string KeyFileText
|
||||
{
|
||||
get { return _keyFileText; }
|
||||
set { SetProperty(ref _keyFileText, value); }
|
||||
}
|
||||
|
||||
public GroupVm RootGroup { get; set; }
|
||||
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password?.ToCharArray());
|
||||
|
||||
public bool OpenDatabase(bool createNew)
|
||||
{
|
||||
_app.Database.Open(CreateCompositeKey(), createNew);
|
||||
switch (_app.Database.Status)
|
||||
{
|
||||
case DatabaseHelper.DatabaseStatus.Opened:
|
||||
RootGroup = _app.Database.RootGroup;
|
||||
return true;
|
||||
case DatabaseHelper.DatabaseStatus.CompositeKeyError:
|
||||
var errorMessage = new StringBuilder("Error: wrong ");
|
||||
if (HasPassword) errorMessage.Append("password");
|
||||
if (HasPassword && HasKeyFile) errorMessage.Append(" or ");
|
||||
if (HasKeyFile) errorMessage.Append("key file");
|
||||
UpdateStatus(errorMessage.ToString(), StatusTypes.Error);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateKey()
|
||||
{
|
||||
_app.Database.UpdateCompositeKey(CreateCompositeKey());
|
||||
UpdateStatus("Database composite key updated.", StatusTypes.Success);
|
||||
}
|
||||
|
||||
private void UpdateStatus(string text, StatusTypes type)
|
||||
{
|
||||
Status = text;
|
||||
StatusType = (int)type;
|
||||
}
|
||||
|
||||
private CompositeKey CreateCompositeKey()
|
||||
{
|
||||
var compositeKey = new CompositeKey();
|
||||
if (HasPassword) compositeKey.AddUserKey(new KcpPassword(Password));
|
||||
if (HasKeyFile) compositeKey.AddUserKey(new KcpKeyFile(IOConnectionInfo.FromFile(KeyFile)));
|
||||
return compositeKey;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,28 +1,31 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Mappings;
|
||||
using ModernKeePassLib;
|
||||
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
||||
using ModernKeePassLib.Security;
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class EntryVm : INotifyPropertyChanged, IPwEntity
|
||||
{
|
||||
public GroupVm ParentGroup { get; }
|
||||
public PwEntry Entry { get; }
|
||||
public GroupVm ParentGroup { get; private set; }
|
||||
|
||||
public System.Drawing.Color? BackgroundColor => Entry?.BackgroundColor;
|
||||
public System.Drawing.Color? ForegroundColor => Entry?.ForegroundColor;
|
||||
public GroupVm PreviousGroup { get; private set; }
|
||||
|
||||
public System.Drawing.Color? BackgroundColor => _pwEntry?.BackgroundColor;
|
||||
public System.Drawing.Color? ForegroundColor => _pwEntry?.ForegroundColor;
|
||||
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
|
||||
public bool HasExpired => HasExpirationDate && Entry.ExpiryTime < DateTime.Now;
|
||||
public bool HasExpired => HasExpirationDate && _pwEntry.ExpiryTime < DateTime.Now;
|
||||
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
|
||||
public bool IsFirstItem => _pwEntry == null;
|
||||
|
||||
|
||||
public double PasswordLength { get; set; } = 25;
|
||||
public bool UpperCasePatternSelected { get; set; } = true;
|
||||
public bool LowerCasePatternSelected { get; set; } = true;
|
||||
public bool DigitsPatternSelected { get; set; } = true;
|
||||
@@ -32,24 +35,35 @@ namespace ModernKeePass.ViewModels
|
||||
public bool SpecialPatternSelected { get; set; }
|
||||
public bool BracketsPatternSelected { get; set; }
|
||||
public string CustomChars { get; set; } = string.Empty;
|
||||
public PwUuid IdUuid => _pwEntry?.Uuid;
|
||||
|
||||
public double PasswordLength
|
||||
{
|
||||
get { return _passwordLength; }
|
||||
set
|
||||
{
|
||||
_passwordLength = value;
|
||||
NotifyPropertyChanged("PasswordLength");
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var title = GetEntryValue(PwDefs.TitleField);
|
||||
return title == null ? "New entry" : title;
|
||||
return title == null ? "< New entry >" : title;
|
||||
}
|
||||
set { SetEntryValue(PwDefs.TitleField, value); }
|
||||
}
|
||||
|
||||
public string Id => Entry.Uuid.ToHexString();
|
||||
public string Id => _pwEntry?.Uuid.ToHexString();
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.UserNameField); }
|
||||
set { SetEntryValue(PwDefs.UserNameField, value); }
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.PasswordField); }
|
||||
@@ -75,22 +89,23 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Entry == null) return Symbol.Add;
|
||||
if (_pwEntry == null) return Symbol.Add;
|
||||
if (HasExpired) return Symbol.Priority;
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(Entry.IconId);
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwEntry.IconId);
|
||||
return result == Symbol.More ? Symbol.Permissions : result;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTimeOffset ExpiryDate
|
||||
{
|
||||
get { return new DateTimeOffset(Entry.ExpiryTime.Date); }
|
||||
set { if (HasExpirationDate) Entry.ExpiryTime = value.DateTime; }
|
||||
get { return new DateTimeOffset(_pwEntry.ExpiryTime.Date); }
|
||||
set { if (HasExpirationDate) _pwEntry.ExpiryTime = value.DateTime; }
|
||||
}
|
||||
|
||||
public TimeSpan ExpiryTime
|
||||
{
|
||||
get { return Entry.ExpiryTime.TimeOfDay; }
|
||||
set { if (HasExpirationDate) Entry.ExpiryTime = Entry.ExpiryTime.Date.Add(value); }
|
||||
get { return _pwEntry.ExpiryTime.TimeOfDay; }
|
||||
set { if (HasExpirationDate) _pwEntry.ExpiryTime = _pwEntry.ExpiryTime.Date.Add(value); }
|
||||
}
|
||||
|
||||
public bool IsEditMode
|
||||
@@ -114,18 +129,31 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
public bool HasExpirationDate
|
||||
{
|
||||
get { return Entry.Expires; }
|
||||
get { return _pwEntry.Expires; }
|
||||
set
|
||||
{
|
||||
Entry.Expires = value;
|
||||
_pwEntry.Expires = value;
|
||||
NotifyPropertyChanged("HasExpirationDate");
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = new StringBuilder(ParentGroup.Path);
|
||||
path.Append($" > {ParentGroup.Name}");
|
||||
return path.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private readonly PwEntry _pwEntry;
|
||||
private readonly App _app = Application.Current as App;
|
||||
private bool _isEditMode;
|
||||
private bool _isRevealPassword;
|
||||
private double _passwordLength = 25;
|
||||
|
||||
private void NotifyPropertyChanged(string propertyName)
|
||||
{
|
||||
@@ -135,11 +163,10 @@ namespace ModernKeePass.ViewModels
|
||||
public EntryVm() { }
|
||||
public EntryVm(PwEntry entry, GroupVm parent)
|
||||
{
|
||||
Entry = entry;
|
||||
_pwEntry = entry;
|
||||
ParentGroup = parent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void GeneratePassword()
|
||||
{
|
||||
var pwProfile = new PwProfile()
|
||||
@@ -163,7 +190,7 @@ namespace ModernKeePass.ViewModels
|
||||
ProtectedString password;
|
||||
PwGenerator.Generate(out password, pwProfile, null, new CustomPwGeneratorPool());
|
||||
|
||||
Entry?.Strings.Set(PwDefs.PasswordField, password);
|
||||
_pwEntry?.Strings.Set(PwDefs.PasswordField, password);
|
||||
NotifyPropertyChanged("Password");
|
||||
NotifyPropertyChanged("IsRevealPasswordEnabled");
|
||||
NotifyPropertyChanged("PasswordComplexityIndicator");
|
||||
@@ -171,34 +198,51 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
private string GetEntryValue(string key)
|
||||
{
|
||||
return Entry?.Strings.GetSafe(key).ReadString();
|
||||
return _pwEntry?.Strings.GetSafe(key).ReadString();
|
||||
}
|
||||
|
||||
private void SetEntryValue(string key, string newValue)
|
||||
{
|
||||
Entry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||
}
|
||||
|
||||
public void MarkForDelete()
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.PendingDeleteEntities.Add(Id, this);
|
||||
ParentGroup.Entries.Remove(this);
|
||||
}
|
||||
public void CommitDelete()
|
||||
{
|
||||
Entry.ParentGroup.Entries.Remove(Entry);
|
||||
if (_app.Database.RecycleBinEnabled && _app.Database.RecycleBin?.IdUuid == null)
|
||||
_app.Database.CreateRecycleBin();
|
||||
Move(_app.Database.RecycleBinEnabled && !ParentGroup.IsSelected ? _app.Database.RecycleBin : null);
|
||||
}
|
||||
|
||||
public void UndoDelete()
|
||||
{
|
||||
Move(PreviousGroup);
|
||||
}
|
||||
|
||||
public void Move(GroupVm destination)
|
||||
{
|
||||
PreviousGroup = ParentGroup;
|
||||
PreviousGroup.Entries.Remove(this);
|
||||
PreviousGroup.RemovePwEntry(_pwEntry);
|
||||
if (destination == null)
|
||||
{
|
||||
_app.Database.AddDeletedItem(IdUuid);
|
||||
return;
|
||||
}
|
||||
ParentGroup = destination;
|
||||
ParentGroup.Entries.Add(this);
|
||||
ParentGroup.AddPwEntry(_pwEntry);
|
||||
}
|
||||
|
||||
public void CommitDelete()
|
||||
{
|
||||
_pwEntry.ParentGroup.Entries.Remove(_pwEntry);
|
||||
if (_app.Database.RecycleBinEnabled && !PreviousGroup.IsSelected) _app.Database.RecycleBin.AddPwEntry(_pwEntry);
|
||||
else _app.Database.AddDeletedItem(IdUuid);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.Database.Save();
|
||||
_app.Database.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -7,38 +8,52 @@ using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Mappings;
|
||||
using ModernKeePassLib;
|
||||
using System;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class GroupVm : NotifyPropertyChangedBase, IPwEntity
|
||||
public class GroupVm : NotifyPropertyChangedBase, IPwEntity, ISelectableModel
|
||||
{
|
||||
public GroupVm ParentGroup { get; }
|
||||
public GroupVm ParentGroup { get; private set; }
|
||||
public GroupVm PreviousGroup { get; private set; }
|
||||
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
||||
|
||||
public ObservableCollection<GroupVm> Groups { get; set; } = new ObservableCollection<GroupVm>();
|
||||
|
||||
public int EntryCount => Entries.Count() - 1;
|
||||
public int GroupCount => Groups.Count - 1;
|
||||
public bool IsNotRoot => ParentGroup != null;
|
||||
public FontWeight FontWeight => _pwGroup == null ? FontWeights.Bold : FontWeights.Normal;
|
||||
public string Id => _pwGroup.Uuid.ToHexString();
|
||||
public int GroupCount => Groups.Count - 1;
|
||||
public PwUuid IdUuid => _pwGroup?.Uuid;
|
||||
public string Id => IdUuid?.ToHexString();
|
||||
public bool IsNotRoot => ParentGroup != null;
|
||||
|
||||
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut
|
||||
public bool ShowRestore => IsNotRoot && ParentGroup.IsSelected;
|
||||
/// <summary>
|
||||
/// Is the Group the database Recycle Bin?
|
||||
/// </summary>
|
||||
public bool IsSelected
|
||||
{
|
||||
get
|
||||
get { return _app.Database.RecycleBinEnabled && _app.Database.RecycleBin?.Id == Id; }
|
||||
set
|
||||
{
|
||||
return from e in Entries
|
||||
where e.Entry != null
|
||||
group e by e.Name.FirstOrDefault() into grp
|
||||
orderby grp.Key
|
||||
select grp;
|
||||
if (value && _pwGroup != null) _app.Database.RecycleBin = this;
|
||||
/*else if (value && _pwGroup == null)
|
||||
{
|
||||
var recycleBin = _app.Database.RootGroup.AddNewGroup("Recycle bin");
|
||||
recycleBin.IsSelected = true;
|
||||
recycleBin.IconSymbol = Symbol.Delete;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut => from e in Entries
|
||||
where !e.IsFirstItem
|
||||
group e by e.Name.FirstOrDefault() into grp
|
||||
orderby grp.Key
|
||||
select grp;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _pwGroup == null ? "New group" : _pwGroup.Name; }
|
||||
get { return _pwGroup == null ? "< New group >" : _pwGroup.Name; }
|
||||
set { _pwGroup.Name = value; }
|
||||
}
|
||||
|
||||
@@ -50,6 +65,7 @@ namespace ModernKeePass.ViewModels
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwGroup.IconId);
|
||||
return result == Symbol.More ? Symbol.Folder : result;
|
||||
}
|
||||
set { _pwGroup.IconId = PwIconToSegoeMapping.GetIconFromSymbol(value); }
|
||||
}
|
||||
|
||||
public bool IsEditMode
|
||||
@@ -58,32 +74,45 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetProperty(ref _isEditMode, value); }
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ParentGroup == null) return string.Empty;
|
||||
var path = new StringBuilder(ParentGroup.Path);
|
||||
path.Append($" > {ParentGroup.Name}");
|
||||
return path.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly PwGroup _pwGroup;
|
||||
private bool _isLeftPaneOpen;
|
||||
private readonly App _app = Application.Current as App;
|
||||
private bool _isEditMode;
|
||||
|
||||
public GroupVm() {}
|
||||
|
||||
public GroupVm(PwGroup pwGroup, GroupVm parent)
|
||||
public GroupVm(PwGroup pwGroup, GroupVm parent, PwUuid recycleBinId = null)
|
||||
{
|
||||
_pwGroup = pwGroup;
|
||||
ParentGroup = parent;
|
||||
|
||||
if (recycleBinId != null && _pwGroup.Uuid.Equals(recycleBinId)) _app.Database.RecycleBin = this;
|
||||
Entries = new ObservableCollection<EntryVm>(pwGroup.Entries.Select(e => new EntryVm(e, this)).OrderBy(e => e.Name));
|
||||
Entries.Insert(0, new EntryVm ());
|
||||
Groups = new ObservableCollection<GroupVm>(pwGroup.Groups.Select(g => new GroupVm(g, this)).OrderBy(g => g.Name));
|
||||
Groups = new ObservableCollection<GroupVm>(pwGroup.Groups.Select(g => new GroupVm(g, this, recycleBinId)).OrderBy(g => g.Name));
|
||||
Groups.Insert(0, new GroupVm ());
|
||||
}
|
||||
|
||||
public GroupVm CreateNewGroup()
|
||||
public GroupVm AddNewGroup(string name = "")
|
||||
{
|
||||
var pwGroup = new PwGroup(true, true, string.Empty, PwIcon.Folder);
|
||||
var pwGroup = new PwGroup(true, true, name, PwIcon.Folder);
|
||||
_pwGroup.AddGroup(pwGroup, true);
|
||||
var newGroup = new GroupVm(pwGroup, this) {IsEditMode = true};
|
||||
var newGroup = new GroupVm(pwGroup, this) {Name = name, IsEditMode = string.IsNullOrEmpty(name)};
|
||||
Groups.Add(newGroup);
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
public EntryVm CreateNewEntry()
|
||||
public EntryVm AddNewEntry()
|
||||
{
|
||||
var pwEntry = new PwEntry(true, true);
|
||||
_pwGroup.AddEntry(pwEntry, true);
|
||||
@@ -91,27 +120,60 @@ namespace ModernKeePass.ViewModels
|
||||
Entries.Add(newEntry);
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
|
||||
public void AddPwEntry(PwEntry entry)
|
||||
{
|
||||
_pwGroup.AddEntry(entry, true);
|
||||
}
|
||||
|
||||
public void RemovePwEntry(PwEntry entry)
|
||||
{
|
||||
_pwGroup.Entries.Remove(entry);
|
||||
}
|
||||
|
||||
public void MarkForDelete()
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.PendingDeleteEntities.Add(Id, this);
|
||||
ParentGroup.Groups.Remove(this);
|
||||
if (_app.Database.RecycleBinEnabled && _app.Database.RecycleBin?.IdUuid == null)
|
||||
_app.Database.CreateRecycleBin();
|
||||
Move(_app.Database.RecycleBinEnabled && !IsSelected ? _app.Database.RecycleBin : null);
|
||||
}
|
||||
|
||||
|
||||
public void UndoDelete()
|
||||
{
|
||||
Move(PreviousGroup);
|
||||
}
|
||||
|
||||
public void Move(GroupVm destination)
|
||||
{
|
||||
PreviousGroup = ParentGroup;
|
||||
PreviousGroup.Groups.Remove(this);
|
||||
PreviousGroup._pwGroup.Groups.Remove(_pwGroup);
|
||||
if (destination == null)
|
||||
{
|
||||
_app.Database.AddDeletedItem(IdUuid);
|
||||
return;
|
||||
}
|
||||
ParentGroup = destination;
|
||||
ParentGroup.Groups.Add(this);
|
||||
ParentGroup._pwGroup.AddGroup(_pwGroup, true);
|
||||
}
|
||||
|
||||
public void CommitDelete()
|
||||
{
|
||||
_pwGroup.ParentGroup.Groups.Remove(_pwGroup);
|
||||
}
|
||||
public void UndoDelete()
|
||||
{
|
||||
ParentGroup.Groups.Add(this);
|
||||
if (_app.Database.RecycleBinEnabled && !PreviousGroup.IsSelected) _app.Database.RecycleBin._pwGroup.AddGroup(_pwGroup, true);
|
||||
else _app.Database.AddDeletedItem(IdUuid);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.Database.Save();
|
||||
_app.Database.Save();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
ModernKeePass/ViewModels/Items/ListMenuItemVm.cs
Normal file
30
ModernKeePass/ViewModels/Items/ListMenuItemVm.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class ListMenuItemVm : NotifyPropertyChangedBase, IIsEnabled, ISelectableModel
|
||||
{
|
||||
private bool _isSelected;
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public int Group { get; set; } = 0;
|
||||
public Type PageType { get; set; }
|
||||
public Symbol SymbolIcon { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Title;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,32 +1,10 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class MainMenuItemVm: NotifyPropertyChangedBase, IIsEnabled, ISelectableModel
|
||||
public class MainMenuItemVm: ListMenuItemVm
|
||||
{
|
||||
private bool _isSelected;
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public Type PageType { get; set; }
|
||||
public object Parameter { get; set; }
|
||||
public Frame Destination { get; set; }
|
||||
public int Group { get; set; } = 0;
|
||||
public Symbol SymbolIcon { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,15 @@
|
||||
using System;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Common;
|
||||
using Windows.Storage.AccessCache;
|
||||
using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentItemVm: NotifyPropertyChangedBase
|
||||
public class RecentItemVm: NotifyPropertyChangedBase, ISelectableModel
|
||||
{
|
||||
private bool _isSelected;
|
||||
|
||||
|
||||
public RecentItemVm() {}
|
||||
public RecentItemVm(AccessListEntry entry, StorageFile file)
|
||||
{
|
||||
Token = entry.Token;
|
||||
@@ -16,15 +17,15 @@ namespace ModernKeePass.ViewModels
|
||||
DatabaseFile = file;
|
||||
}
|
||||
|
||||
public StorageFile DatabaseFile { get; private set; }
|
||||
public string Token { get; private set; }
|
||||
public string Name { get; private set; } = "Recent file";
|
||||
public string Path => DatabaseFile.Path;
|
||||
public StorageFile DatabaseFile { get; }
|
||||
public string Token { get; }
|
||||
public string Name { get; }
|
||||
public string Path => DatabaseFile?.Path;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
internal set { SetProperty(ref _isSelected, value); }
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
110
ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs
Normal file
110
ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePassLib;
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SettingsDatabaseVm: NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private readonly App _app = Application.Current as App;
|
||||
private readonly ApplicationDataContainer _localSettings = ApplicationData.Current.LocalSettings;
|
||||
private GroupVm _selectedItem;
|
||||
|
||||
public bool HasRecycleBin
|
||||
{
|
||||
get { return _app.Database.RecycleBinEnabled; }
|
||||
set
|
||||
{
|
||||
_app.Database.RecycleBinEnabled = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<GroupVm> Groups { get; set; }
|
||||
|
||||
public IEnumerable<string> Ciphers
|
||||
{
|
||||
get
|
||||
{
|
||||
for (var inx = 0; inx < CipherPool.GlobalPool.EngineCount; inx++)
|
||||
{
|
||||
yield return CipherPool.GlobalPool[inx].DisplayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CipherIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
for (var inx = 0; inx < CipherPool.GlobalPool.EngineCount; ++inx)
|
||||
{
|
||||
if (CipherPool.GlobalPool[inx].CipherUuid.Equals(_app.Database.DataCipher)) return inx;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
set { _app.Database.DataCipher = CipherPool.GlobalPool[value].CipherUuid; }
|
||||
}
|
||||
|
||||
public IEnumerable<string> Compressions => Enum.GetNames(typeof(PwCompressionAlgorithm)).Take((int)PwCompressionAlgorithm.Count);
|
||||
|
||||
public string CompressionName
|
||||
{
|
||||
get { return Enum.GetName(typeof(PwCompressionAlgorithm), _app.Database.CompressionAlgorithm); }
|
||||
set { _app.Database.CompressionAlgorithm = (PwCompressionAlgorithm)Enum.Parse(typeof(PwCompressionAlgorithm), value); }
|
||||
}
|
||||
public IEnumerable<string> KeyDerivations => KdfPool.Engines.Select(e => e.Name);
|
||||
|
||||
public string KeyDerivationName
|
||||
{
|
||||
get { return KdfPool.Get(_app.Database.KeyDerivation.KdfUuid).Name; }
|
||||
set { _app.Database.KeyDerivation = KdfPool.Engines.FirstOrDefault(e => e.Name == value)?.GetDefaultParameters(); }
|
||||
}
|
||||
|
||||
public ISelectableModel SelectedItem
|
||||
{
|
||||
get { return Groups.FirstOrDefault(g => g.IsSelected); }
|
||||
set
|
||||
{
|
||||
if (_selectedItem == value) return;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = false;
|
||||
}
|
||||
|
||||
SetProperty(ref _selectedItem, (GroupVm)value);
|
||||
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsDatabaseVm()
|
||||
{
|
||||
Groups = _app?.Database.RootGroup.Groups;
|
||||
}
|
||||
|
||||
// TODO: Move to another setting class (or a static class)
|
||||
private T GetSetting<T>(string property)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) Convert.ChangeType(_localSettings.Values[property], typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,7 +7,6 @@ using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Pages;
|
||||
using ModernKeePass.Pages.BasePages;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
|
@@ -1,21 +1,7 @@
|
||||
using ModernKeePassLib.Cryptography;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class NewVm : OpenVm
|
||||
{
|
||||
private string _password = string.Empty;
|
||||
|
||||
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
|
||||
public string Password
|
||||
{
|
||||
get { return _password; }
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
NotifyPropertyChanged("PasswordComplexityIndicator");
|
||||
}
|
||||
}
|
||||
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,9 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public OpenVm()
|
||||
{
|
||||
var database = ((App)Application.Current).Database;
|
||||
if (database == null || database.Status != DatabaseHelper.DatabaseStatus.Opening) return;
|
||||
OpenFile(database.DatabaseFile);
|
||||
var app = Application.Current as App;
|
||||
if (app?.Database == null || app.Database.Status != DatabaseHelper.DatabaseStatus.Opening) return;
|
||||
OpenFile(app.Database.DatabaseFile);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
@@ -2,12 +2,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Windows.Storage.AccessCache;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentVm : NotifyPropertyChangedBase
|
||||
public class RecentVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private RecentItemVm _selectedItem;
|
||||
private ISelectableModel _selectedItem;
|
||||
private ObservableCollection<RecentItemVm> _recentItems = new ObservableCollection<RecentItemVm>();
|
||||
|
||||
public ObservableCollection<RecentItemVm> RecentItems
|
||||
@@ -16,7 +17,7 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetProperty(ref _recentItems, value); }
|
||||
}
|
||||
|
||||
public RecentItemVm SelectedItem
|
||||
public ISelectableModel SelectedItem
|
||||
{
|
||||
get { return _selectedItem; }
|
||||
set
|
||||
|
@@ -8,9 +8,7 @@ namespace ModernKeePass.ViewModels
|
||||
public void Save(bool close = true)
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.Database.Save();
|
||||
if (!close) return;
|
||||
app.Database.Close();
|
||||
if (close && app.Database.Save()) app.Database.Close();
|
||||
}
|
||||
|
||||
internal void Save(StorageFile file)
|
||||
|
46
ModernKeePass/ViewModels/SettingsVm.cs
Normal file
46
ModernKeePass/ViewModels/SettingsVm.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Pages;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SettingsVM : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private ListMenuItemVm _selectedItem;
|
||||
|
||||
public ObservableCollection<ListMenuItemVm> MenuItems { get; set; }
|
||||
public ISelectableModel SelectedItem
|
||||
{
|
||||
get { return _selectedItem; }
|
||||
set
|
||||
{
|
||||
if (_selectedItem == value) return;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = false;
|
||||
}
|
||||
|
||||
SetProperty(ref _selectedItem, (ListMenuItemVm)value);
|
||||
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsVM()
|
||||
{
|
||||
MenuItems = new ObservableCollection<ListMenuItemVm>
|
||||
{
|
||||
new ListMenuItemVm { Title = "Database", SymbolIcon = Symbol.Setting, PageType = typeof(SettingsDatabasePage), IsSelected = true },
|
||||
new ListMenuItemVm { Title = "Security", SymbolIcon = Symbol.Permissions, PageType = typeof(SettingsSecurityPage) },
|
||||
//new ListMenuItemVm { Title = "General", SymbolIcon = Symbol.Edit, PageType = typeof(SettingsGeneralPage) }
|
||||
};
|
||||
SelectedItem = MenuItems.FirstOrDefault(m => m.IsSelected);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="win81" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="win81" />
|
||||
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
|
||||
<package id="Microsoft.Toolkit.Uwp.Notifications" version="2.0.0" targetFramework="win81" />
|
||||
<package id="ModernKeePassLib" version="2.37.4000" targetFramework="win81" />
|
||||
<package id="ModernKeePassLib" version="2.37.6000" targetFramework="win81" />
|
||||
<package id="NETStandard.Library" version="2.0.1" targetFramework="win81" />
|
||||
<package id="Portable.BouncyCastle" version="1.8.1.3" targetFramework="win81" />
|
||||
<package id="Splat" version="2.0.0" targetFramework="win81" />
|
||||
@@ -24,5 +25,5 @@
|
||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Xml.XmlSerializer" version="4.3.0" targetFramework="win81" />
|
||||
<package id="Validation" version="2.4.15" targetFramework="win81" />
|
||||
<package id="Validation" version="2.4.18" targetFramework="win81" />
|
||||
</packages>
|
204
ModernKeePassLib.Test/Cryptography/Cipher/Chacha20Tests.cs
Normal file
204
ModernKeePassLib.Test/Cryptography/Cipher/Chacha20Tests.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.Cipher
|
||||
{
|
||||
[TestClass]
|
||||
public class Chacha20Tests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestChacha20()
|
||||
{
|
||||
// ======================================================
|
||||
// Test vector from RFC 7539, section 2.3.2
|
||||
|
||||
byte[] pbKey = new byte[32];
|
||||
for (int i = 0; i < 32; ++i) pbKey[i] = (byte)i;
|
||||
|
||||
byte[] pbIV = new byte[12];
|
||||
pbIV[3] = 0x09;
|
||||
pbIV[7] = 0x4A;
|
||||
|
||||
byte[] pbExpc = new byte[64] {
|
||||
0x10, 0xF1, 0xE7, 0xE4, 0xD1, 0x3B, 0x59, 0x15,
|
||||
0x50, 0x0F, 0xDD, 0x1F, 0xA3, 0x20, 0x71, 0xC4,
|
||||
0xC7, 0xD1, 0xF4, 0xC7, 0x33, 0xC0, 0x68, 0x03,
|
||||
0x04, 0x22, 0xAA, 0x9A, 0xC3, 0xD4, 0x6C, 0x4E,
|
||||
0xD2, 0x82, 0x64, 0x46, 0x07, 0x9F, 0xAA, 0x09,
|
||||
0x14, 0xC2, 0xD7, 0x05, 0xD9, 0x8B, 0x02, 0xA2,
|
||||
0xB5, 0x12, 0x9C, 0xD1, 0xDE, 0x16, 0x4E, 0xB9,
|
||||
0xCB, 0xD0, 0x83, 0xE8, 0xA2, 0x50, 0x3C, 0x4E
|
||||
};
|
||||
|
||||
byte[] pb = new byte[64];
|
||||
|
||||
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV))
|
||||
{
|
||||
c.Seek(64, SeekOrigin.Begin); // Skip first block
|
||||
c.Encrypt(pb, 0, pb.Length);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
// ======================================================
|
||||
// Test vector from RFC 7539, section 2.4.2
|
||||
|
||||
pbIV[3] = 0;
|
||||
|
||||
pb = StrUtil.Utf8.GetBytes("Ladies and Gentlemen of the clas" +
|
||||
@"s of '99: If I could offer you only one tip for " +
|
||||
@"the future, sunscreen would be it.");
|
||||
|
||||
pbExpc = new byte[] {
|
||||
0x6E, 0x2E, 0x35, 0x9A, 0x25, 0x68, 0xF9, 0x80,
|
||||
0x41, 0xBA, 0x07, 0x28, 0xDD, 0x0D, 0x69, 0x81,
|
||||
0xE9, 0x7E, 0x7A, 0xEC, 0x1D, 0x43, 0x60, 0xC2,
|
||||
0x0A, 0x27, 0xAF, 0xCC, 0xFD, 0x9F, 0xAE, 0x0B,
|
||||
0xF9, 0x1B, 0x65, 0xC5, 0x52, 0x47, 0x33, 0xAB,
|
||||
0x8F, 0x59, 0x3D, 0xAB, 0xCD, 0x62, 0xB3, 0x57,
|
||||
0x16, 0x39, 0xD6, 0x24, 0xE6, 0x51, 0x52, 0xAB,
|
||||
0x8F, 0x53, 0x0C, 0x35, 0x9F, 0x08, 0x61, 0xD8,
|
||||
0x07, 0xCA, 0x0D, 0xBF, 0x50, 0x0D, 0x6A, 0x61,
|
||||
0x56, 0xA3, 0x8E, 0x08, 0x8A, 0x22, 0xB6, 0x5E,
|
||||
0x52, 0xBC, 0x51, 0x4D, 0x16, 0xCC, 0xF8, 0x06,
|
||||
0x81, 0x8C, 0xE9, 0x1A, 0xB7, 0x79, 0x37, 0x36,
|
||||
0x5A, 0xF9, 0x0B, 0xBF, 0x74, 0xA3, 0x5B, 0xE6,
|
||||
0xB4, 0x0B, 0x8E, 0xED, 0xF2, 0x78, 0x5E, 0x42,
|
||||
0x87, 0x4D
|
||||
};
|
||||
|
||||
byte[] pb64 = new byte[64];
|
||||
|
||||
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV))
|
||||
{
|
||||
c.Encrypt(pb64, 0, pb64.Length); // Skip first block
|
||||
c.Encrypt(pb, 0, pb.Length);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// Test vector from RFC 7539, appendix A.2 #2
|
||||
|
||||
Array.Clear(pbKey, 0, pbKey.Length);
|
||||
pbKey[31] = 1;
|
||||
|
||||
Array.Clear(pbIV, 0, pbIV.Length);
|
||||
pbIV[11] = 2;
|
||||
|
||||
pb = StrUtil.Utf8.GetBytes("Any submission to the IETF inten" +
|
||||
"ded by the Contributor for publication as all or" +
|
||||
" part of an IETF Internet-Draft or RFC and any s" +
|
||||
"tatement made within the context of an IETF acti" +
|
||||
"vity is considered an \"IETF Contribution\". Such " +
|
||||
"statements include oral statements in IETF sessi" +
|
||||
"ons, as well as written and electronic communica" +
|
||||
"tions made at any time or place, which are addressed to");
|
||||
|
||||
pbExpc = MemUtil.HexStringToByteArray(
|
||||
"A3FBF07DF3FA2FDE4F376CA23E82737041605D9F4F4F57BD8CFF2C1D4B7955EC" +
|
||||
"2A97948BD3722915C8F3D337F7D370050E9E96D647B7C39F56E031CA5EB6250D" +
|
||||
"4042E02785ECECFA4B4BB5E8EAD0440E20B6E8DB09D881A7C6132F420E527950" +
|
||||
"42BDFA7773D8A9051447B3291CE1411C680465552AA6C405B7764D5E87BEA85A" +
|
||||
"D00F8449ED8F72D0D662AB052691CA66424BC86D2DF80EA41F43ABF937D3259D" +
|
||||
"C4B2D0DFB48A6C9139DDD7F76966E928E635553BA76C5C879D7B35D49EB2E62B" +
|
||||
"0871CDAC638939E25E8A1E0EF9D5280FA8CA328B351C3C765989CBCF3DAA8B6C" +
|
||||
"CC3AAF9F3979C92B3720FC88DC95ED84A1BE059C6499B9FDA236E7E818B04B0B" +
|
||||
"C39C1E876B193BFE5569753F88128CC08AAA9B63D1A16F80EF2554D7189C411F" +
|
||||
"5869CA52C5B83FA36FF216B9C1D30062BEBCFD2DC5BCE0911934FDA79A86F6E6" +
|
||||
"98CED759C3FF9B6477338F3DA4F9CD8514EA9982CCAFB341B2384DD902F3D1AB" +
|
||||
"7AC61DD29C6F21BA5B862F3730E37CFDC4FD806C22F221");
|
||||
|
||||
using (MemoryStream msEnc = new MemoryStream())
|
||||
{
|
||||
using (ChaCha20Stream c = new ChaCha20Stream(msEnc, true, pbKey, pbIV))
|
||||
{
|
||||
Random r = CryptoRandom.NewWeakRandom();
|
||||
r.NextBytes(pb64);
|
||||
c.Write(pb64, 0, pb64.Length); // Skip first block
|
||||
|
||||
int p = 0;
|
||||
while (p < pb.Length)
|
||||
{
|
||||
int cb = r.Next(1, pb.Length - p + 1);
|
||||
c.Write(pb, p, cb);
|
||||
p += cb;
|
||||
}
|
||||
Debug.Assert(p == pb.Length);
|
||||
}
|
||||
|
||||
byte[] pbEnc0 = msEnc.ToArray();
|
||||
byte[] pbEnc = MemUtil.Mid(pbEnc0, 64, pbEnc0.Length - 64);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbEnc, pbExpc));
|
||||
|
||||
using (MemoryStream msCT = new MemoryStream(pbEnc0, false))
|
||||
{
|
||||
using (ChaCha20Stream cDec = new ChaCha20Stream(msCT, false,
|
||||
pbKey, pbIV))
|
||||
{
|
||||
byte[] pbPT = MemUtil.Read(cDec, pbEnc0.Length);
|
||||
|
||||
Assert.IsTrue(cDec.ReadByte() < 0);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 0, 64), pb64));
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 64, pbEnc.Length), pb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// Test vector TC8 from RFC draft by J. Strombergson:
|
||||
// https://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-01
|
||||
|
||||
pbKey = new byte[32] {
|
||||
0xC4, 0x6E, 0xC1, 0xB1, 0x8C, 0xE8, 0xA8, 0x78,
|
||||
0x72, 0x5A, 0x37, 0xE7, 0x80, 0xDF, 0xB7, 0x35,
|
||||
0x1F, 0x68, 0xED, 0x2E, 0x19, 0x4C, 0x79, 0xFB,
|
||||
0xC6, 0xAE, 0xBE, 0xE1, 0xA6, 0x67, 0x97, 0x5D
|
||||
};
|
||||
|
||||
// The first 4 bytes are set to zero and a large counter
|
||||
// is used; this makes the RFC 7539 version of ChaCha20
|
||||
// compatible with the original specification by
|
||||
// D. J. Bernstein.
|
||||
pbIV = new byte[12] { 0x00, 0x00, 0x00, 0x00,
|
||||
0x1A, 0xDA, 0x31, 0xD5, 0xCF, 0x68, 0x82, 0x21
|
||||
};
|
||||
|
||||
pb = new byte[128];
|
||||
|
||||
pbExpc = new byte[128] {
|
||||
0xF6, 0x3A, 0x89, 0xB7, 0x5C, 0x22, 0x71, 0xF9,
|
||||
0x36, 0x88, 0x16, 0x54, 0x2B, 0xA5, 0x2F, 0x06,
|
||||
0xED, 0x49, 0x24, 0x17, 0x92, 0x30, 0x2B, 0x00,
|
||||
0xB5, 0xE8, 0xF8, 0x0A, 0xE9, 0xA4, 0x73, 0xAF,
|
||||
0xC2, 0x5B, 0x21, 0x8F, 0x51, 0x9A, 0xF0, 0xFD,
|
||||
0xD4, 0x06, 0x36, 0x2E, 0x8D, 0x69, 0xDE, 0x7F,
|
||||
0x54, 0xC6, 0x04, 0xA6, 0xE0, 0x0F, 0x35, 0x3F,
|
||||
0x11, 0x0F, 0x77, 0x1B, 0xDC, 0xA8, 0xAB, 0x92,
|
||||
|
||||
0xE5, 0xFB, 0xC3, 0x4E, 0x60, 0xA1, 0xD9, 0xA9,
|
||||
0xDB, 0x17, 0x34, 0x5B, 0x0A, 0x40, 0x27, 0x36,
|
||||
0x85, 0x3B, 0xF9, 0x10, 0xB0, 0x60, 0xBD, 0xF1,
|
||||
0xF8, 0x97, 0xB6, 0x29, 0x0F, 0x01, 0xD1, 0x38,
|
||||
0xAE, 0x2C, 0x4C, 0x90, 0x22, 0x5B, 0xA9, 0xEA,
|
||||
0x14, 0xD5, 0x18, 0xF5, 0x59, 0x29, 0xDE, 0xA0,
|
||||
0x98, 0xCA, 0x7A, 0x6C, 0xCF, 0xE6, 0x12, 0x27,
|
||||
0x05, 0x3C, 0x84, 0xE4, 0x9A, 0x4A, 0x33, 0x32
|
||||
};
|
||||
|
||||
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV, true))
|
||||
{
|
||||
c.Decrypt(pb, 0, pb.Length);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,22 +1,15 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Serialization;
|
||||
using ModernKeePassLib.Utility;
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography.Cipher;
|
||||
#else
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
#endif
|
||||
|
||||
using NUnit.Framework;
|
||||
using ModernKeePassLib.Utility;
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Cryptography.Cipher
|
||||
namespace ModernKeePassLib.Test.Cryptography.Cipher
|
||||
{
|
||||
[TestFixture()]
|
||||
[TestClass()]
|
||||
public class StandardAesEngineTests
|
||||
{
|
||||
// Test vector (official ECB test vector #356)
|
||||
@@ -24,7 +17,7 @@ namespace ModernKeePassLib.Test.Shared.Cryptography.Cipher
|
||||
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
|
||||
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
|
||||
};
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestEncryptStream()
|
||||
{
|
||||
byte[] pbIV = new byte[16];
|
||||
@@ -36,13 +29,13 @@ namespace ModernKeePassLib.Test.Shared.Cryptography.Cipher
|
||||
var aes = new StandardAesEngine();
|
||||
var inStream = aes.EncryptStream(outStream, pbTestKey, pbIV);
|
||||
new BinaryWriter(inStream).Write(pbTestData);
|
||||
//Assert.That(outStream.Position, Is.EqualTo(16));
|
||||
Assert.AreEqual(outStream.Position, 16);
|
||||
outStream.Position = 0;
|
||||
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
|
||||
Assert.That(outBytes, Is.EqualTo(pbReferenceCT));
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbReferenceCT));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestDecryptStream()
|
||||
{
|
||||
byte[] pbIV = new byte[16];
|
||||
@@ -57,10 +50,10 @@ namespace ModernKeePassLib.Test.Shared.Cryptography.Cipher
|
||||
var aes = new StandardAesEngine();
|
||||
var outStream = aes.DecryptStream(inStream, pbTestKey, pbIV);
|
||||
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
|
||||
Assert.That(outBytes, Is.EqualTo(pbTestData));
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbTestData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestBouncyCastleAes()
|
||||
{
|
||||
byte[] pbIV = new byte[16];
|
||||
@@ -75,10 +68,9 @@ namespace ModernKeePassLib.Test.Shared.Cryptography.Cipher
|
||||
var aesEngine = new AesEngine();
|
||||
//var parametersWithIv = new ParametersWithIV(new KeyParameter(pbTestKey), pbIV);
|
||||
aesEngine.Init(true, new KeyParameter(pbTestKey));
|
||||
Assert.That(aesEngine.GetBlockSize(), Is.EqualTo(pbTestData.Length));
|
||||
Assert.AreEqual(aesEngine.GetBlockSize(), pbTestData.Length);
|
||||
aesEngine.ProcessBlock(pbTestData, 0, pbTestData, 0);
|
||||
//Assert.That(MemUtil.ArraysEqual(pbTestData, pbReferenceCT), Is.False);
|
||||
Assert.That(pbTestData, Is.EqualTo(pbReferenceCT));
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbTestData, pbReferenceCT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +1,56 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography;
|
||||
#else
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Cryptography
|
||||
namespace ModernKeePassLib.Test.Cryptography
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class CryptoRandomStreamTests
|
||||
{
|
||||
void TestGetRandomBytes(CryptoRandomStream stream)
|
||||
[TestClass]
|
||||
public class CryptoRandomStreamTests
|
||||
{
|
||||
const uint length = 16;
|
||||
var bytes1 = stream.GetRandomBytes (length);
|
||||
Assert.That (bytes1.Length, Is.EqualTo (length));
|
||||
var bytes2 = stream.GetRandomBytes (length);
|
||||
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
|
||||
}
|
||||
private void TestGetRandomBytes(CryptoRandomStream stream)
|
||||
{
|
||||
const uint length = 16;
|
||||
var bytes1 = stream.GetRandomBytes(length);
|
||||
Assert.AreEqual(bytes1.Length, (int)length);
|
||||
var bytes2 = stream.GetRandomBytes(length);
|
||||
Assert.IsFalse(MemUtil.ArraysEqual(bytes2, bytes1));
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetRandomBytesCrsAlgorithmSalsa20 ()
|
||||
{
|
||||
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
|
||||
TestGetRandomBytes (stream);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestGetRandomBytesCrsAlgorithmSalsa20()
|
||||
{
|
||||
var stream = new CryptoRandomStream(CrsAlgorithm.Salsa20, new byte[16]);
|
||||
TestGetRandomBytes(stream);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetRandomBytesCrsAlgorithmArcFourVariant ()
|
||||
{
|
||||
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
|
||||
TestGetRandomBytes (stream);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestGetRandomBytesCrsAlgorithmArcFourVariant()
|
||||
{
|
||||
var stream = new CryptoRandomStream(CrsAlgorithm.ArcFourVariant, new byte[16]);
|
||||
TestGetRandomBytes(stream);
|
||||
}
|
||||
|
||||
void TestGetRandomInt64 (CryptoRandomStream stream)
|
||||
{
|
||||
var value1 = stream.GetRandomUInt64 ();
|
||||
var value2 = stream.GetRandomUInt64 ();
|
||||
Assert.That (value2, Is.Not.EqualTo (value1));
|
||||
}
|
||||
private void TestGetRandomInt64(CryptoRandomStream stream)
|
||||
{
|
||||
var value1 = stream.GetRandomUInt64();
|
||||
var value2 = stream.GetRandomUInt64();
|
||||
Assert.AreNotEqual(value2, value1);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetRandomInt64AlgorithmSalsa20 ()
|
||||
{
|
||||
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
|
||||
TestGetRandomInt64 (stream);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestGetRandomInt64AlgorithmSalsa20()
|
||||
{
|
||||
var stream = new CryptoRandomStream(CrsAlgorithm.Salsa20, new byte[16]);
|
||||
TestGetRandomInt64(stream);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetRandomInt64AlgorithmArcFourVariant ()
|
||||
{
|
||||
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
|
||||
TestGetRandomInt64 (stream);
|
||||
[TestMethod]
|
||||
public void TestGetRandomInt64AlgorithmArcFourVariant()
|
||||
{
|
||||
var stream = new CryptoRandomStream(CrsAlgorithm.ArcFourVariant, new byte[16]);
|
||||
TestGetRandomInt64(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,44 +1,38 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography;
|
||||
#else
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Cryptography
|
||||
namespace ModernKeePassLib.Test.Cryptography
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class CryptoRandomTests
|
||||
{
|
||||
[Test ()]
|
||||
public void TestAddEntropy ()
|
||||
[TestClass()]
|
||||
public class CryptoRandomTests
|
||||
{
|
||||
// just making sure it does not throw an exception
|
||||
CryptoRandom.Instance.AddEntropy (new byte[1]);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestAddEntropy()
|
||||
{
|
||||
// just making sure it does not throw an exception
|
||||
CryptoRandom.Instance.AddEntropy(new byte[1]);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetRandomBytes ()
|
||||
{
|
||||
const int length = 32;
|
||||
var bytes1 = CryptoRandom.Instance.GetRandomBytes (length);
|
||||
Assert.That (bytes1.Length, Is.EqualTo (length));
|
||||
var bytes2 = CryptoRandom.Instance.GetRandomBytes (length);
|
||||
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestGetRandomBytes()
|
||||
{
|
||||
const int length = 32;
|
||||
var bytes1 = CryptoRandom.Instance.GetRandomBytes(length);
|
||||
Assert.AreEqual(bytes1.Length, length);
|
||||
var bytes2 = CryptoRandom.Instance.GetRandomBytes(length);
|
||||
Assert.AreNotEqual(bytes2, bytes1);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGeneratedBytesCount ()
|
||||
{
|
||||
const int length = 1;
|
||||
CryptoRandom.Instance.GetRandomBytes (length);
|
||||
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
|
||||
CryptoRandom.Instance.GetRandomBytes (length);
|
||||
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
|
||||
Assert.That (count2, Is.GreaterThan (count1));
|
||||
[TestMethod]
|
||||
public void TestGeneratedBytesCount()
|
||||
{
|
||||
const int length = 1;
|
||||
CryptoRandom.Instance.GetRandomBytes(length);
|
||||
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
|
||||
CryptoRandom.Instance.GetRandomBytes(length);
|
||||
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
|
||||
Assert.IsTrue(count2 > count1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
101
ModernKeePassLib.Test/Cryptography/Hash/Blake2bTests.cs
Normal file
101
ModernKeePassLib.Test/Cryptography/Hash/Blake2bTests.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.Hash
|
||||
{
|
||||
[TestClass]
|
||||
public class Blake2bTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestBlake2bUtf8()
|
||||
{
|
||||
Blake2b h = new Blake2b();
|
||||
|
||||
// ======================================================
|
||||
// From https://tools.ietf.org/html/rfc7693
|
||||
|
||||
byte[] pbData = StrUtil.Utf8.GetBytes("abc");
|
||||
byte[] pbExpc = new byte[64]
|
||||
{
|
||||
0xBA, 0x80, 0xA5, 0x3F, 0x98, 0x1C, 0x4D, 0x0D,
|
||||
0x6A, 0x27, 0x97, 0xB6, 0x9F, 0x12, 0xF6, 0xE9,
|
||||
0x4C, 0x21, 0x2F, 0x14, 0x68, 0x5A, 0xC4, 0xB7,
|
||||
0x4B, 0x12, 0xBB, 0x6F, 0xDB, 0xFF, 0xA2, 0xD1,
|
||||
0x7D, 0x87, 0xC5, 0x39, 0x2A, 0xAB, 0x79, 0x2D,
|
||||
0xC2, 0x52, 0xD5, 0xDE, 0x45, 0x33, 0xCC, 0x95,
|
||||
0x18, 0xD3, 0x8A, 0xA8, 0xDB, 0xF1, 0x92, 0x5A,
|
||||
0xB9, 0x23, 0x86, 0xED, 0xD4, 0x00, 0x99, 0x23
|
||||
};
|
||||
|
||||
byte[] pbC = h.ComputeHash(pbData);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbC, pbExpc));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBlake2bEmpty()
|
||||
{
|
||||
// ======================================================
|
||||
// Computed using the official b2sum tool
|
||||
Blake2b h = new Blake2b();
|
||||
|
||||
var pbExpc = new byte[64]
|
||||
{
|
||||
0x78, 0x6A, 0x02, 0xF7, 0x42, 0x01, 0x59, 0x03,
|
||||
0xC6, 0xC6, 0xFD, 0x85, 0x25, 0x52, 0xD2, 0x72,
|
||||
0x91, 0x2F, 0x47, 0x40, 0xE1, 0x58, 0x47, 0x61,
|
||||
0x8A, 0x86, 0xE2, 0x17, 0xF7, 0x1F, 0x54, 0x19,
|
||||
0xD2, 0x5E, 0x10, 0x31, 0xAF, 0xEE, 0x58, 0x53,
|
||||
0x13, 0x89, 0x64, 0x44, 0x93, 0x4E, 0xB0, 0x4B,
|
||||
0x90, 0x3A, 0x68, 0x5B, 0x14, 0x48, 0xB7, 0x55,
|
||||
0xD5, 0x6F, 0x70, 0x1A, 0xFE, 0x9B, 0xE2, 0xCE
|
||||
};
|
||||
|
||||
var pbC = h.ComputeHash(MemUtil.EmptyByteArray);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbC, pbExpc));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBlake2bString()
|
||||
{
|
||||
// ======================================================
|
||||
// Computed using the official b2sum tool
|
||||
Blake2b h = new Blake2b();
|
||||
|
||||
string strS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:,;_-\r\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 1000; ++i) sb.Append(strS);
|
||||
var pbData = StrUtil.Utf8.GetBytes(sb.ToString());
|
||||
|
||||
var pbExpc = new byte[64] {
|
||||
0x59, 0x69, 0x8D, 0x3B, 0x83, 0xF4, 0x02, 0x4E,
|
||||
0xD8, 0x99, 0x26, 0x0E, 0xF4, 0xE5, 0x9F, 0x20,
|
||||
0xDC, 0x31, 0xEE, 0x5B, 0x45, 0xEA, 0xBB, 0xFC,
|
||||
0x1C, 0x0A, 0x8E, 0xED, 0xAA, 0x7A, 0xFF, 0x50,
|
||||
0x82, 0xA5, 0x8F, 0xBC, 0x4A, 0x46, 0xFC, 0xC5,
|
||||
0xEF, 0x44, 0x4E, 0x89, 0x80, 0x7D, 0x3F, 0x1C,
|
||||
0xC1, 0x94, 0x45, 0xBB, 0xC0, 0x2C, 0x95, 0xAA,
|
||||
0x3F, 0x08, 0x8A, 0x93, 0xF8, 0x75, 0x91, 0xB0
|
||||
};
|
||||
|
||||
Random r = CryptoRandom.NewWeakRandom();
|
||||
int p = 0;
|
||||
while (p < pbData.Length)
|
||||
{
|
||||
int cb = r.Next(1, pbData.Length - p + 1);
|
||||
h.TransformBlock(pbData, p, cb, pbData, p);
|
||||
p += cb;
|
||||
}
|
||||
Assert.AreEqual(p, pbData.Length);
|
||||
|
||||
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(h.Hash, pbExpc));
|
||||
|
||||
h.Clear();
|
||||
}
|
||||
}
|
||||
}
|
117
ModernKeePassLib.Test/Cryptography/Hash/HmacTests.cs
Normal file
117
ModernKeePassLib.Test/Cryptography/Hash/HmacTests.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.Hash
|
||||
{
|
||||
[TestClass]
|
||||
public class HmacTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestHmac1()
|
||||
{
|
||||
// Test vectors from RFC 4231
|
||||
|
||||
var pbKey = new byte[20];
|
||||
for (var i = 0; i < pbKey.Length; ++i) pbKey[i] = 0x0B;
|
||||
var pbMsg = StrUtil.Utf8.GetBytes("Hi There");
|
||||
var pbExpc = new byte[]
|
||||
{
|
||||
0xB0, 0x34, 0x4C, 0x61, 0xD8, 0xDB, 0x38, 0x53,
|
||||
0x5C, 0xA8, 0xAF, 0xCE, 0xAF, 0x0B, 0xF1, 0x2B,
|
||||
0x88, 0x1D, 0xC2, 0x00, 0xC9, 0x83, 0x3D, 0xA7,
|
||||
0x26, 0xE9, 0x37, 0x6C, 0x2E, 0x32, 0xCF, 0xF7
|
||||
};
|
||||
HmacEval(pbKey, pbMsg, pbExpc);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestHmac2()
|
||||
{
|
||||
var pbKey = new byte[131];
|
||||
for (var i = 0; i < pbKey.Length; ++i) pbKey[i] = 0xAA;
|
||||
var pbMsg = StrUtil.Utf8.GetBytes(
|
||||
"This is a test using a larger than block-size key and " +
|
||||
"a larger than block-size data. The key needs to be " +
|
||||
"hashed before being used by the HMAC algorithm.");
|
||||
var pbExpc = new byte[] {
|
||||
0x9B, 0x09, 0xFF, 0xA7, 0x1B, 0x94, 0x2F, 0xCB,
|
||||
0x27, 0x63, 0x5F, 0xBC, 0xD5, 0xB0, 0xE9, 0x44,
|
||||
0xBF, 0xDC, 0x63, 0x64, 0x4F, 0x07, 0x13, 0x93,
|
||||
0x8A, 0x7F, 0x51, 0x53, 0x5C, 0x3A, 0x35, 0xE2
|
||||
};
|
||||
HmacEval(pbKey, pbMsg, pbExpc);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestHmacSha1ComputeHash()
|
||||
{
|
||||
var expectedHash = "AC2C2E614882CE7158F69B7E3B12114465945D01";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
var key = StrUtil.Utf8.GetBytes("hello");
|
||||
using (var result = new HMACSHA1(key))
|
||||
{
|
||||
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestHmacSha256ComputeHash()
|
||||
{
|
||||
var expectedHash = "09C1BD2DE4E5659C0EFAF9E6AE4723E9CF96B69609B4E562F6AFF1745D7BF4E0";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
var key = StrUtil.Utf8.GetBytes("hello");
|
||||
using (var result = new HMACSHA256(key))
|
||||
{
|
||||
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
|
||||
}
|
||||
}
|
||||
|
||||
private static string ByteToString(byte[] buff)
|
||||
{
|
||||
string sbinary = "";
|
||||
|
||||
for (int i = 0; i < buff.Length; i++)
|
||||
{
|
||||
sbinary += buff[i].ToString("X2"); // hex format
|
||||
}
|
||||
return (sbinary);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestHmacOtp()
|
||||
{
|
||||
var pbSecret = StrUtil.Utf8.GetBytes("12345678901234567890");
|
||||
var vExp = new []{ "755224", "287082", "359152",
|
||||
"969429", "338314", "254676", "287922", "162583", "399871",
|
||||
"520489" };
|
||||
|
||||
for (var i = 0; i < vExp.Length; ++i)
|
||||
{
|
||||
Assert.AreEqual(HmacOtp.Generate(pbSecret, (ulong)i, 6, false, -1), vExp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HmacEval(byte[] pbKey, byte[] pbMsg,
|
||||
byte[] pbExpc)
|
||||
{
|
||||
using (var h = new HMACSHA256(pbKey))
|
||||
{
|
||||
h.TransformBlock(pbMsg, 0, pbMsg.Length, pbMsg, 0);
|
||||
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
|
||||
|
||||
byte[] pbHash = h.Hash;
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbHash, pbExpc));
|
||||
|
||||
// Reuse the object
|
||||
h.Initialize();
|
||||
h.TransformBlock(pbMsg, 0, pbMsg.Length, pbMsg, 0);
|
||||
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
|
||||
|
||||
pbHash = h.Hash;
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbHash, pbExpc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
ModernKeePassLib.Test/Cryptography/Hash/SHAManagedTests.cs
Normal file
42
ModernKeePassLib.Test/Cryptography/Hash/SHAManagedTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.Hash
|
||||
{
|
||||
[TestClass]
|
||||
public class SHAManagedTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestSha256ComputeHash()
|
||||
{
|
||||
var expectedHash = "B822F1CD2DCFC685B47E83E3980289FD5D8E3FF3A82DEF24D7D1D68BB272EB32";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
using (var result = new SHA256Managed())
|
||||
{
|
||||
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSha512ComputeHash()
|
||||
{
|
||||
var expectedHash = "4120117B3190BA5E24044732B0B09AA9ED50EB1567705ABCBFA78431A4E0A96B1152ED7F4925966B1C82325E186A8100E692E6D2FCB6702572765820D25C7E9E";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
using (var result = new SHA512Managed())
|
||||
{
|
||||
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
|
||||
}
|
||||
}
|
||||
private static string ByteToString(byte[] buff)
|
||||
{
|
||||
string sbinary = "";
|
||||
|
||||
for (int i = 0; i < buff.Length; i++)
|
||||
{
|
||||
sbinary += buff[i].ToString("X2"); // hex format
|
||||
}
|
||||
return (sbinary);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,77 +1,83 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography;
|
||||
#else
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Cryptography
|
||||
namespace ModernKeePassLib.Test.Cryptography
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class HashingStreamExTests
|
||||
{
|
||||
const string data = "test";
|
||||
|
||||
// The expected hash includes the \n added by WriteLine
|
||||
static readonly byte[] sha256HashOfData = {
|
||||
0xf2, 0xca, 0x1b, 0xb6, 0xc7, 0xe9, 0x07, 0xd0,
|
||||
0x6d, 0xaf, 0xe4, 0x68, 0x7e, 0x57, 0x9f, 0xce,
|
||||
0x76, 0xb3, 0x7e, 0x4e, 0x93, 0xb7, 0x60, 0x50,
|
||||
0x22, 0xda, 0x52, 0xe6, 0xcc, 0xc2, 0x6f, 0xd2
|
||||
};
|
||||
|
||||
[Test ()]
|
||||
public void TestRead ()
|
||||
[TestClass()]
|
||||
public class HashingStreamExTests
|
||||
{
|
||||
// if we use larger size, StreamReader will read past newline and cause bad hash
|
||||
var bytes = new byte[data.Length + 1];
|
||||
using (var ms = new MemoryStream (bytes)) {
|
||||
using (var sw = new StreamWriter (ms)) {
|
||||
// set NewLine to ensure we don't run into cross-platform issues on Windows
|
||||
sw.NewLine = "\n";
|
||||
sw.WriteLine (data);
|
||||
}
|
||||
}
|
||||
using (var ms = new MemoryStream (bytes)) {
|
||||
using (var hs = new HashingStreamEx (ms, false, null)) {
|
||||
using (var sr = new StreamReader (hs)) {
|
||||
var read = sr.ReadLine ();
|
||||
Assert.That (read, Is.EqualTo (data));
|
||||
}
|
||||
// When the StreamReader is disposed, it calls Dispose on the
|
||||
//HasingStreamEx, which computes the hash.
|
||||
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
|
||||
}
|
||||
}
|
||||
}
|
||||
const string data = "test";
|
||||
|
||||
[Test ()]
|
||||
public void TestWrite ()
|
||||
{
|
||||
var bytes = new byte[16];
|
||||
using (var ms = new MemoryStream (bytes)) {
|
||||
using (var hs = new HashingStreamEx (ms, true, null)) {
|
||||
using (var sw = new StreamWriter (hs)) {
|
||||
// set NewLine to ensure we don't run into cross-platform issues on Windows
|
||||
sw.NewLine = "\n";
|
||||
sw.WriteLine (data);
|
||||
}
|
||||
// When the StreamWriter is disposed, it calls Dispose on the
|
||||
//HasingStreamEx, which computes the hash.
|
||||
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
|
||||
// The expected hash includes the \n added by WriteLine
|
||||
static readonly byte[] sha256HashOfData =
|
||||
{
|
||||
0xf2, 0xca, 0x1b, 0xb6, 0xc7, 0xe9, 0x07, 0xd0,
|
||||
0x6d, 0xaf, 0xe4, 0x68, 0x7e, 0x57, 0x9f, 0xce,
|
||||
0x76, 0xb3, 0x7e, 0x4e, 0x93, 0xb7, 0x60, 0x50,
|
||||
0x22, 0xda, 0x52, 0xe6, 0xcc, 0xc2, 0x6f, 0xd2
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
public void TestRead()
|
||||
{
|
||||
// if we use larger size, StreamReader will read past newline and cause bad hash
|
||||
var bytes = new byte[data.Length + 1];
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
{
|
||||
using (var sw = new StreamWriter(ms))
|
||||
{
|
||||
// set NewLine to ensure we don't run into cross-platform issues on Windows
|
||||
sw.NewLine = "\n";
|
||||
sw.WriteLine(data);
|
||||
}
|
||||
}
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
{
|
||||
using (var hs = new HashingStreamEx(ms, false, null))
|
||||
{
|
||||
using (var sr = new StreamReader(hs))
|
||||
{
|
||||
var read = sr.ReadLine();
|
||||
Assert.AreEqual(read, data);
|
||||
}
|
||||
// When the StreamReader is disposed, it calls Dispose on the
|
||||
//HasingStreamEx, which computes the hash.
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(hs.Hash, sha256HashOfData));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using (var ms = new MemoryStream (bytes)) {
|
||||
using (var sr = new StreamReader (ms)) {
|
||||
var read = sr.ReadLine ();
|
||||
Assert.That (read, Is.EqualTo (data));
|
||||
|
||||
[TestMethod]
|
||||
public void TestWrite()
|
||||
{
|
||||
var bytes = new byte[16];
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
{
|
||||
using (var hs = new HashingStreamEx(ms, true, null))
|
||||
{
|
||||
using (var sw = new StreamWriter(hs))
|
||||
{
|
||||
// set NewLine to ensure we don't run into cross-platform issues on Windows
|
||||
sw.NewLine = "\n";
|
||||
sw.WriteLine(data);
|
||||
}
|
||||
// When the StreamWriter is disposed, it calls Dispose on the
|
||||
//HasingStreamEx, which computes the hash.
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(hs.Hash, sha256HashOfData));
|
||||
}
|
||||
}
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
{
|
||||
using (var sr = new StreamReader(ms))
|
||||
{
|
||||
var read = sr.ReadLine();
|
||||
Assert.AreEqual(read, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,36 +1,32 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography;
|
||||
#else
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Cryptography
|
||||
namespace ModernKeePassLib.Test.Cryptography
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class HmacOtpTests
|
||||
{
|
||||
// Using the test case from Appendix D of RFC 4226
|
||||
|
||||
const string secret = "12345678901234567890";
|
||||
static readonly string[] expectedHOTP = new string[] {
|
||||
"755224", "287082", "359152", "969429", "338314",
|
||||
"254676", "287922", "162583", "399871", "520489"
|
||||
};
|
||||
|
||||
[Test ()]
|
||||
public void TestGenerate ()
|
||||
[TestClass()]
|
||||
public class HmacOtpTests
|
||||
{
|
||||
var secretBytes = Encoding.UTF8.GetBytes (secret);
|
||||
// Using the test case from Appendix D of RFC 4226
|
||||
|
||||
for (ulong i = 0; i < 10; i++) {
|
||||
var hotp = HmacOtp.Generate (secretBytes, i, 6, false, -1);
|
||||
Assert.That (hotp, Is.EqualTo (expectedHOTP[i]));
|
||||
}
|
||||
const string secret = "12345678901234567890";
|
||||
|
||||
static readonly string[] expectedHOTP = new string[]
|
||||
{
|
||||
"755224", "287082", "359152", "969429", "338314",
|
||||
"254676", "287922", "162583", "399871", "520489"
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
public void TestGenerate()
|
||||
{
|
||||
var secretBytes = Encoding.UTF8.GetBytes(secret);
|
||||
|
||||
for (ulong i = 0; i < 10; i++)
|
||||
{
|
||||
var hotp = HmacOtp.Generate(secretBytes, i, 6, false, -1);
|
||||
Assert.AreEqual(hotp, expectedHOTP[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
|
||||
{
|
||||
[TestClass]
|
||||
public class AesKdfTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestAesKdf()
|
||||
{
|
||||
// Up to KeePass 2.34, the OtpKeyProv plugin used the public
|
||||
// CompositeKey.TransformKeyManaged method (and a finalizing
|
||||
// SHA-256 computation), which became an internal method of
|
||||
// the AesKdf class in KeePass 2.35, thus OtpKeyProv now
|
||||
// uses the AesKdf class; here we ensure that the results
|
||||
// are the same
|
||||
var r = CryptoRandom.NewWeakRandom();
|
||||
var pbKey = new byte[32];
|
||||
r.NextBytes(pbKey);
|
||||
var pbSeed = new byte[32];
|
||||
r.NextBytes(pbSeed);
|
||||
var uRounds = (ulong)r.Next(1, 0x7FFF);
|
||||
|
||||
var pbMan = new byte[pbKey.Length];
|
||||
Array.Copy(pbKey, pbMan, pbKey.Length);
|
||||
Assert.IsTrue(AesKdf.TransformKeyManaged(pbMan, pbSeed, uRounds));
|
||||
pbMan = CryptoUtil.HashSha256(pbMan);
|
||||
|
||||
var kdf = new AesKdf();
|
||||
var p = kdf.GetDefaultParameters();
|
||||
p.SetUInt64(AesKdf.ParamRounds, uRounds);
|
||||
p.SetByteArray(AesKdf.ParamSeed, pbSeed);
|
||||
var pbKdf = kdf.Transform(pbKey, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbMan, pbKdf));
|
||||
}
|
||||
}
|
||||
}
|
146
ModernKeePassLib.Test/Cryptography/KeyDerivation/Argon2Tests.cs
Normal file
146
ModernKeePassLib.Test/Cryptography/KeyDerivation/Argon2Tests.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
|
||||
{
|
||||
[TestClass]
|
||||
public class Argon2Tests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestArgon2()
|
||||
{
|
||||
Argon2Kdf kdf = new Argon2Kdf();
|
||||
|
||||
// ======================================================
|
||||
// From the official Argon2 1.3 reference code package
|
||||
// (test vector for Argon2d 1.3); also on
|
||||
// https://tools.ietf.org/html/draft-irtf-cfrg-argon2-00
|
||||
|
||||
var p = kdf.GetDefaultParameters();
|
||||
kdf.Randomize(p);
|
||||
|
||||
Assert.AreEqual(p.GetUInt32(Argon2Kdf.ParamVersion, 0), 0x13U);
|
||||
|
||||
byte[] pbMsg = new byte[32];
|
||||
for (int i = 0; i < pbMsg.Length; ++i) pbMsg[i] = 1;
|
||||
|
||||
p.SetUInt64(Argon2Kdf.ParamMemory, 32 * 1024);
|
||||
p.SetUInt64(Argon2Kdf.ParamIterations, 3);
|
||||
p.SetUInt32(Argon2Kdf.ParamParallelism, 4);
|
||||
|
||||
byte[] pbSalt = new byte[16];
|
||||
for (int i = 0; i < pbSalt.Length; ++i) pbSalt[i] = 2;
|
||||
p.SetByteArray(Argon2Kdf.ParamSalt, pbSalt);
|
||||
|
||||
byte[] pbKey = new byte[8];
|
||||
for (int i = 0; i < pbKey.Length; ++i) pbKey[i] = 3;
|
||||
p.SetByteArray(Argon2Kdf.ParamSecretKey, pbKey);
|
||||
|
||||
byte[] pbAssoc = new byte[12];
|
||||
for (int i = 0; i < pbAssoc.Length; ++i) pbAssoc[i] = 4;
|
||||
p.SetByteArray(Argon2Kdf.ParamAssocData, pbAssoc);
|
||||
|
||||
byte[] pbExpc = new byte[32] {
|
||||
0x51, 0x2B, 0x39, 0x1B, 0x6F, 0x11, 0x62, 0x97,
|
||||
0x53, 0x71, 0xD3, 0x09, 0x19, 0x73, 0x42, 0x94,
|
||||
0xF8, 0x68, 0xE3, 0xBE, 0x39, 0x84, 0xF3, 0xC1,
|
||||
0xA1, 0x3A, 0x4D, 0xB9, 0xFA, 0xBE, 0x4A, 0xCB
|
||||
};
|
||||
|
||||
byte[] pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
|
||||
// ======================================================
|
||||
// From the official Argon2 1.3 reference code package
|
||||
// (test vector for Argon2d 1.0)
|
||||
|
||||
p.SetUInt32(Argon2Kdf.ParamVersion, 0x10);
|
||||
|
||||
pbExpc = new byte[32] {
|
||||
0x96, 0xA9, 0xD4, 0xE5, 0xA1, 0x73, 0x40, 0x92,
|
||||
0xC8, 0x5E, 0x29, 0xF4, 0x10, 0xA4, 0x59, 0x14,
|
||||
0xA5, 0xDD, 0x1F, 0x5C, 0xBF, 0x08, 0xB2, 0x67,
|
||||
0x0D, 0xA6, 0x8A, 0x02, 0x85, 0xAB, 0xF3, 0x2B
|
||||
};
|
||||
|
||||
pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
|
||||
// ======================================================
|
||||
// From the official 'phc-winner-argon2-20151206.zip'
|
||||
// (test vector for Argon2d 1.0)
|
||||
|
||||
p.SetUInt64(Argon2Kdf.ParamMemory, 16 * 1024);
|
||||
|
||||
pbExpc = new byte[32] {
|
||||
0x57, 0xB0, 0x61, 0x3B, 0xFD, 0xD4, 0x13, 0x1A,
|
||||
0x0C, 0x34, 0x88, 0x34, 0xC6, 0x72, 0x9C, 0x2C,
|
||||
0x72, 0x29, 0x92, 0x1E, 0x6B, 0xBA, 0x37, 0x66,
|
||||
0x5D, 0x97, 0x8C, 0x4F, 0xE7, 0x17, 0x5E, 0xD2
|
||||
};
|
||||
|
||||
pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
|
||||
// ======================================================
|
||||
// Computed using the official 'argon2' application
|
||||
// (test vectors for Argon2d 1.3)
|
||||
|
||||
p = kdf.GetDefaultParameters();
|
||||
|
||||
pbMsg = StrUtil.Utf8.GetBytes("ABC1234");
|
||||
|
||||
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 11) * 1024); // 2 MB
|
||||
p.SetUInt64(Argon2Kdf.ParamIterations, 2);
|
||||
p.SetUInt32(Argon2Kdf.ParamParallelism, 2);
|
||||
|
||||
pbSalt = StrUtil.Utf8.GetBytes("somesalt");
|
||||
p.SetByteArray(Argon2Kdf.ParamSalt, pbSalt);
|
||||
|
||||
pbExpc = new byte[32] {
|
||||
0x29, 0xCB, 0xD3, 0xA1, 0x93, 0x76, 0xF7, 0xA2,
|
||||
0xFC, 0xDF, 0xB0, 0x68, 0xAC, 0x0B, 0x99, 0xBA,
|
||||
0x40, 0xAC, 0x09, 0x01, 0x73, 0x42, 0xCE, 0xF1,
|
||||
0x29, 0xCC, 0xA1, 0x4F, 0xE1, 0xC1, 0xB7, 0xA3
|
||||
};
|
||||
|
||||
pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
|
||||
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 10) * 1024); // 1 MB
|
||||
p.SetUInt64(Argon2Kdf.ParamIterations, 3);
|
||||
|
||||
pbExpc = new byte[32] {
|
||||
0x7A, 0xBE, 0x1C, 0x1C, 0x8D, 0x7F, 0xD6, 0xDC,
|
||||
0x7C, 0x94, 0x06, 0x3E, 0xD8, 0xBC, 0xD8, 0x1C,
|
||||
0x2F, 0x87, 0x84, 0x99, 0x12, 0x83, 0xFE, 0x76,
|
||||
0x00, 0x64, 0xC4, 0x58, 0xA4, 0xDA, 0x35, 0x70
|
||||
};
|
||||
|
||||
pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
|
||||
|
||||
// TODO: Out of memory exception
|
||||
/*p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 20) * 1024); // 1 GB
|
||||
p.SetUInt64(Argon2Kdf.ParamIterations, 2);
|
||||
p.SetUInt32(Argon2Kdf.ParamParallelism, 3);
|
||||
|
||||
pbExpc = new byte[32] {
|
||||
0xE6, 0xE7, 0xCB, 0xF5, 0x5A, 0x06, 0x93, 0x05,
|
||||
0x32, 0xBA, 0x86, 0xC6, 0x1F, 0x45, 0x17, 0x99,
|
||||
0x65, 0x41, 0x77, 0xF9, 0x30, 0x55, 0x9A, 0xE8,
|
||||
0x3D, 0x21, 0x48, 0xC6, 0x2D, 0x0C, 0x49, 0x11
|
||||
};
|
||||
|
||||
pb = kdf.Transform(pbMsg, p);
|
||||
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));*/
|
||||
}
|
||||
}
|
||||
}
|
BIN
ModernKeePassLib.Test/Images/UnitTestLogo.scale-100.png
Normal file
BIN
ModernKeePassLib.Test/Images/UnitTestLogo.scale-100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
ModernKeePassLib.Test/Images/UnitTestSmallLogo.scale-100.png
Normal file
BIN
ModernKeePassLib.Test/Images/UnitTestSmallLogo.scale-100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 745 B |
BIN
ModernKeePassLib.Test/Images/UnitTestSplashScreen.scale-100.png
Normal file
BIN
ModernKeePassLib.Test/Images/UnitTestSplashScreen.scale-100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
ModernKeePassLib.Test/Images/UnitTestStoreLogo.scale-100.png
Normal file
BIN
ModernKeePassLib.Test/Images/UnitTestStoreLogo.scale-100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@@ -1,33 +1,35 @@
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Keys;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Keys
|
||||
namespace ModernKeePassLib.Test.Keys
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class CompositeKeyTests
|
||||
{
|
||||
[Test]
|
||||
public void TestGenerateKey32 ()
|
||||
[TestClass()]
|
||||
public class CompositeKeyTests
|
||||
{
|
||||
var originalKey = new byte[32];
|
||||
var expectedKey = new byte[32] {
|
||||
0xF0, 0xED, 0x57, 0xD5, 0xF0, 0xDA, 0xF3, 0x47,
|
||||
0x90, 0xD0, 0xDB, 0x43, 0x25, 0xC6, 0x81, 0x2C,
|
||||
0x81, 0x6A, 0x0D, 0x94, 0x96, 0xA9, 0x03, 0xE1,
|
||||
0x20, 0xD4, 0x3A, 0x3E, 0x45, 0xAD, 0x02, 0x65
|
||||
};
|
||||
const ulong rounds = 1;
|
||||
[TestMethod]
|
||||
public void TestGenerateKey32()
|
||||
{
|
||||
var originalKey = new byte[32];
|
||||
var expectedKey = new byte[32]
|
||||
{
|
||||
0xF0, 0xED, 0x57, 0xD5, 0xF0, 0xDA, 0xF3, 0x47,
|
||||
0x90, 0xD0, 0xDB, 0x43, 0x25, 0xC6, 0x81, 0x2C,
|
||||
0x81, 0x6A, 0x0D, 0x94, 0x96, 0xA9, 0x03, 0xE1,
|
||||
0x20, 0xD4, 0x3A, 0x3E, 0x45, 0xAD, 0x02, 0x65
|
||||
};
|
||||
const ulong rounds = 1;
|
||||
|
||||
var composite = new CompositeKey ();
|
||||
AesKdf kdf = new AesKdf();
|
||||
KdfParameters p = kdf.GetDefaultParameters();
|
||||
p.SetUInt64(AesKdf.ParamRounds, rounds);
|
||||
p.SetByteArray(AesKdf.ParamSeed, originalKey);
|
||||
var key = composite.GenerateKey32(p);
|
||||
Assert.That (key, Is.Not.Null);
|
||||
var keyData = key.ReadData ();
|
||||
Assert.That (keyData, Is.EqualTo (expectedKey));
|
||||
var composite = new CompositeKey();
|
||||
AesKdf kdf = new AesKdf();
|
||||
KdfParameters p = kdf.GetDefaultParameters();
|
||||
p.SetUInt64(AesKdf.ParamRounds, rounds);
|
||||
p.SetByteArray(AesKdf.ParamSeed, originalKey);
|
||||
var key = composite.GenerateKey32(p);
|
||||
Assert.IsNotNull(key);
|
||||
var keyData = key.ReadData();
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,39 +1,35 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Keys;
|
||||
#else
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Keys;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Keys
|
||||
namespace ModernKeePassLib.Test.Keys
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class KcpCustomKeyTests
|
||||
{
|
||||
static readonly byte[] testData = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
[Test ()]
|
||||
public void TestConstruct ()
|
||||
[TestClass()]
|
||||
public class KcpCustomKeyTests
|
||||
{
|
||||
var expectedHash = new byte[32] {
|
||||
0xAF, 0x55, 0x70, 0xF5, 0xA1, 0x81, 0x0B, 0x7A,
|
||||
0xF7, 0x8C, 0xAF, 0x4B, 0xC7, 0x0A, 0x66, 0x0F,
|
||||
0x0D, 0xF5, 0x1E, 0x42, 0xBA, 0xF9, 0x1D, 0x4D,
|
||||
0xE5, 0xB2, 0x32, 0x8D, 0xE0, 0xE8, 0x3D, 0xFC
|
||||
};
|
||||
static readonly byte[] testData =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
var key = new KcpCustomKey ("test1", testData, false);
|
||||
var keyData = key.KeyData.ReadData ();
|
||||
Assert.That (keyData, Is.EqualTo (testData));
|
||||
[TestMethod]
|
||||
public void TestConstruct()
|
||||
{
|
||||
var expectedHash = new byte[32]
|
||||
{
|
||||
0xAF, 0x55, 0x70, 0xF5, 0xA1, 0x81, 0x0B, 0x7A,
|
||||
0xF7, 0x8C, 0xAF, 0x4B, 0xC7, 0x0A, 0x66, 0x0F,
|
||||
0x0D, 0xF5, 0x1E, 0x42, 0xBA, 0xF9, 0x1D, 0x4D,
|
||||
0xE5, 0xB2, 0x32, 0x8D, 0xE0, 0xE8, 0x3D, 0xFC
|
||||
};
|
||||
|
||||
key = new KcpCustomKey ("test2", testData, true);
|
||||
keyData = key.KeyData.ReadData ();
|
||||
Assert.That (keyData, Is.EqualTo (expectedHash));
|
||||
var key = new KcpCustomKey("test1", testData, false);
|
||||
var keyData = key.KeyData.ReadData();
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(keyData, testData));
|
||||
|
||||
key = new KcpCustomKey("test2", testData, true);
|
||||
keyData = key.KeyData.ReadData();
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedHash));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,76 +1,84 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Keys;
|
||||
#else
|
||||
using Windows.Storage;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Keys;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Keys
|
||||
namespace ModernKeePassLib.Test.Keys
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class KcpKeyFileTests
|
||||
{
|
||||
const string testCreateFile = "TestCreate.xml";
|
||||
const string testKey = "0123456789";
|
||||
|
||||
const string expectedFileStart =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
|
||||
"<KeyFile>\r\n" +
|
||||
"\t<Meta>\r\n" +
|
||||
"\t\t<Version>1.00</Version>\r\n" +
|
||||
"\t</Meta>\r\n" +
|
||||
"\t<Key>\r\n" +
|
||||
"\t\t<Data>";
|
||||
|
||||
const string expectedFileEnd = "\t</Key>\r\n" +
|
||||
"</KeyFile>\r\n";
|
||||
|
||||
[Test ()]
|
||||
public void TestConstruct ()
|
||||
[TestClass]
|
||||
public class KcpKeyFileTests
|
||||
{
|
||||
var expectedKeyData = new byte[32] {
|
||||
0xC1, 0xB1, 0x12, 0x77, 0x23, 0xB8, 0x99, 0xB8,
|
||||
0xB9, 0x3B, 0x1B, 0xFF, 0x6C, 0xBE, 0xA1, 0x5B,
|
||||
0x8B, 0x99, 0xAC, 0xBD, 0x99, 0x51, 0x85, 0x95,
|
||||
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
|
||||
};
|
||||
private const string TestCreateFile = "TestCreate.xml";
|
||||
private const string TestKey = "0123456789";
|
||||
|
||||
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
|
||||
using (var fs = new FileStream(fullPath, FileMode.Create)) {
|
||||
using (var sw = new StreamWriter(fs)) {
|
||||
sw.Write (expectedFileStart);
|
||||
sw.Write (testKey);
|
||||
sw.Write (expectedFileEnd);
|
||||
private const string ExpectedFileStart =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
|
||||
"<KeyFile>\r\n" +
|
||||
"\t<Meta>\r\n" +
|
||||
"\t\t<Version>1.00</Version>\r\n" +
|
||||
"\t</Meta>\r\n" +
|
||||
"\t<Key>\r\n" +
|
||||
"\t\t<Data>";
|
||||
|
||||
private const string ExpectedFileEnd = "\t</Key>\r\n" +
|
||||
"</KeyFile>\r\n";
|
||||
|
||||
[TestMethod]
|
||||
public void TestConstruct()
|
||||
{
|
||||
var expectedKeyData = new byte[32]
|
||||
{
|
||||
0xC1, 0xB1, 0x12, 0x77, 0x23, 0xB8, 0x99, 0xB8,
|
||||
0xB9, 0x3B, 0x1B, 0xFF, 0x6C, 0xBE, 0xA1, 0x5B,
|
||||
0x8B, 0x99, 0xAC, 0xBD, 0x99, 0x51, 0x85, 0x95,
|
||||
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
|
||||
};
|
||||
|
||||
var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
|
||||
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
|
||||
using (var fs = file.OpenStreamForWriteAsync().GetAwaiter().GetResult())
|
||||
{
|
||||
using (var sw = new StreamWriter(fs))
|
||||
{
|
||||
sw.Write(ExpectedFileStart);
|
||||
sw.Write(TestKey);
|
||||
sw.Write(ExpectedFileEnd);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var keyFile = new KcpKeyFile(fullPath);
|
||||
var keyData = keyFile.KeyData.ReadData();
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedKeyData));
|
||||
}
|
||||
finally
|
||||
{
|
||||
file.DeleteAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var keyFile = new KcpKeyFile (fullPath);
|
||||
var keyData = keyFile.KeyData.ReadData ();
|
||||
Assert.That (keyData, Is.EqualTo (expectedKeyData));
|
||||
} finally {
|
||||
File.Delete (fullPath);
|
||||
}
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestCreate()
|
||||
{
|
||||
var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
|
||||
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
|
||||
KcpKeyFile.Create(fullPath, null);
|
||||
try
|
||||
{
|
||||
var fileContents = FileIO.ReadTextAsync(file).GetAwaiter().GetResult();
|
||||
|
||||
[Test ()]
|
||||
public void TestCreate ()
|
||||
{
|
||||
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
|
||||
File.Create(fullPath).Close();
|
||||
KcpKeyFile.Create (fullPath, null);
|
||||
try {
|
||||
var fileContents = File.ReadAllText (fullPath);
|
||||
Assert.That (fileContents.Length, Is.EqualTo (187));
|
||||
Assert.That (fileContents, Does.StartWith (expectedFileStart));
|
||||
Assert.That (fileContents, Does.EndWith (expectedFileEnd));
|
||||
} finally {
|
||||
File.Delete (fullPath);
|
||||
}
|
||||
Assert.AreEqual(fileContents.Length, 187);
|
||||
Assert.IsTrue(fileContents.StartsWith(ExpectedFileStart));
|
||||
Assert.IsTrue(fileContents.EndsWith(ExpectedFileEnd));
|
||||
}
|
||||
finally
|
||||
{
|
||||
file.DeleteAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,33 +1,29 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Keys;
|
||||
#else
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Keys;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Keys
|
||||
namespace ModernKeePassLib.Test.Keys
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class KcpPasswordTests
|
||||
{
|
||||
const string testPassword = "password";
|
||||
|
||||
[Test ()]
|
||||
public void TestConstruct ()
|
||||
[TestClass()]
|
||||
public class KcpPasswordTests
|
||||
{
|
||||
var expectedHash = new byte[32] {
|
||||
0x5E, 0x88, 0x48, 0x98, 0xDA, 0x28, 0x04, 0x71,
|
||||
0x51, 0xD0, 0xE5, 0x6F, 0x8D, 0xC6, 0x29, 0x27,
|
||||
0x73, 0x60, 0x3D, 0x0D, 0x6A, 0xAB, 0xBD, 0xD6,
|
||||
0x2A, 0x11, 0xEF, 0x72, 0x1D, 0x15, 0x42, 0xD8
|
||||
};
|
||||
const string testPassword = "password";
|
||||
|
||||
var key = new KcpPassword (testPassword);
|
||||
var keyData = key.KeyData.ReadData ();
|
||||
Assert.That (keyData, Is.EqualTo (expectedHash));
|
||||
[TestMethod]
|
||||
public void TestConstruct()
|
||||
{
|
||||
var expectedHash = new byte[32]
|
||||
{
|
||||
0x5E, 0x88, 0x48, 0x98, 0xDA, 0x28, 0x04, 0x71,
|
||||
0x51, 0xD0, 0xE5, 0x6F, 0x8D, 0xC6, 0x29, 0x27,
|
||||
0x73, 0x60, 0x3D, 0x0D, 0x6A, 0xAB, 0xBD, 0xD6,
|
||||
0x2A, 0x11, 0xEF, 0x72, 0x1D, 0x15, 0x42, 0xD8
|
||||
};
|
||||
|
||||
var key = new KcpPassword(testPassword);
|
||||
var keyData = key.KeyData.ReadData();
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedHash));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,64 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{067456C0-086C-46A8-B37F-1405717B7BFC}</ProjectGuid>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0A4279CF-2A67-4868-9906-052E50C25F3B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ModernKeePassLib.Test</RootNamespace>
|
||||
<AssemblyName>ModernKeePassLib.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformVersion>8.1</TargetPlatformVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>ModernKeePassLib.Test_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<AppxBundle>Never</AppxBundle>
|
||||
<AllowCrossPlatformRetargeting>False</AllowCrossPlatformRetargeting>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppXPackage>True</AppXPackage>
|
||||
<AppxPackageIncludePrivateSymbols>true</AppxPackageIncludePrivateSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Crypto">
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.3\lib\net40\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Splat.2.0.0\lib\Net45\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="Windows">
|
||||
<HintPath>..\ModernKeePassLib\Libs\Windows.winmd</HintPath>
|
||||
</Reference>
|
||||
<!--A reference to the entire .Net Framework and Windows SDK are automatically included-->
|
||||
<SDKReference Include="MSTestFramework, Version=14.0" />
|
||||
<SDKReference Include="TestPlatform, Version=14.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cryptography\Cipher\Chacha20Tests.cs" />
|
||||
<Compile Include="Cryptography\Cipher\StandardAesEngineTests.cs" />
|
||||
<Compile Include="Cryptography\CryptoRandomStreamTests.cs" />
|
||||
<Compile Include="Cryptography\CryptoRandomTests.cs" />
|
||||
<Compile Include="Cryptography\HashingStreamExTests.cs" />
|
||||
<Compile Include="Cryptography\Hash\Blake2bTests.cs" />
|
||||
<Compile Include="Cryptography\Hash\HmacTests.cs" />
|
||||
<Compile Include="Cryptography\Hash\SHAManagedTests.cs" />
|
||||
<Compile Include="Cryptography\HmacOtpTests.cs" />
|
||||
<Compile Include="Cryptography\KeyDerivation\AesKdfTests.cs" />
|
||||
<Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" />
|
||||
<Compile Include="Keys\CompositeKeyTests.cs" />
|
||||
<Compile Include="Keys\KcpCustomKeyTests.cs" />
|
||||
<Compile Include="Keys\KcpKeyFileTests.cs" />
|
||||
@@ -67,9 +134,13 @@
|
||||
<Compile Include="Serialization\HashedBlockStreamTests.cs" />
|
||||
<Compile Include="Serialization\KdbxFileTests.cs" />
|
||||
<Compile Include="Utility\GfxUtilTests.cs" />
|
||||
<Compile Include="Utility\MemUtilTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="ModernKeePassLib.Test_TemporaryKey.pfx" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -78,18 +149,46 @@
|
||||
<Name>ModernKeePassLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.3\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\win8\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Validation.2.4.18\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Images\UnitTestLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestSmallLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestSplashScreen.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestStoreLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
BIN
ModernKeePassLib.Test/ModernKeePassLib.Test_TemporaryKey.pfx
Normal file
BIN
ModernKeePassLib.Test/ModernKeePassLib.Test_TemporaryKey.pfx
Normal file
Binary file not shown.
56
ModernKeePassLib.Test/Package.appxmanifest
Normal file
56
ModernKeePassLib.Test/Package.appxmanifest
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
|
||||
|
||||
<Identity Name="2aac30f7-3bad-4e17-be76-27de378756c9"
|
||||
Publisher="CN=GBE"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>ModernKeePassLib.Test</DisplayName>
|
||||
<PublisherDisplayName>GBE</PublisherDisplayName>
|
||||
<Logo>Images\UnitTestStoreLogo.png</Logo>
|
||||
<Description>ModernKeePassLib.Test</Description>
|
||||
</Properties>
|
||||
|
||||
<Prerequisites>
|
||||
<OSMinVersion>6.3.0</OSMinVersion>
|
||||
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
|
||||
</Prerequisites>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="vstest.executionengine.App"
|
||||
Executable="vstest.executionengine.appcontainer.exe"
|
||||
EntryPoint="vstest.executionengine.App">
|
||||
<VisualElements
|
||||
DisplayName="NoUIEntryPoints"
|
||||
Logo="Images\UnitTestLogo.png"
|
||||
SmallLogo="Images\UnitTestSmallLogo.png"
|
||||
Description="vstest.executionengine.App"
|
||||
ForegroundText="light"
|
||||
BackgroundColor="#0084FF">
|
||||
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
|
||||
<Application Id="vstest.executionengine.x86.App"
|
||||
Executable="vstest.executionengine.appcontainer.x86.exe"
|
||||
EntryPoint="vstest.executionengine.x86.App">
|
||||
<VisualElements
|
||||
DisplayName="NoUIEntryPoints"
|
||||
Logo="Images\UnitTestLogo.png"
|
||||
SmallLogo="Images\UnitTestSmallLogo.png"
|
||||
Description="vstest.executionengine.x86.App"
|
||||
ForegroundText="light"
|
||||
BackgroundColor="#0084FF">
|
||||
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
@@ -10,18 +10,10 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ModernKeePassLib.Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("067456c0-086c-46a8-b37f-1405717b7bfc")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
|
@@ -1,71 +1,73 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Serialization;
|
||||
#else
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Serialization;
|
||||
#endif
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
namespace ModernKeePassLib.Test.Serialization
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class HashedBlockStreamTests
|
||||
{
|
||||
static readonly byte[] data = new byte[16];
|
||||
|
||||
static readonly byte[] hashStreamData = new byte[] {
|
||||
// The first 4 bytes are an integer indicating the block index
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
// Then the SHA-256 hash of the data
|
||||
0x37, 0x47, 0x08, 0xFF, 0xF7, 0x71, 0x9D, 0xD5,
|
||||
0x97, 0x9E, 0xC8, 0x75, 0xD5, 0x6C, 0xD2, 0x28,
|
||||
0x6F, 0x6D, 0x3C, 0xF7, 0xEC, 0x31, 0x7A, 0x3B,
|
||||
0x25, 0x63, 0x2A, 0xAB, 0x28, 0xEC, 0x37, 0xBB,
|
||||
// then an integer that is the length of the data
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
// and finally the data itself
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// Next, a terminating block
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
// terminating block is indicated by a hash of all 0s...
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// ...and by a size of 0
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
[Test ()]
|
||||
public void TestRead ()
|
||||
[TestClass()]
|
||||
public class HashedBlockStreamTests
|
||||
{
|
||||
using (var ms = new MemoryStream (hashStreamData)) {
|
||||
using (var hbs = new HashedBlockStream (ms, false)) {
|
||||
using (var br = new BinaryReader(hbs)) {
|
||||
var bytes = br.ReadBytes (data.Length);
|
||||
Assert.That (bytes, Is.EqualTo (data));
|
||||
Assert.That (() => br.ReadByte (), Throws.InstanceOf<EndOfStreamException> ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static readonly byte[] data = new byte[16];
|
||||
|
||||
[Test ()]
|
||||
public void TestWrite ()
|
||||
{
|
||||
var buffer = new byte[hashStreamData.Length];
|
||||
using (var ms = new MemoryStream (buffer)) {
|
||||
using (var hbs = new HashedBlockStream (ms, true)) {
|
||||
using (var bw = new BinaryWriter(hbs)) {
|
||||
bw.Write (data);
|
||||
}
|
||||
static readonly byte[] hashStreamData = new byte[]
|
||||
{
|
||||
// The first 4 bytes are an integer indicating the block index
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
// Then the SHA-256 hash of the data
|
||||
0x37, 0x47, 0x08, 0xFF, 0xF7, 0x71, 0x9D, 0xD5,
|
||||
0x97, 0x9E, 0xC8, 0x75, 0xD5, 0x6C, 0xD2, 0x28,
|
||||
0x6F, 0x6D, 0x3C, 0xF7, 0xEC, 0x31, 0x7A, 0x3B,
|
||||
0x25, 0x63, 0x2A, 0xAB, 0x28, 0xEC, 0x37, 0xBB,
|
||||
// then an integer that is the length of the data
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
// and finally the data itself
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// Next, a terminating block
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
// terminating block is indicated by a hash of all 0s...
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// ...and by a size of 0
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
public void TestRead()
|
||||
{
|
||||
using (var ms = new MemoryStream(hashStreamData))
|
||||
{
|
||||
using (var hbs = new HashedBlockStream(ms, false))
|
||||
{
|
||||
using (var br = new BinaryReader(hbs))
|
||||
{
|
||||
var bytes = br.ReadBytes(data.Length);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(bytes, data));
|
||||
Assert.ThrowsException<EndOfStreamException>(() => br.ReadByte());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestWrite()
|
||||
{
|
||||
var buffer = new byte[hashStreamData.Length];
|
||||
using (var ms = new MemoryStream(buffer))
|
||||
{
|
||||
using (var hbs = new HashedBlockStream(ms, true))
|
||||
{
|
||||
using (var bw = new BinaryWriter(hbs))
|
||||
{
|
||||
bw.Write(data);
|
||||
}
|
||||
}
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(buffer, hashStreamData));
|
||||
}
|
||||
}
|
||||
Assert.That (buffer, Is.EqualTo (hashStreamData));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,50 +1,38 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Windows.UI;
|
||||
#if KeePassLib
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Security;
|
||||
using KeePassLib.Serialization;
|
||||
using KeePassLib.Collections;
|
||||
#else
|
||||
using ModernKeePassLib;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Keys;
|
||||
using ModernKeePassLib.Security;
|
||||
using ModernKeePassLib.Serialization;
|
||||
using ModernKeePassLib.Collections;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
namespace ModernKeePassLib.Test.Serialization
|
||||
{
|
||||
[TestFixture()]
|
||||
[TestClass()]
|
||||
public class KdbxFileTests
|
||||
{
|
||||
const string testLocalizedAppName = "My Localized App Name";
|
||||
const string TestLocalizedAppName = "My Localized App Name";
|
||||
|
||||
const string testDatabaseName = "My Database Name";
|
||||
const string testDatabaseDescription = "My Database Description";
|
||||
const string testDefaultUserName = "My Default User Name";
|
||||
const string testColor = "#FF0000"; // Red
|
||||
const string TestDatabaseName = "My Database Name";
|
||||
const string TestDatabaseDescription = "My Database Description";
|
||||
const string TestDefaultUserName = "My Default User Name";
|
||||
const string TestColor = "#FF0000"; // Red
|
||||
|
||||
const string testRootGroupName = "My Root Group Name";
|
||||
const string testRootGroupNotes = "My Root Group Notes";
|
||||
const string testRootGroupDefaultAutoTypeSequence = "My Root Group Default Auto Type Sequence";
|
||||
const string TestRootGroupName = "My Root Group Name";
|
||||
const string TestRootGroupNotes = "My Root Group Notes";
|
||||
const string TestRootGroupDefaultAutoTypeSequence = "My Root Group Default Auto Type Sequence";
|
||||
|
||||
const string testDatabase = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n" +
|
||||
const string TestDatabase = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n" +
|
||||
"<KeePassFile>\r\n" +
|
||||
"\t<Meta>\r\n" +
|
||||
"\t\t<Generator>" + testLocalizedAppName + "</Generator>\r\n" +
|
||||
"\t\t<DatabaseName>" + testDatabaseName + "</DatabaseName>\r\n" +
|
||||
"\t\t<Generator>" + TestLocalizedAppName + "</Generator>\r\n" +
|
||||
"\t\t<DatabaseName>" + TestDatabaseName + "</DatabaseName>\r\n" +
|
||||
"\t\t<DatabaseNameChanged>2017-10-23T08:03:55Z</DatabaseNameChanged>\r\n" +
|
||||
"\t\t<DatabaseDescription>" + testDatabaseDescription + "</DatabaseDescription>\r\n" +
|
||||
"\t\t<DatabaseDescription>" + TestDatabaseDescription + "</DatabaseDescription>\r\n" +
|
||||
"\t\t<DatabaseDescriptionChanged>2017-10-23T08:03:55Z</DatabaseDescriptionChanged>\r\n" +
|
||||
"\t\t<DefaultUserName>" + testDefaultUserName + "</DefaultUserName>\r\n" +
|
||||
"\t\t<DefaultUserName>" + TestDefaultUserName + "</DefaultUserName>\r\n" +
|
||||
"\t\t<DefaultUserNameChanged>2017-10-23T08:03:55Z</DefaultUserNameChanged>\r\n" +
|
||||
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
|
||||
//"\t\t<Color>" + testColor + "</Color>\r\n" +
|
||||
@@ -74,8 +62,8 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
"\t<Root>\r\n" +
|
||||
"\t\t<Group>\r\n" +
|
||||
"\t\t\t<UUID>AAAAAAAAAAAAAAAAAAAAAA==</UUID>\r\n" +
|
||||
"\t\t\t<Name>" + testRootGroupName + "</Name>\r\n" +
|
||||
"\t\t\t<Notes>" + testRootGroupNotes + "</Notes>\r\n" +
|
||||
"\t\t\t<Name>" + TestRootGroupName + "</Name>\r\n" +
|
||||
"\t\t\t<Notes>" + TestRootGroupNotes + "</Notes>\r\n" +
|
||||
"\t\t\t<IconID>49</IconID>\r\n" +
|
||||
"\t\t\t<Times>\r\n" +
|
||||
"\t\t\t\t<CreationTime>2017-10-23T08:03:55Z</CreationTime>\r\n" +
|
||||
@@ -87,7 +75,7 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
"\t\t\t\t<LocationChanged>2017-10-23T08:03:55Z</LocationChanged>\r\n" +
|
||||
"\t\t\t</Times>\r\n" +
|
||||
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
|
||||
"\t\t\t<DefaultAutoTypeSequence>" + testRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
||||
"\t\t\t<DefaultAutoTypeSequence>" + TestRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
||||
"\t\t\t<EnableAutoType>null</EnableAutoType>\r\n" +
|
||||
"\t\t\t<EnableSearching>null</EnableSearching>\r\n" +
|
||||
"\t\t\t<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>\r\n" +
|
||||
@@ -96,24 +84,24 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
"\t</Root>\r\n" +
|
||||
"</KeePassFile>";
|
||||
|
||||
const string testDate = "2017-10-23T08:03:55Z";
|
||||
const string TestDate = "2017-10-23T08:03:55Z";
|
||||
|
||||
[Test()]
|
||||
[TestMethod]
|
||||
public void TestLoad()
|
||||
{
|
||||
var database = new PwDatabase();
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(testDatabase)))
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
|
||||
{
|
||||
var file = new KdbxFile(database);
|
||||
file.Load(ms, KdbxFormat.PlainXml, null);
|
||||
}
|
||||
//Assert.That(database.Color.ToArgb(), Is.EqualTo(Color.Red.ToArgb()));
|
||||
Assert.That(database.Compression, Is.EqualTo(PwCompressionAlgorithm.GZip));
|
||||
Assert.AreEqual(database.Compression, PwCompressionAlgorithm.GZip);
|
||||
//Assert.That (database.CustomData, Is.EqualTo ());
|
||||
Assert.That(database.CustomIcons, Is.Empty);
|
||||
Assert.IsTrue(database.CustomIcons.Count == 0);
|
||||
}
|
||||
|
||||
[Test()]
|
||||
[TestMethod]
|
||||
public void TestSave()
|
||||
{
|
||||
var buffer = new byte[4096];
|
||||
@@ -121,23 +109,23 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
{
|
||||
var database = new PwDatabase();
|
||||
database.New(new IOConnectionInfo(), new CompositeKey());
|
||||
var date = DateTime.Parse(testDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
|
||||
var date = DateTime.Parse(TestDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
|
||||
//var date = DateTime.UtcNow;
|
||||
PwDatabase.LocalizedAppName = testLocalizedAppName;
|
||||
database.Name = testDatabaseName;
|
||||
PwDatabase.LocalizedAppName = TestLocalizedAppName;
|
||||
database.Name = TestDatabaseName;
|
||||
database.NameChanged = date;
|
||||
database.Description = testDatabaseDescription;
|
||||
database.Description = TestDatabaseDescription;
|
||||
database.DescriptionChanged = date;
|
||||
database.DefaultUserName = testDefaultUserName;
|
||||
database.DefaultUserName = TestDefaultUserName;
|
||||
database.DefaultUserNameChanged = date;
|
||||
//database.Color = Color.Red;
|
||||
database.MasterKeyChanged = date;
|
||||
database.RecycleBinChanged = date;
|
||||
database.EntryTemplatesGroupChanged = date;
|
||||
database.RootGroup.Uuid = PwUuid.Zero;
|
||||
database.RootGroup.Name = testRootGroupName;
|
||||
database.RootGroup.Notes = testRootGroupNotes;
|
||||
database.RootGroup.DefaultAutoTypeSequence = testRootGroupDefaultAutoTypeSequence;
|
||||
database.RootGroup.Name = TestRootGroupName;
|
||||
database.RootGroup.Notes = TestRootGroupNotes;
|
||||
database.RootGroup.DefaultAutoTypeSequence = TestRootGroupDefaultAutoTypeSequence;
|
||||
database.RootGroup.CreationTime = date;
|
||||
database.RootGroup.LastModificationTime = date;
|
||||
database.RootGroup.LastAccessTime = date;
|
||||
@@ -146,22 +134,21 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
||||
var file = new KdbxFile(database);
|
||||
file.Save(ms, null, KdbxFormat.PlainXml, null);
|
||||
}
|
||||
var fileContents = Encoding.UTF8.GetString(buffer).Replace("\0", "");
|
||||
if (typeof(KdbxFile).Namespace.StartsWith("KeePassLib.")
|
||||
&& Environment.OSVersion.Platform != PlatformID.Win32NT)
|
||||
var fileContents = Encoding.UTF8.GetString(buffer, 0, buffer.Length).Replace("\0", "");
|
||||
if (typeof(KdbxFile).Namespace.StartsWith("KeePassLib."))
|
||||
{
|
||||
// Upstream KeePassLib does not specify line endings for XmlTextWriter,
|
||||
// so it uses native line endings.
|
||||
fileContents = fileContents.Replace("\n", "\r\n");
|
||||
}
|
||||
Assert.That(fileContents, Is.EqualTo(testDatabase));
|
||||
Assert.AreEqual(fileContents, TestDatabase);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSearch()
|
||||
{
|
||||
var database = new PwDatabase();
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(testDatabase)))
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
|
||||
{
|
||||
var file = new KdbxFile(database);
|
||||
file.Load(ms, KdbxFormat.PlainXml, null);
|
||||
|
@@ -1,16 +1,10 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Utility;
|
||||
#else
|
||||
using Splat;
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Utility;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Test.Shared.Utility
|
||||
namespace ModernKeePassLib.Test.Utility
|
||||
{
|
||||
[TestFixture ()]
|
||||
[TestClass ()]
|
||||
public class GfxUtilTests
|
||||
{
|
||||
// 16x16 all white PNG file, base64 encoded
|
||||
@@ -20,14 +14,14 @@ namespace ModernKeePassLib.Test.Shared.Utility
|
||||
"VkIHdpdGggR0lNUFeBDhcAAAAaSURBVCjPY/z//z8DKYCJgUQwqmFUw9DRAABVb" +
|
||||
"QMdny4VogAAAABJRU5ErkJggg==";
|
||||
|
||||
[Test ()]
|
||||
[TestMethod]
|
||||
public void TestLoadImage ()
|
||||
{
|
||||
var testData = Convert.FromBase64String (testImageData);
|
||||
var image = GfxUtil.ScaleImage(testData, 16, 16).GetAwaiter().GetResult();
|
||||
//var image = GfxUtil.LoadImage(testData);
|
||||
Assert.That (image.Width, Is.EqualTo (16));
|
||||
Assert.That (image.Height, Is.EqualTo (16));
|
||||
Assert.AreEqual(image.Width, 16);
|
||||
Assert.AreEqual(image.Height, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
89
ModernKeePassLib.Test/Utility/MemUtilTests.cs
Normal file
89
ModernKeePassLib.Test/Utility/MemUtilTests.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Test.Utility
|
||||
{
|
||||
[TestClass]
|
||||
public class MemUtilTests
|
||||
{
|
||||
private byte[] _pb = CryptoRandom.Instance.GetRandomBytes((uint)CryptoRandom.NewWeakRandom().Next(0, 0x2FFFF));
|
||||
|
||||
[TestMethod]
|
||||
public void TestGzip()
|
||||
{
|
||||
var pbCompressed = MemUtil.Compress(_pb);
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Decompress(pbCompressed), _pb));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMemUtil()
|
||||
{
|
||||
Encoding enc = StrUtil.Utf8;
|
||||
_pb = enc.GetBytes("012345678901234567890a");
|
||||
byte[] pbN = enc.GetBytes("9012");
|
||||
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 9);
|
||||
|
||||
pbN = enc.GetBytes("01234567890123");
|
||||
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 0);
|
||||
|
||||
pbN = enc.GetBytes("a");
|
||||
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 21);
|
||||
|
||||
pbN = enc.GetBytes("0a");
|
||||
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 20);
|
||||
|
||||
pbN = enc.GetBytes("1");
|
||||
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 1);
|
||||
|
||||
pbN = enc.GetBytes("b");
|
||||
Assert.IsTrue(MemUtil.IndexOf(_pb, pbN) < 0);
|
||||
|
||||
pbN = enc.GetBytes("012b");
|
||||
Assert.IsTrue(MemUtil.IndexOf(_pb, pbN) < 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBase32()
|
||||
{
|
||||
byte[] pbRes = MemUtil.ParseBase32("MY======");
|
||||
byte[] pbExp = Encoding.UTF8.GetBytes("f");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("MZXQ====");
|
||||
pbExp = Encoding.UTF8.GetBytes("fo");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("MZXW6===");
|
||||
pbExp = Encoding.UTF8.GetBytes("foo");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("MZXW6YQ=");
|
||||
pbExp = Encoding.UTF8.GetBytes("foob");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("MZXW6YTB");
|
||||
pbExp = Encoding.UTF8.GetBytes("fooba");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("MZXW6YTBOI======");
|
||||
pbExp = Encoding.UTF8.GetBytes("foobar");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
|
||||
pbRes = MemUtil.ParseBase32("JNSXSIDQOJXXM2LEMVZCAYTBONSWIIDPNYQG63TFFV2GS3LFEBYGC43TO5XXEZDTFY======");
|
||||
pbExp = Encoding.UTF8.GetBytes("Key provider based on one-time passwords.");
|
||||
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMemUtil2()
|
||||
{
|
||||
var i = 0 - 0x10203040;
|
||||
var pbRes = MemUtil.Int32ToBytes(i);
|
||||
Assert.AreEqual(MemUtil.ByteArrayToHexString(pbRes), "C0CFDFEF");
|
||||
Assert.AreEqual(MemUtil.BytesToUInt32(pbRes), (uint)i);
|
||||
Assert.AreEqual(MemUtil.BytesToInt32(pbRes), i);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="PInvoke.BCrypt" publicKeyToken="9e300f9f87f04a7a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.5.0.0" newVersion="0.5.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="PInvoke.NCrypt" publicKeyToken="9e300f9f87f04a7a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.5.0.0" newVersion="0.5.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Validation" publicKeyToken="2fc06f0d701809a7" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.WindowsRuntime" publicKeyToken="b77a5c561934e089" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>
|
@@ -1,6 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net462" />
|
||||
<package id="NUnit" version="3.8.1" targetFramework="net452" />
|
||||
<package id="Splat" version="2.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="win81" />
|
||||
<package id="NETStandard.Library" version="1.6.1" targetFramework="win81" />
|
||||
<package id="Portable.BouncyCastle" version="1.8.1.3" targetFramework="win81" />
|
||||
<package id="Splat" version="2.0.0" targetFramework="win81" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Globalization" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Net.Http" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Net.Primitives" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Runtime.WindowsRuntime" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Threading" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="win81" />
|
||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="win81" />
|
||||
<package id="Validation" version="2.4.18" targetFramework="win81" />
|
||||
</packages>
|
@@ -69,7 +69,7 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ChaCha20Stream : Stream
|
||||
public sealed class ChaCha20Stream : Stream
|
||||
{
|
||||
private Stream m_sBase;
|
||||
private readonly bool m_bWriting;
|
||||
|
@@ -165,7 +165,7 @@ namespace ModernKeePassLib.Cryptography
|
||||
pb = MemUtil.Int64ToBytes(DateTime.UtcNow.ToBinary());
|
||||
MemUtil.Write(ms, pb);
|
||||
|
||||
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
// In try-catch for systems without GUI;
|
||||
// https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/
|
||||
try
|
||||
|
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography
|
||||
{
|
||||
public static class CryptographicHashExtensions
|
||||
{
|
||||
public static int TransformBlock(this CryptographicHash hash, byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
byte[] buffer;
|
||||
if (inputCount < inputBuffer.Length)
|
||||
{
|
||||
buffer = new byte[inputCount];
|
||||
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = inputBuffer;
|
||||
}
|
||||
|
||||
hash.Append(buffer.AsBuffer());
|
||||
if (outputBuffer != null)
|
||||
{
|
||||
Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||
}
|
||||
|
||||
return inputCount;
|
||||
}
|
||||
|
||||
public static byte[] TransformFinalBlock(this CryptographicHash hash, byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
hash.TransformBlock(inputBuffer, inputOffset, inputCount, null, 0);
|
||||
if (inputCount == inputBuffer.Length)
|
||||
{
|
||||
return inputBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
var buffer = new byte[inputCount];
|
||||
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public abstract class DigestManaged: IDisposable
|
||||
{
|
||||
protected IDigest Hash;
|
||||
|
||||
public byte[] ComputeHash(byte[] value)
|
||||
{
|
||||
return ComputeHash(value, 0, value.Length);
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(byte[] value, int offset, int length)
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
|
||||
byte[] resBuf = new byte[Hash.GetDigestSize()];
|
||||
Hash.BlockUpdate(value, 0, length);
|
||||
Hash.DoFinal(resBuf, 0);
|
||||
|
||||
return resBuf;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Hash.Reset();
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,7 +5,17 @@ namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class HMAC : IDisposable
|
||||
{
|
||||
protected HMac _hmac;
|
||||
protected HMac Hmac;
|
||||
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = new byte[Hmac.GetMacSize()];
|
||||
Hmac.DoFinal(result, 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(byte[] value)
|
||||
{
|
||||
@@ -16,16 +26,37 @@ namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
|
||||
byte[] resBuf = new byte[_hmac.GetMacSize()];
|
||||
_hmac.BlockUpdate(value, 0, length);
|
||||
_hmac.DoFinal(resBuf, 0);
|
||||
byte[] resBuf = new byte[Hmac.GetMacSize()];
|
||||
Hmac.BlockUpdate(value, offset, length);
|
||||
Hmac.DoFinal(resBuf, offset);
|
||||
|
||||
return resBuf;
|
||||
}
|
||||
|
||||
public void TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||
if ((outputBuffer != null) && ((inputBuffer != outputBuffer) || (inputOffset != outputOffset)))
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||
}
|
||||
|
||||
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||
byte[] outputBytes = new byte[inputCount];
|
||||
if (inputCount != 0)
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
|
||||
return outputBytes;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Hmac.Reset();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_hmac.Reset();
|
||||
Hmac.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,10 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Macs;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class HMACSHA1: HMAC
|
||||
public class HMACSHA1: HashAlgorithm
|
||||
{
|
||||
public HMACSHA1(byte[] key)
|
||||
{
|
||||
_hmac = new HMac(new Sha1Digest());
|
||||
_hmac.Init(new KeyParameter(key));
|
||||
}
|
||||
public HMACSHA1(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1).CreateHash(key.AsBuffer())) {}
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,10 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Macs;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class HMACSHA256: HMAC
|
||||
public class HMACSHA256: HashAlgorithm
|
||||
{
|
||||
public HMACSHA256(byte[] key)
|
||||
{
|
||||
_hmac = new HMac(new Sha256Digest());
|
||||
_hmac.Init(new KeyParameter(key));
|
||||
}
|
||||
|
||||
/*internal void TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
_hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||
}
|
||||
|
||||
internal void TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
_hmac.DoFinal(inputBuffer, inputOffset);
|
||||
}
|
||||
|
||||
internal void Initialize()
|
||||
{
|
||||
_hmac.Reset();
|
||||
}*/
|
||||
public HMACSHA256(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(key.AsBuffer())) {}
|
||||
}
|
||||
}
|
||||
|
100
ModernKeePassLib/Cryptography/Hash/HashAlgorithm.cs
Normal file
100
ModernKeePassLib/Cryptography/Hash/HashAlgorithm.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
using Validation;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public abstract class HashAlgorithm: IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The platform-specific hash object.
|
||||
/// </summary>
|
||||
private readonly CryptographicHash _hash;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HashAlgorithm"/> class.
|
||||
/// </summary>
|
||||
/// <param name="hash">The platform hash.</param>
|
||||
internal HashAlgorithm(CryptographicHash hash)
|
||||
{
|
||||
Requires.NotNull(hash, "Hash");
|
||||
_hash = hash;
|
||||
}
|
||||
|
||||
public bool CanReuseTransform => true;
|
||||
public bool CanTransformMultipleBlocks => true;
|
||||
|
||||
public byte[] Hash => _hash.GetValueAndReset().ToArray();
|
||||
|
||||
public void Append(byte[] data)
|
||||
{
|
||||
_hash.Append(data.AsBuffer());
|
||||
}
|
||||
|
||||
public byte[] GetValueAndReset()
|
||||
{
|
||||
return _hash.GetValueAndReset().ToArray();
|
||||
}
|
||||
|
||||
#region ICryptoTransform methods
|
||||
|
||||
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
byte[] buffer;
|
||||
if (inputCount < inputBuffer.Length)
|
||||
{
|
||||
buffer = new byte[inputCount];
|
||||
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = inputBuffer;
|
||||
}
|
||||
|
||||
Append(buffer);
|
||||
if (outputBuffer != null)
|
||||
{
|
||||
Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||
}
|
||||
|
||||
return inputCount;
|
||||
}
|
||||
|
||||
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
this.TransformBlock(inputBuffer, inputOffset, inputCount, null, 0);
|
||||
if (inputCount == inputBuffer.Length)
|
||||
{
|
||||
return inputBuffer;
|
||||
}
|
||||
var buffer = new byte[inputCount];
|
||||
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(byte[] value)
|
||||
{
|
||||
return ComputeHash(value, 0, value.Length);
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(byte[] value, int offset, int length)
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
|
||||
TransformFinalBlock(value, offset, length);
|
||||
var resBuf = GetValueAndReset();
|
||||
|
||||
return resBuf;
|
||||
}
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -1,12 +1,9 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class SHA256Managed : DigestManaged
|
||||
public class SHA256Managed : HashAlgorithm
|
||||
{
|
||||
public SHA256Managed()
|
||||
{
|
||||
Hash = new Sha256Digest();
|
||||
}
|
||||
public SHA256Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256).CreateHash()) {}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,9 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class SHA512Managed: DigestManaged
|
||||
public class SHA512Managed: HashAlgorithm
|
||||
{
|
||||
public SHA512Managed()
|
||||
{
|
||||
Hash = new Sha512Digest();
|
||||
}
|
||||
public SHA512Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512).CreateHash()) {}
|
||||
}
|
||||
}
|
||||
|
@@ -22,13 +22,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
#if ModernKeePassLib
|
||||
using Windows.Security.Cryptography;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Tls;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
#elif !KeePassUAP
|
||||
using System.Security.Cryptography;
|
||||
#endif
|
||||
@@ -41,11 +36,7 @@ namespace ModernKeePassLib.Cryptography
|
||||
{
|
||||
private readonly Stream m_sBaseStream;
|
||||
private readonly bool m_bWriting;
|
||||
#if ModernKeePassLib
|
||||
private IDigest m_hash;
|
||||
#else
|
||||
private HashAlgorithm m_hash;
|
||||
#endif
|
||||
|
||||
private byte[] m_pbFinalHash = null;
|
||||
|
||||
@@ -80,19 +71,14 @@ namespace ModernKeePassLib.Cryptography
|
||||
set { Debug.Assert(false); throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
#if ModernKeePassLib
|
||||
public HashingStreamEx(Stream sBaseStream, bool bWriting, IDigest hashAlgorithm)
|
||||
#else
|
||||
public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm hashAlgorithm)
|
||||
#endif
|
||||
{
|
||||
if(sBaseStream == null) throw new ArgumentNullException("sBaseStream");
|
||||
|
||||
m_sBaseStream = sBaseStream;
|
||||
m_bWriting = bWriting;
|
||||
#if ModernKeePassLib
|
||||
m_hash = hashAlgorithm ?? new Sha256Digest();
|
||||
#elif !KeePassLibSD
|
||||
|
||||
#if !KeePassLibSD
|
||||
m_hash = (hashAlgorithm ?? new SHA256Managed());
|
||||
#else // KeePassLibSD
|
||||
m_hash = null;
|
||||
@@ -105,14 +91,11 @@ namespace ModernKeePassLib.Cryptography
|
||||
if(m_hash == null) { Debug.Assert(false); return; }
|
||||
|
||||
// Validate hash algorithm
|
||||
#if ModernKeePassLib
|
||||
#else
|
||||
if(!m_hash.CanReuseTransform || !m_hash.CanTransformMultipleBlocks)
|
||||
{
|
||||
Debug.Assert(false);
|
||||
m_hash = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -123,15 +106,9 @@ namespace ModernKeePassLib.Cryptography
|
||||
{
|
||||
try
|
||||
{
|
||||
#if ModernKeePassLib
|
||||
m_pbFinalHash = new byte[32];
|
||||
m_hash.DoFinal(m_pbFinalHash, 0);
|
||||
m_hash.Reset();
|
||||
#else
|
||||
m_hash.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
|
||||
|
||||
m_pbFinalHash = m_hash.Hash;
|
||||
#endif
|
||||
}
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
|
||||
@@ -178,11 +155,7 @@ namespace ModernKeePassLib.Cryptography
|
||||
#endif
|
||||
|
||||
if((m_hash != null) && (nRead > 0))
|
||||
#if ModernKeePassLib
|
||||
m_hash.BlockUpdate(pbBuffer, nOffset, nRead);
|
||||
#else
|
||||
m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset);
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));
|
||||
@@ -201,11 +174,7 @@ namespace ModernKeePassLib.Cryptography
|
||||
#endif
|
||||
|
||||
if((m_hash != null) && (nCount > 0))
|
||||
#if ModernKeePassLib
|
||||
m_hash.BlockUpdate(pbBuffer, nOffset, nCount);
|
||||
#else
|
||||
m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset);
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));
|
||||
|
@@ -134,7 +134,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
||||
public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
||||
ulong uNumRounds)
|
||||
{
|
||||
#if ModernKeePassLib || KeePassUAP
|
||||
|
@@ -34,6 +34,7 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Utility;
|
||||
@@ -465,7 +466,11 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
||||
ti.Pass = r;
|
||||
ti.Lane = (ulong)l;
|
||||
ti.Slice = s;
|
||||
#if !ModernKeePassLib
|
||||
|
||||
#if ModernKeePassLib
|
||||
Task.Factory.StartNew(FillSegmentThr, ti);
|
||||
//ThreadPool.RunAsync(a => FillSegmentThr(ti));
|
||||
#else
|
||||
if(!ThreadPool.QueueUserWorkItem(FillSegmentThr, ti))
|
||||
{
|
||||
Debug.Assert(false);
|
||||
|
@@ -417,7 +417,7 @@ namespace ModernKeePassLib.Cryptography
|
||||
|
||||
private static void TestBlake2b(Random r)
|
||||
{
|
||||
#if !ModernKeePassLib && DEBUG
|
||||
#if DEBUG
|
||||
Blake2b h = new Blake2b();
|
||||
|
||||
// ======================================================
|
||||
@@ -676,35 +676,6 @@ namespace ModernKeePassLib.Cryptography
|
||||
private static void HmacEval(byte[] pbKey, byte[] pbMsg,
|
||||
byte[] pbExpc, string strID)
|
||||
{
|
||||
#if ModernKeePassLib
|
||||
/*
|
||||
// WinRT
|
||||
var h = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(CryptographicBuffer.CreateFromByteArray(pbKey));
|
||||
h.Append(CryptographicBuffer.CreateFromByteArray(pbMsg));
|
||||
var pbHash = h.GetValueAndReset().ToArray();
|
||||
if (!MemUtil.ArraysEqual(pbHash, pbExpc))
|
||||
throw new SecurityException("HMAC-SHA-256-" + strID);
|
||||
|
||||
h.Append(CryptographicBuffer.CreateFromByteArray(pbMsg));
|
||||
pbHash = h.GetValueAndReset().ToArray();
|
||||
if (!MemUtil.ArraysEqual(pbHash, pbExpc))
|
||||
throw new SecurityException("HMAC-SHA-256-" + strID + "-R");
|
||||
|
||||
// BouncyCastle
|
||||
// var h = new HMac(new Sha256Digest());
|
||||
//h.BlockUpdate(pbMsg, 0, pbMsg.Length);
|
||||
//byte[] pbHash = MemUtil.EmptyByteArray;
|
||||
//h.DoFinal(pbHash, 0);
|
||||
//if (!MemUtil.ArraysEqual(pbHash, pbExpc))
|
||||
// throw new SecurityException("HMAC-SHA-256-" + strID);
|
||||
|
||||
// h.Reset();
|
||||
//h.BlockUpdate(pbMsg, 0, pbMsg.Length);
|
||||
//h.DoFinal(pbHash, 0);
|
||||
//if (!MemUtil.ArraysEqual(pbHash, pbExpc))
|
||||
// throw new SecurityException("HMAC-SHA-256-" + strID + "-R");*/
|
||||
#else
|
||||
// Original
|
||||
using(HMACSHA256 h = new HMACSHA256(pbKey))
|
||||
{
|
||||
h.TransformBlock(pbMsg, 0, pbMsg.Length, pbMsg, 0);
|
||||
@@ -723,7 +694,6 @@ namespace ModernKeePassLib.Cryptography
|
||||
if(!MemUtil.ArraysEqual(pbHash, pbExpc))
|
||||
throw new SecurityException("HMAC-SHA-256-" + strID + "-R");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user