Showing preview only (525K chars total). Download the full file or copy to clipboard to get everything.
Repository: HamletDuFromage/switch-cheats-updater
Branch: master
Commit: e6bc70c7b0f6
Files: 55
Total size: 503.2 KB
Directory structure:
gitextract_9wj35k_u/
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── include/
│ ├── download.hpp
│ ├── extract.hpp
│ ├── title.h
│ └── titles.hpp
├── libs/
│ └── minizip/
│ ├── include/
│ │ ├── CDirEntry.h
│ │ ├── crypt.h
│ │ ├── defs.h
│ │ ├── ioapi.h
│ │ ├── ioapi_buf.h
│ │ ├── ioapi_mem.h
│ │ ├── iowin32.h
│ │ ├── tools.h
│ │ ├── unzip.h
│ │ ├── unzipper.h
│ │ ├── zip.h
│ │ └── zipper.h
│ └── source/
│ ├── CDirEntry.cpp
│ ├── aes/
│ │ ├── Makefile
│ │ ├── aes.h
│ │ ├── aes_via_ace.h
│ │ ├── aescrypt.c
│ │ ├── aeskey.c
│ │ ├── aesopt.h
│ │ ├── aestab.c
│ │ ├── aestab.h
│ │ ├── brg_endian.h
│ │ ├── brg_types.h
│ │ ├── entropy.c
│ │ ├── entropy.h
│ │ ├── fileenc.c
│ │ ├── fileenc.h
│ │ ├── hmac.c
│ │ ├── hmac.h
│ │ ├── prng.c
│ │ ├── prng.h
│ │ ├── pwd2key.c
│ │ ├── pwd2key.h
│ │ ├── sha1.c
│ │ └── sha1.h
│ ├── ioapi.c
│ ├── ioapi_buf.c
│ ├── ioapi_mem.c
│ ├── tools.cpp
│ ├── unzip.c
│ ├── unzipper.cpp
│ ├── zip.c
│ └── zipper.cpp
└── source/
├── download.cpp
├── extract.cpp
├── main.cpp
└── titles.cpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
build/
cheatsUploader/
.vscode/
BACKUP/
test/
*.elf
*.nrp
*.nacp
*.nro
*.zip
*.ai
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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:
<program> Copyright (C) <year> <name of author>
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
<https://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
<https://www.gnu.org/licenses/why-not-lgpl.html>.
================================================
FILE: Makefile
================================================
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source libs/minizip/source
DATA := data
INCLUDES := include libs/minizip/include
#ROMFS := romfs
APP_TITLE := Cheats Updater
APP_AUTHOR := HamletDuFromage & Acta
APP_VERSION := 1.2.1
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fexceptions -std=gnu++17 -Wno-reorder
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcurl -lnx -lz -lmbedtls -lmbedx509 -lmbedcrypto -lstdc++fs `freetype-config --libs`
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(CONFIG_JSON)),)
jsons := $(wildcard *.json)
ifneq (,$(findstring $(TARGET).json,$(jsons)))
export APP_JSON := $(TOPDIR)/$(TARGET).json
else
ifneq (,$(findstring config.json,$(jsons)))
export APP_JSON := $(TOPDIR)/config.json
endif
endif
else
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
endif
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
else
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
else
all : $(OUTPUT).nsp
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
$(OUTPUT).nso : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
================================================
FILE: README.md
================================================
# NOT SUPPORTED ANYMORE, USE THIS INSTEAD: https://github.com/HamletDuFromage/AIO-switch-updater
While this app will still work, I recommend using AIO-switch-updater which adds QOL improvements chosing which cheats to not update with a GUI
# switch-cheats-updater
<p align="center">
<img src = "https://user-images.githubusercontent.com/61667930/78696328-916c2a00-78ff-11ea-95e4-f104e8428e64.jpg"\><br>
<img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/HamletDuFromage/switch-cheats-updater/total">
</p>
A Nintendo Switch homebrew app to automatically update your cheat files for your installed games, gamecarts and XCIs. Supports Atmosphere, ReiNX and SXOS.
Fetches the latest cheats from the [gbatemp general thread](https://gbatemp.net/download/cheat-codes-sxos-and-ams-main-cheat-file-updated.36311/updates) through [my mirror](https://github.com/HamletDuFromage/switch-cheats-db/releases) (updates once a day)
## Blacklist titles
By default, this homebrew will overwrite the existing cheats. If you have your own cheat files that you'd like to keep as is, you may add the title IDs of the corresponding games, one ID per line, to `/config/cheats-updater/exclude.txt`. Use http://tinfoil.io/title to find the title ID of a game.
## How to install
Copy the `switch-cheats-updater/` directory to `/switch/` in your sdcard
## Screenshots


## Thanks
- [wilsam239 (Acta)](https://github.com/wilsam239) for his [significant QOL contribtions](https://github.com/HamletDuFromage/switch-cheats-updater/pull/3)
- [ITotalJustice](https://github.com/ITotalJustice) for his download functions
- The AtlasNX discord for helping me various with libnx questions in the past few weeks
================================================
FILE: include/download.hpp
================================================
#ifndef _DOWNLOAD_H_
#define _DOWNLOAD_H_
#define ON 1
#define OFF 0
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <math.h>
#include <curl/curl.h>
#include <string>
#include <regex>
#include <iostream>
#include <switch.h>
bool downloadFile(const char *url, const char *output, int api);
std::string fetchVersion(const char *url, const char *range);
#endif
================================================
FILE: include/extract.hpp
================================================
#ifndef EXTRACT_HPP
#define EXTRACT_HPP
#include <string>
#include <vector>
#include <switch.h>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string.h>
#include <stdio.h>
#include <filesystem>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <unzipper.h>
#include "title.h"
#include "titles.hpp"
#define CONFIG_PATH "/config/cheats-updater/"
#define CONTENTS_PATH "contents/"
#define TITLES_PATH "titles/"
#define AMS_PATH "/atmosphere/"
#define SXOS_PATH "/sxos/"
#define REINX_PATH "/ReiNX/"
enum CFW{
ams,
rnx,
sxos,
};
std::vector<std::string> getInstalledTitles(std::vector<NcmStorageId> storageId);
std::vector<Title> getInstalledTitlesNs();
std::string formatApplicationId(u64 ApplicationId);
std::vector<Title> excludeTitles(const char* path, std::vector<Title> listedTitles);
int extractCheats(std::string zipPath, std::vector<Title> titles, int cfw, bool credits);
int removeCheats(int cfw);
bool caselessCompare (const std::string& a, const std::string& b);
static constexpr u32 MaxTitleCount = 64000;
#endif
================================================
FILE: include/title.h
================================================
#include <iostream>
#ifndef TITLE
#define TITLE
/* Defines the Title structure
id: the title ID
name: the title Name
This overloads operators too, so that sorting and comparison can be done.
*/
struct Title {
std::string id;
std::string name;
bool operator ==(const Title&x) const {
return id == x.id;
}
bool operator <(const Title&x) const {
return id < x.id;
}
};
#endif
================================================
FILE: include/titles.hpp
================================================
#ifndef TITLES_HPP
#define TITLES_HPP
#define UPDATED_TITLES_PATH "/config/cheats-updater/updated.dat"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <switch.h>
#include "title.h"
void outputUpdatedTitles();
void writeTitlesToFile(std::vector<Title> titles);
std::vector<Title> readTitlesFromFile();
void outputUpdatedTitles();
void printTitles(std::vector<Title> titles);
#endif
================================================
FILE: libs/minizip/include/CDirEntry.h
================================================
// Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.
#ifndef ZIPPER_CDirEntry
#define ZIPPER_CDirEntry
#include <string>
#include <vector>
namespace zipper
{
/**
* This class provides an OS independent interface to directory entries
* such as files and directories.
*/
class CDirEntry
{
public:
/**
* The character used to separate directory entries.
*/
static const std::string Separator;
/**
* Check whether the directory entry specified by 'path' is
* a file.
* @param const std::string & path
* @return bool isFile
*/
static bool isFile(const std::string & path);
/**
* Check whether the directory entry specified by 'path' is
* is a directory.
* @param const std::string & path
* @return bool isDir
*/
static bool isDir(const std::string & path);
/**
* Check whether the directory entry specified by 'path' exists.
* @param const std::string & path
* @return bool exist
*/
static bool exist(const std::string & path);
/**
* Check whether the directory entry specified by 'path' is
* is readable.
* @param const std::string & path
* @return bool isReadable
*/
static bool isReadable(const std::string & path);
/**
* Check whether the directory entry specified by 'path' is
* writable.
* @param const std::string & path
* @return bool isWritable
*/
static bool isWritable(const std::string & path);
/**
* Returns the base name, i.e., the directory path and the
* the suffix are removed from 'path'.
* @param const std::string & path
* @return std::string baseName
*/
static std::string baseName(const std::string & path);
/**
* Returns the file name, i.e., the directory path is removed from 'path'.
* @param const std::string & path
* @return std::string fileName
*/
static std::string fileName(const std::string & path);
/**
* Returns the directory path to the parent directoryu, i.e.,
* the file name or directory name are removed from 'path'.
* @param const std::string & path
* @return std::string dirName
*/
static std::string dirName(const std::string & path);
/**
* Returns the suffix, i.e., the directory path and the
* the base name are removed from 'path'.
* @param const std::string & path
* @return std::string basename
*/
static std::string suffix(const std::string & path);
/**
* Create the directory 'dir' in the parent directory 'parent'.
* @param const std::string & dir
* @param const std::string & parent (Default: current working directory)
* @return bool success
*/
static bool createDir(const std::string & dir,
const std::string & parent = "");
/**
* Create a name for a temporary directory entry. The directory entry
* will be located in the directory given
* @param const std::string & dir
* @param const std::string & suffix
* @return std::string tmpName
*/
static std::string createTmpName(const std::string & dir,
const std::string & suffix);
/**
* Move a file from. If to is the directory the filename of from is
* appended.
* @param const std::string & from
* @param const std::string & to
* @return bool success
*/
static bool move(const std::string & from,
const std::string & to);
/**
* Removes a file or directory specified by path.
* @param const std::string & path
* @return bool success
*/
static bool remove(const std::string & path);
/**
* Remove files or directories matching the pattern in directory dir.
* @param const std::string & pattern
* @param const std::string & dir
* @return bool success
*/
static bool removeFiles(const std::string & pattern,
const std::string & dir);
/**
* Compiles the pattern to a patternList. Valid wildcards in the pattern are:
* '*' matches any number of characters and '?' matches exactly one character.
* @param const std::string & pattern
* @return std::vector< std::string > patternList
*/
static std::vector< std::string > compilePattern(const std::string & pattern);
/**
* Compare the name against the pattern list and returns whether the
* name matches. The patternList can be created from a pattern by the
* compilePattern method.
* @param const std::string & name
* @param const std::vector< std::string > & patternList
* @return bool match
*/
static bool match(const std::string & name,
const std::vector< std::string > & patternList);
/**
* Checks whether the given path is relative
* @return bool isRelative
*/
static bool isRelativePath(const std::string & path);
/**
* Makes the absolute path relative to the path given in relativeTo
* @param std::string & absolutePath
* @param const std::string & relativeTo
* @return bool success
*/
static bool makePathRelative(std::string & absolutePath,
const std::string & relativeTo);
/**
* Makes the relative path absolute to the path given in absoluteTo
* @param std::string & relativePath
* @param const std::string & absoluteTo
* @return bool success
*/
static bool makePathAbsolute(std::string & relativePath,
const std::string & absoluteTo);
/**
* This method normalizes the path, i.e.,
* it converts all '\' to '/' (only on WIN32)
* and collapses '^./' to '^', '/./' to '/', and '[^/]+/../' to '/'
* @param const std::string & path
* @return std::string normalizedPath
*/
static std::string normalize(const std::string & path);
private:
/**
* This private methods checks whether the active section matches the
* specified patter. The section is automatically advanced to allow
* repeated calls. On the first call 'at' must be 0. The parameters
* 'at' and 'after' must not be changed outside this method.
* @param const std::string & name
* @param const std::string pattern
* @param std::string::size_type & at
* @param std::string::size_type & after
* @return bool match
*/
static bool matchInternal(const std::string & name,
const std::string pattern,
std::string::size_type & at,
std::string::size_type & after);
};
}
#endif // ZIPPER_CDirEntry
================================================
FILE: libs/minizip/include/crypt.h
================================================
/* crypt.h -- base code for traditional PKWARE encryption
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
Modifications for Info-ZIP crypting
Copyright (C) 2003 Terry Thorsen
This code is a modified version of crypting code in Info-ZIP distribution
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
See the Info-ZIP LICENSE file version 2000-Apr-09 or later for terms of use
which also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
*/
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}
/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
while (*passwd != 0) {
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++;
}
}
#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(const char* passwd, /* password string */
unsigned char* buf, /* where to write header */
int bufSize,
unsigned long* pkeys,
const unsigned long* pcrc_32_tab,
unsigned long crcForCrypting)
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN)
return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n;
}
#endif
================================================
FILE: libs/minizip/include/defs.h
================================================
#pragma once
extern "C"
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#if (defined(_WIN32)) || (defined(_WIN64))
# include <direct.h>
# include <io.h>
#else
# include <unistd.h>
# include <utime.h>
#endif
#include <zip.h>
#include <unzip.h>
#include <ioapi_mem.h>
#define CASESENSITIVITY (0)
#define WRITEBUFFERSIZE (8192)
#define MAXFILENAME (256)
#if (defined(_WIN32)) || (defined(_WIN64))
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
}
#if (defined(_WIN32)) || (defined(_WIN64))
#include <filesystem>
#endif
#if (defined(_WIN32)) || (defined(_WIN64))
#define EXCEPTION_CLASS std::exception
#else
#define EXCEPTION_CLASS std::runtime_error
#endif
#if (defined(_WIN64)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#ifndef __USE_LARGEFILE64
#define __USE_LARGEFILE64
#endif
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#ifndef _FILE_OFFSET_BIT
#define _FILE_OFFSET_BIT 64
#endif
#endif
#if (defined(_WIN32)) || (defined(_WIN64))
# define MKDIR(d) _mkdir(d)
# define CHDIR(d) _chdir(d)
#else
# define MKDIR(d) mkdir(d, 0775)
# define CHDIR(d) chdir(d)
#endif
================================================
FILE: libs/minizip/include/ioapi.h
================================================
/* ioapi.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson
http://result42.com
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _ZLIBIOAPI64_H
#define _ZLIBIOAPI64_H
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
# ifndef __USE_FILE_OFFSET64
# define __USE_FILE_OFFSET64
# endif
# ifndef __USE_LARGEFILE64
# define __USE_LARGEFILE64
# endif
# ifndef _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE
# endif
# ifndef _FILE_OFFSET_BIT
# define _FILE_OFFSET_BIT 64
# endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include "zlib.h"
#define USE_FILE32API
#if defined(USE_FILE32API)
# define fopen64 fopen
# define ftello64 ftell
# define fseeko64 fseek
#else
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
# define fopen64 fopen
# define ftello64 ftello
# define fseeko64 fseeko
# endif
# ifdef _MSC_VER
# define fopen64 fopen
# if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
# define ftello64 _ftelli64
# define fseeko64 _fseeki64
# else /* old MSC */
# define ftello64 ftell
# define fseeko64 fseek
# endif
# endif
#endif
/* a type choosen by DEFINE */
#ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else
# ifdef HAS_STDINT_H
# include "stdint.h"
typedef uint64_t ZPOS64_T;
# else
# if defined(_MSC_VER) || defined(__BORLANDC__)
typedef unsigned __int64 ZPOS64_T;
# else
typedef unsigned long long int ZPOS64_T;
# endif
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)
#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)
#ifndef ZCALLBACK
# if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
# define ZCALLBACK CALLBACK
# else
# define ZCALLBACK
# endif
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef voidpf (ZCALLBACK *opendisk_file_func) OF((voidpf opaque, voidpf stream, int number_disk, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
/* here is the "old" 32 bits structure structure */
typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
opendisk_file_func zopendisk_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
typedef voidpf (ZCALLBACK *opendisk64_file_func)OF((voidpf opaque, voidpf stream, int number_disk, int mode));
typedef struct zlib_filefunc64_def_s
{
open64_file_func zopen64_file;
opendisk64_file_func zopendisk64_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell64_file_func ztell64_file;
seek64_file_func zseek64_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc64_def;
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
/* now internal definition, only for zip.c and unzip.h */
typedef struct zlib_filefunc64_32_def_s
{
zlib_filefunc64_def zfile_func64;
open_file_func zopen32_file;
opendisk_file_func zopendisk32_file;
tell_file_func ztell32_file;
seek_file_func zseek32_file;
} zlib_filefunc64_32_def;
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))*/
/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))*/
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
voidpf call_zopendisk64 OF((const zlib_filefunc64_32_def* pfilefunc, voidpf filestream, int number_disk, int mode));
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
void fill_zlib_filefunc64_32_def_from_filefunc32 OF((zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32));
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
#define ZOPENDISK64(filefunc,filestream,diskn,mode) (call_zopendisk64((&(filefunc)),(filestream),(diskn),(mode)))
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: libs/minizip/include/ioapi_buf.h
================================================
/* ioapi_buf.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This version of ioapi is designed to buffer IO.
Copyright (C) 1998-2003 Gilles Vollant
(C) 2012-2014 Nathan Moinvaziri
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOAPI_BUF_H
#define _IOAPI_BUF_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
#define IOBUF_BUFFERSIZE (64 * 1024)
#ifdef __cplusplus
extern "C" {
#endif
voidpf ZCALLBACK fopen_buf_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopen64_buf_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopendisk_buf_func OF((voidpf opaque, voidpf stream_cd, int number_disk, int mode));
voidpf ZCALLBACK fopendisk64_buf_func OF((voidpf opaque, voidpf stream_cd, int number_disk, int mode));
uLong ZCALLBACK fread_buf_func OF((voidpf opaque,voidpf stream,void* buf,uLong size));
uLong ZCALLBACK fwrite_buf_func OF((voidpf opaque,voidpf stream,const void* buf,uLong size));
long ZCALLBACK ftell_buf_func OF((voidpf opaque,voidpf stream));
ZPOS64_T ZCALLBACK ftell64_buf_func OF((voidpf opaque, voidpf stream));
long ZCALLBACK fseek_buf_func OF((voidpf opaque,voidpf stream,uLong offset,int origin));
long ZCALLBACK fseek64_buf_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
int ZCALLBACK fclose_buf_func OF((voidpf opaque,voidpf stream));
int ZCALLBACK ferror_buf_func OF((voidpf opaque,voidpf stream));
typedef struct ourbuffer_s {
zlib_filefunc_def filefunc;
zlib_filefunc64_def filefunc64;
} ourbuffer_t;
void fill_buffer_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf));
void fill_buffer_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf));
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: libs/minizip/include/ioapi_mem.h
================================================
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This version of ioapi is designed to access memory rather than files.
We do use a region of memory to put data in to and take it out of. We do
not have auto-extending buffers and do not inform anyone else that the
data has been written. It is really intended for accessing a zip archive
embedded in an application such that I can write an installer with no
external files.
Copyright (C) 1998-2003 Gilles Vollant
(C) 2003 Justin Fletcher
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOAPI_MEM_H
#define _IOAPI_MEM_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
#ifdef __cplusplus
extern "C" {
#endif
voidpf ZCALLBACK fopen_mem_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopendisk_mem_func OF((voidpf opaque, voidpf stream, int number_disk, int mode));
uLong ZCALLBACK fread_mem_func OF((voidpf opaque,voidpf stream,void* buf,uLong size));
uLong ZCALLBACK fwrite_mem_func OF((voidpf opaque,voidpf stream,const void* buf,uLong size));
long ZCALLBACK ftell_mem_func OF((voidpf opaque,voidpf stream));
long ZCALLBACK fseek_mem_func OF((voidpf opaque,voidpf stream,uLong offset,int origin));
int ZCALLBACK fclose_mem_func OF((voidpf opaque,voidpf stream));
int ZCALLBACK ferror_mem_func OF((voidpf opaque,voidpf stream));
typedef struct ourmemory_s {
char *base; /* Base of the region of memory we're using */
uLong size; /* Size of the region of memory we're using */
uLong limit; /* Furthest we've written */
uLong cur_offset; /* Current offset in the area */
int grow; /* Growable memory buffer */
} ourmemory_t;
void fill_memory_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem));
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: libs/minizip/include/iowin32.h
================================================
/* iowin32.h -- IO base function header for compress/uncompress .zip
Version 1.1, February 14h, 2010
part of the MiniZip project
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson
http://result42.com
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOWIN32_H
#define _IOWIN32_H
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: libs/minizip/include/tools.h
================================================
#pragma once
#include <string>
#include <vector>
#include <istream>
namespace zipper
{
void getFileCrc(std::istream& input_stream, std::vector<char>& buff, unsigned long& result_crc);
bool isLargeFile(std::istream& input_stream);
bool checkFileExists(const std::string& filename);
bool makedir(const std::string& newdir);
void removeFolder(const std::string& foldername);
std::string parentDirectory(const std::string& filepath);
std::string currentPath();
bool isDirectory(const std::string& path);
std::vector<std::string> filesFromDirectory(const std::string& path);
std::string fileNameFromPath(const std::string& path);
}
================================================
FILE: libs/minizip/include/unzip.h
================================================
/* unzip.h -- IO for uncompress .zip files using zlib
Version 1.1, February 14h, 2010
part of the MiniZip project
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson
http://result42.com
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _UNZ_H
#define _UNZ_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
#endif
#ifdef HAVE_BZIP2
#include "bzlib.h"
#endif
#define Z_BZIP2ED 12
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
#endif
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102)
#define UNZ_BADZIPFILE (-103)
#define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */
typedef struct tm_unz_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info64_s
{
ZPOS64_T number_entry; /* total number of entries in the central dir on this disk */
uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info64;
typedef struct unz_global_info_s
{
uLong number_entry; /* total number of entries in the central dir on this disk */
uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info64_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
ZPOS64_T compressed_size; /* compressed size 8 bytes */
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
ZPOS64_T disk_offset;
uLong size_file_extra_internal;
} unz_file_info64;
typedef struct unz_file_info_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
uLong disk_offset;
} unz_file_info;
/***************************************************************************/
/* Opening and close a zip file */
extern unzFile ZEXPORT unzOpen OF((const char *path));
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
/* Open a Zip file.
path should contain the full pathname (by example, on a Windows XP computer
"c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
return NULL if zipfile cannot be opened or doesn't exist
return unzFile handle if no error
NOTE: The "64" function take a const void* pointer, because the path is just the value passed to the
open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* does not describe the reality */
extern unzFile ZEXPORT unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def));
/* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write operations */
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, zlib_filefunc64_def* pzlib_filefunc_def));
/* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write 64-bit operations */
extern int ZEXPORT unzClose OF((unzFile file));
/* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile,
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no error */
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info));
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, unz_global_info64 *pglobal_info));
/* Write info about the ZipFile in the *pglobal_info structure.
return UNZ_OK if no error */
extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *comment, uLong comment_size));
/* Get the global comment string of the ZipFile, in the comment buffer.
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0 */
/***************************************************************************/
/* Reading the content of the current zipfile, you can open it, read data from it, and close it
(you can close it before reading all the file) */
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/* Open for reading data the current file in the zipfile.
return UNZ_OK if no error */
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, const char* password));
/* Open for reading data the current file in the zipfile.
password is a crypting password
return UNZ_OK if no error */
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, int* method, int* level, int raw));
/* Same as unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1 *method will receive method of compression, *level will receive level of compression
NOTE: you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL */
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, int* method, int* level, int raw, const char* password));
/* Same as unzOpenCurrentFile, but takes extra parameter password for encrypted files */
extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len));
/* Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
/* Get Info about the current file
pfile_info if != NULL, the *pfile_info structure will contain somes info about the current file
filename if != NULL, the file name string will be copied in filename
filename_size is the size of the filename buffer
extrafield if != NULL, the extra field information from the central header will be copied in to
extrafield_size is the size of the extraField buffer
comment if != NULL, the comment string of the file will be copied in to
comment_size is the size of the comment buffer */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len));
/* Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
if buf == NULL, it return the size of the local extra field
if buf != NULL, len is the size of the buffer, the extra header is copied in buf.
return number of bytes copied in buf, or (if <0) the error code */
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/* Close the file in zip opened with unzOpenCurrentFile
return UNZ_CRCERROR if all the file was read but the CRC is not good */
/***************************************************************************/
/* Browse the directory of the zipfile */
typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
typedef int (*unzIteratorFunction)(unzFile file);
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size);
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/* Set the current file of the zipfile to the first file.
return UNZ_OK if no error */
extern int ZEXPORT unzGoToFirstFile2 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
/* Set the current file of the zipfile to the first file and retrieves the current info on success.
Not as seek intensive as unzGoToFirstFile + unzGetCurrentFileInfo.
return UNZ_OK if no error */
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/* Set the current file of the zipfile to the next file.
return UNZ_OK if no error
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
extern int ZEXPORT unzGoToNextFile2 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
/* Set the current file of the zipfile to the next file and retrieves the current
info on success. Does less seeking around than unzGotoNextFile + unzGetCurrentFileInfo.
return UNZ_OK if no error
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
extern int ZEXPORT unzLocateFile OF((unzFile file, const char *filename, unzFileNameComparer filename_compare_func));
/* Try locate the file szFileName in the zipfile. For custom filename comparison pass in comparison function.
return UNZ_OK if the file is found (it becomes the current file)
return UNZ_END_OF_LIST_OF_FILE if the file is not found */
/***************************************************************************/
/* Raw access to zip file */
typedef struct unz_file_pos_s
{
uLong pos_in_zip_directory; /* offset in zip file directory */
uLong num_of_file; /* # of file */
} unz_file_pos;
extern int ZEXPORT unzGetFilePos OF((unzFile file, unz_file_pos* file_pos));
extern int ZEXPORT unzGoToFilePos OF((unzFile file, unz_file_pos* file_pos));
typedef struct unz64_file_pos_s
{
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
ZPOS64_T num_of_file; /* # of file */
} unz64_file_pos;
extern int ZEXPORT unzGetFilePos64 OF((unzFile file, unz64_file_pos* file_pos));
extern int ZEXPORT unzGoToFilePos64 OF((unzFile file, const unz64_file_pos* file_pos));
extern uLong ZEXPORT unzGetOffset OF((unzFile file));
extern ZPOS64_T ZEXPORT unzGetOffset64 OF((unzFile file));
/* Get the current file offset */
extern int ZEXPORT unzSetOffset OF((unzFile file, uLong pos));
extern int ZEXPORT unzSetOffset64 OF((unzFile file, ZPOS64_T pos));
/* Set the current file offset */
extern z_off_t ZEXPORT unztell OF((unzFile file));
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
/* return current position in uncompressed data */
extern int ZEXPORT unzeof OF((unzFile file));
/* return 1 if the end of file was reached, 0 elsewhere */
/***************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* _UNZ_H */
================================================
FILE: libs/minizip/include/unzipper.h
================================================
#pragma once
#include <vector>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
#include <memory>
#include <map>
namespace zipper {
class ZipEntry;
class Unzipper
{
public:
Unzipper(std::istream& buffer);
Unzipper(std::vector<unsigned char>& buffer);
Unzipper(const std::string& zipname);
Unzipper(const std::string& zipname, const std::string& password);
~Unzipper(void);
std::vector<ZipEntry> entries();
bool extract(const std::string& destination, const std::map<std::string, std::string>& alternativeNames);
bool extract(const std::string& destination=std::string());
bool extractEntry(const std::string& name, const std::string& destination = std::string());
bool extractEntryToStream(const std::string& name, std::ostream& stream);
bool extractEntryToMemory(const std::string& name, std::vector<unsigned char>& vec);
void close();
private:
std::string m_password;
std::string m_zipname;
std::istream& m_ibuffer;
std::vector<unsigned char>& m_vecbuffer;
bool m_usingMemoryVector;
bool m_usingStream;
bool m_open;
struct Impl;
Impl* m_impl;
};
class ZipEntry
{
private:
typedef struct
{
unsigned int tm_sec;
unsigned int tm_min;
unsigned int tm_hour;
unsigned int tm_mday;
unsigned int tm_mon;
unsigned int tm_year;
} tm_s;
public:
ZipEntry(const std::string& name, unsigned long long int compressed_size, unsigned long long int uncompressed_size,
int year, int month, int day, int hour, int minute, int second, unsigned long dosdate)
: name(name), compressedSize(compressed_size), uncompressedSize(uncompressed_size), dosdate(dosdate)
{
// timestamp YYYY-MM-DD HH:MM:SS
std::stringstream str;
str << year << "-" << month << "-" << day <<
" " << hour << ":" << minute << ":" << second;
timestamp = str.str();
unixdate.tm_year = year;
unixdate.tm_mon = month;
unixdate.tm_mday = day;
unixdate.tm_hour = hour;
unixdate.tm_min = minute;
unixdate.tm_sec = second;
}
bool valid() { return !name.empty(); }
std::string name, timestamp;
unsigned long long int compressedSize, uncompressedSize;
unsigned long dosdate;
tm_s unixdate;
};
}
================================================
FILE: libs/minizip/include/zip.h
================================================
/* zip.h -- IO on .zip files using zlib
Version 1.1, February 14h, 2010
part of the MiniZip project
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson
http://result42.com
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _ZIP_H
#define _ZIP_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
# include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
# include "ioapi.h"
#endif
#ifdef HAVE_BZIP2
# include "bzlib.h"
#endif
#define Z_BZIP2ED 12
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
#ifndef DEF_MEM_LEVEL
# if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
# else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
# endif
#endif
/* default memLevel */
/* tm_zip contain date/time info */
typedef struct tm_zip_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_zip;
typedef struct
{
tm_zip tmz_date; /* date in understandable format */
uLong dosDate; /* if dos_date == 0, tmu_date is used */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
} zip_fileinfo;
typedef const char* zipcharpc;
#define APPEND_STATUS_CREATE (0)
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
/***************************************************************************/
/* Writing a zip file */
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
/* Create a zipfile.
pathname should contain the full pathname (by example, on a Windows XP computer
"c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
return NULL if zipfile cannot be opened
return zipFile handle if no error
If the file pathname exist and append == APPEND_STATUS_CREATEAFTER, the zip
will be created at the end of the file. (useful if the file contain a self extractor code)
If the file pathname exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing
zip (be sure you don't add file that doesn't exist)
NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile,
you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
the file you did not want delete. */
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, int append, zipcharpc* globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen3 OF((const char *pathname, int append, ZPOS64_T disk_size,
zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc_def));
/* Same as zipOpen2 but allows specification of spanned zip size */
extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append, ZPOS64_T disk_size,
zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level));
/* Open a file in the ZIP for writing.
filename : the filename in zip (if NULL, '-' without quote will be used
*zipfi contain supplemental information
extrafield_local buffer to store the local header extra field data, can be NULL
size_extrafield_local size of extrafield_local buffer
extrafield_global buffer to store the global header extra field data, can be NULL
size_extrafield_global size of extrafield_local buffer
comment buffer for comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
this MUST be '1' if the uncompressed size is >= 0xffffffff. */
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int zip64));
/* Same as zipOpenNewFileInZip with zip64 support */
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw));
/* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw, int zip64));
/* Same as zipOpenNewFileInZip3 with zip64 support */
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
int strategy, const char* password, uLong crcForCrypting));
/* Same as zipOpenNewFileInZip2, except
windowBits, memLevel, strategy : see parameter strategy in deflateInit2
password : crypting password (NULL for no crypting)
crcForCrypting : crc of file to compress (needed for crypting) */
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
int strategy, const char* password, uLong crcForCrypting, int zip64));
/* Same as zipOpenNewFileInZip3 with zip64 support */
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase));
/* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64));
/* Same as zipOpenNewFileInZip4 with zip64 support */
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, const void* buf, unsigned len));
/* Write data in the zipfile */
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/* Close the current file in the zipfile */
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32));
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, ZPOS64_T uncompressed_size, uLong crc32));
/* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size */
extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment));
/* Close the zipfile */
/***************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* _ZIP_H */
================================================
FILE: libs/minizip/include/zipper.h
================================================
#pragma once
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <memory>
namespace zipper {
class Zipper
{
public:
// Minizip options/params:
// -o -a -0 -1 -9 -j
enum zipFlags { Overwrite = 0x01, Append = 0x02, Store = 0x04, Faster = 0x08, Better = 0x10, NoPaths = 0x20 };
Zipper(std::iostream& buffer);
Zipper(std::vector<unsigned char>& buffer);
Zipper(const std::string& zipname);
Zipper(const std::string& zipname, const std::string& password);
~Zipper(void);
bool add(std::istream& source, const std::string& nameInZip = std::string(), zipFlags flags = Better);
bool add(const std::string& fileOrFolderPath, zipFlags flags = Better);
void open();
void close();
private:
std::string m_password;
std::string m_zipname;
std::iostream& m_obuffer;
std::vector<unsigned char>& m_vecbuffer;
bool m_usingMemoryVector;
bool m_usingStream;
bool m_open;
struct Impl;
Impl* m_impl;
};
}
================================================
FILE: libs/minizip/source/CDirEntry.cpp
================================================
// Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
// Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.
#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef WIN32
# include <io.h>
# include <direct.h>
typedef struct _stat STAT;
# define stat _stat
# define S_IFREG _S_IFREG
# define S_IFDIR _S_IFDIR
# define access _access
# define mkdir _mkdir
# define rmdir _rmdir
#else
typedef struct stat STAT;
# include <dirent.h>
# include <unistd.h>
#endif // WIN32
#include "CDirEntry.h"
#include <stdlib.h>
#include <fstream>
using namespace zipper;
#ifdef WIN32
const std::string CDirEntry::Separator = "\\";
#else
const std::string CDirEntry::Separator = "/";
#endif
bool CDirEntry::isFile(const std::string & path)
{
STAT st;
if (stat(path.c_str(), & st) == -1) return false;
#ifdef WIN32
return ((st.st_mode & S_IFREG) == S_IFREG);
#else
return S_ISREG(st.st_mode);
#endif
}
bool CDirEntry::isDir(const std::string & path)
{
STAT st;
if (stat(path.c_str(), & st) == -1) return false;
#ifdef WIN32
return ((st.st_mode & S_IFDIR) == S_IFDIR);
#else
return S_ISDIR(st.st_mode);
#endif
}
bool CDirEntry::exist(const std::string & path)
{
STAT st;
if (stat(path.c_str(), & st) == -1) return false;
#ifdef WIN32
return ((st.st_mode & S_IFREG) == S_IFREG ||
(st.st_mode & S_IFDIR) == S_IFDIR);
#else
return (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode));
#endif
}
bool CDirEntry::isReadable(const std::string & path)
{return (access(path.c_str(), 0x4) == 0);}
bool CDirEntry::isWritable(const std::string & path)
{return (access(path.c_str(), 0x2) == 0);}
std::string CDirEntry::baseName(const std::string & path)
{
std::string::size_type start = path.find_last_of(Separator);
#ifdef WIN32 // WIN32 also understands '/' as the separator.
if (start == std::string::npos)
start = path.find_last_of("/");
#endif
if (start == std::string::npos) start = 0;
else start++; // We do not want the separator.
std::string::size_type end = path.find_last_of(".");
if (end == std::string::npos || end < start)
end = path.length();
return path.substr(start, end - start);
}
std::string CDirEntry::fileName(const std::string & path)
{
std::string::size_type start = path.find_last_of(Separator);
#ifdef WIN32 // WIN32 also understands '/' as the separator.
if (start == std::string::npos)
start = path.find_last_of("/");
#endif
if (start == std::string::npos) start = 0;
else start++; // We do not want the separator.
return path.substr(start);
}
std::string CDirEntry::dirName(const std::string & path)
{
if (path == "") return path;
#ifdef WIN32 // WIN32 also understands '/' as the separator.
std::string::size_type end = path.find_last_of(Separator + "/");
#else
std::string::size_type end = path.find_last_of(Separator);
#endif
if (end == path.length() - 1)
{
#ifdef WIN32 // WIN32 also understands '/' as the separator.
end = path.find_last_of(Separator + "/", end);
#else
end = path.find_last_of(Separator, end);
#endif
}
if (end == std::string::npos) return "";
return path.substr(0, end);
}
std::string CDirEntry::suffix(const std::string & path)
{
std::string::size_type start = path.find_last_of(Separator);
#ifdef WIN32 // WIN32 also understands '/' as the separator.
if (start == std::string::npos)
start = path.find_last_of("/");
#endif
if (start == std::string::npos) start = 0;
else start++; // We do not want the separator.
std::string::size_type end = path.find_last_of(".");
if (end == std::string::npos || end < start)
return "";
else
return path.substr(end);
}
bool CDirEntry::createDir(const std::string & dir,
const std::string & parent)
{
std::string Dir;
if (parent != "") Dir = parent + Separator;
Dir += dir;
// Check whether the directory already exists and is writable.
if (isDir(Dir) && isWritable(Dir)) return true;
// Check whether the parent directory exists and is writable.
if (!parent.empty() && (!isDir(parent) || !isWritable(parent))) return false;
Dir = normalize(Dir);
// ensure we have parent
std::string actualParent = dirName(Dir);
if (!actualParent.empty() && (!exist(actualParent)))
createDir(actualParent);
#ifdef WIN32
return (mkdir(Dir.c_str()) == 0);
#else
return (mkdir(Dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0);
#endif
}
std::string CDirEntry::createTmpName(const std::string & dir,
const std::string & suffix)
{
std::string RandomName;
do
{
RandomName = dir + Separator;
unsigned int Char;
for (size_t i = 0; i < 8; i++)
{
Char = int((rand()/double(RAND_MAX))*35.0);
if (Char < 10)
RandomName += '0' + Char;
else
RandomName += 'a' - 10 + Char;
}
RandomName += suffix;
}
while (exist(RandomName));
return RandomName;
}
bool CDirEntry::move(const std::string & from,
const std::string & to)
{
if (!isFile(from)) return false;
std::string To = to;
// Check whether To is a directory and append the
// filename of from
if (isDir(To))
To += Separator + fileName(from);
if (isDir(To)) return false;
#ifdef WIN32
// The target must not exist under WIN32 for rename to succeed.
if (exist(To) && !remove(To))
return false;
#endif // WIN32
bool success =
(::rename(from.c_str(), To.c_str()) == 0);
if (!success)
{
{
std::ifstream in(from.c_str());
std::ofstream out(To.c_str());
out << in.rdbuf();
success = out.good();
}
remove(from);
}
return success;
}
bool CDirEntry::remove(const std::string & path)
{
if (isDir(path))
return (rmdir(path.c_str()) == 0);
else if (isFile(path))
#ifdef WIN32
return (::remove(path.c_str()) == 0);
#else
return (::remove(path.c_str()) == 0);
#endif
return false;
}
bool CDirEntry::removeFiles(const std::string & pattern,
const std::string & path)
{
bool success = true;
std::vector< std::string > PatternList;
PatternList = compilePattern(pattern);
#ifdef WIN32
// We want the same pattern matching behaviour for all platforms.
// Therefore, we do not use the MS provided one and list all files instead.
std::string FilePattern = path + "\\*";
// Open directory stream and try read info about first entry
struct _finddata_t Entry;
intptr_t hList = _findfirst(FilePattern.c_str(), &Entry);
if (hList == -1) return success;
do
{
std::string Utf8 = Entry.name;
if (match(Utf8, PatternList))
{
if (Entry.attrib | _A_NORMAL)
{
#ifdef WIN32
if (::remove((path + Separator + Utf8).c_str()) != 0) success = false;
#else
if (::remove((path + Separator + Utf8).c_str()) != 0) success = false;
#endif
}
else
{
if (rmdir((path + Separator + Utf8).c_str()) != 0) success = false;
}
}
}
while (_findnext(hList, &Entry) == 0);
_findclose(hList);
#else
DIR * pDir = opendir(path.c_str());
if (!pDir) return false;
struct dirent * pEntry;
while ((pEntry = readdir(pDir)) != NULL)
{
std::string Utf8 = pEntry->d_name;
if (match(Utf8, PatternList))
{
if (isDir(Utf8))
{
if (::rmdir((path + Separator + Utf8).c_str()) != 0)
success = false;
}
else
{
if (::remove((path + Separator + Utf8).c_str()) != 0)
success = false;
}
}
}
closedir(pDir);
#endif // WIN32
return success;
}
std::vector< std::string > CDirEntry::compilePattern(const std::string & pattern)
{
std::string::size_type pos = 0;
std::string::size_type start = 0;
std::string::size_type end = 0;
std::vector< std::string > PatternList;
while (pos != std::string::npos)
{
start = pos;
pos = pattern.find_first_of("*?", pos);
end = std::min(pos, pattern.length());
if (start != end)
PatternList.push_back(pattern.substr(start, end - start));
else
{
PatternList.push_back(pattern.substr(start, 1));
pos++;
}
};
return PatternList;
}
bool CDirEntry::match(const std::string & name,
const std::vector< std::string > & patternList)
{
std::vector< std::string >::const_iterator it = patternList.begin();
std::vector< std::string >::const_iterator end = patternList.end();
std::string::size_type at = 0;
std::string::size_type after = 0;
bool Match = true;
while (it != end && Match)
Match = matchInternal(name, *it++, at, after);
return Match;
}
bool CDirEntry::isRelativePath(const std::string & path)
{
#ifdef WIN32
std::string Path = normalize(path);
if (Path.length() < 2)
return true;
if (Path[1] == ':')
return false;
if (Path[0] == '/' && Path[1] == '/')
return false;
return true;
#else
return (path.length() < 1 || path[0] != '/');
#endif
}
bool CDirEntry::makePathRelative(std::string & absolutePath,
const std::string & relativeTo)
{
if (isRelativePath(absolutePath) ||
isRelativePath(relativeTo)) return false; // Nothing can be done.
std:: string RelativeTo = normalize(relativeTo);
if (isFile(RelativeTo)) RelativeTo = dirName(RelativeTo);
if (!isDir(RelativeTo)) return false;
absolutePath = normalize(absolutePath);
size_t i, imax = std::min(absolutePath.length(), RelativeTo.length());
for (i = 0; i < imax; i++)
if (absolutePath[i] != RelativeTo[i]) break;
// We need to retract to the beginning of the current directory.
if (i != imax)
i = absolutePath.find_last_of('/', i) + 1;
#ifdef WIN32
if (i == 0) return false; // A different drive letter we cannot do anything
#endif
RelativeTo = RelativeTo.substr(i);
std::string relativePath;
while (RelativeTo != "")
{
relativePath += "../";
RelativeTo = dirName(RelativeTo);
}
if (relativePath != "")
absolutePath = relativePath + absolutePath.substr(i);
else
absolutePath = absolutePath.substr(i + 1);
return true;
}
bool CDirEntry::makePathAbsolute(std::string & relativePath,
const std::string & absoluteTo)
{
if (!isRelativePath(relativePath) ||
isRelativePath(absoluteTo)) return false; // Nothing can be done.
std:: string AbsoluteTo = normalize(absoluteTo);
if (isFile(AbsoluteTo)) AbsoluteTo = dirName(AbsoluteTo);
if (!isDir(AbsoluteTo)) return false;
relativePath = normalize(relativePath);
while (!relativePath.compare(0, 3, "../"))
{
AbsoluteTo = dirName(AbsoluteTo);
relativePath = relativePath.substr(3);
}
relativePath = AbsoluteTo + "/" + relativePath;
return true;
}
bool CDirEntry::matchInternal(const std::string & name,
const std::string pattern,
std::string::size_type & at,
std::string::size_type & after)
{
bool Match = true;
switch (pattern[0])
{
case '*':
if (at != std::string::npos)
{
after = at;
at = std::string::npos;
}
break;
case '?':
if (at != std::string::npos)
{
++at;
Match = (name.length() >= at);
}
else
{
++after;
Match = (name.length() >= after);
}
break;
default:
if (at != std::string::npos)
{
Match = (name.compare(at, pattern.length(), pattern) == 0);
at += pattern.length();
}
else
{
at = name.find(pattern, after);
Match = (at != std::string::npos);
at += pattern.length();
}
break;
}
return Match;
}
std::string CDirEntry::normalize(const std::string & path)
{
std::string Normalized = path;
#ifdef WIN32
// converts all '\' to '/' (only on WIN32)
size_t i, imax;
for (i = 0, imax = Normalized.length(); i < imax; i++)
if (Normalized[i] == '\\') Normalized[i] = '/';
#endif
// Remove leading './'
while (!Normalized.compare(0, 2, "./"))
Normalized = Normalized.substr(2);
// Collapse '//' to '/'
std::string::size_type pos = 1;
while (true)
{
pos = Normalized.find("//", pos);
if (pos == std::string::npos) break;
Normalized.erase(pos, 1);
}
// Collapse '/./' to '/'
pos = 0;
while (true)
{
pos = Normalized.find("/./", pos);
if (pos == std::string::npos) break;
Normalized.erase(pos, 2);
}
// Collapse '[^/]+/../' to '/'
std::string::size_type start = Normalized.length();
while (true)
{
pos = Normalized.rfind("/../", start);
if (pos == std::string::npos) break;
start = Normalized.rfind('/', pos - 1);
if (start == std::string::npos) break;
if (!Normalized.compare(start, 4, "/../")) continue;
Normalized.erase(start, pos - start + 3);
start = Normalized.length();
}
return Normalized;
}
================================================
FILE: libs/minizip/source/aes/Makefile
================================================
CC=cc
CFLAGS=-O -DHAVE_AES
OBJS=aescrypt.o aeskey.o aestab.o entropy.o fileenc.o hmac.o prng.o pwd2key.o sha1.o
ARFLAGS=rv
.c.o:
$(CC) -c $(CFLAGS) $*.c
libaes.a: $(OBJS)
$(ECHO) $(AR) $(ARFLAGS) ../libaes.a $?
$(AR) $(ARFLAGS) ../libaes.a $?
$(RANLIB) ../libaes.a
all: libaes.a
.PHONY: clean
clean:
rm *.o *.a
================================================
FILE: libs/minizip/source/aes/aes.h
================================================
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
This file contains the definitions required to use AES in C. See aesopt.h
for optimisation details.
*/
#ifndef _AES_H
#define _AES_H
#include <stdlib.h>
/* This include is used to find 8 & 32 bit unsigned integer types */
#include "brg_types.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#define AES_128 /* if a fast 128 bit key scheduler is needed */
#define AES_192 /* if a fast 192 bit key scheduler is needed */
#define AES_256 /* if a fast 256 bit key scheduler is needed */
#define AES_VAR /* if variable key size scheduler is needed */
#define AES_MODES /* if support is needed for modes */
/* The following must also be set in assembler files if being used */
#define AES_ENCRYPT /* if support for encryption is needed */
#define AES_DECRYPT /* if support for decryption is needed */
#define AES_REV_DKS /* define to reverse decryption key schedule */
#define AES_BLOCK_SIZE 16 /* the AES block size in bytes */
#define N_COLS 4 /* the number of columns in the state */
/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */
/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */
/* or 44, 52 or 60 32-bit words. */
#if defined( AES_VAR ) || defined( AES_256 )
#define KS_LENGTH 60
#elif defined( AES_192 )
#define KS_LENGTH 52
#else
#define KS_LENGTH 44
#endif
#define AES_RETURN INT_RETURN
/* the character array 'inf' in the following structures is used */
/* to hold AES context information. This AES code uses cx->inf.b[0] */
/* to hold the number of rounds multiplied by 16. The other three */
/* elements can be used by code that implements additional modes */
typedef union
{ uint_32t l;
uint_8t b[4];
} aes_inf;
typedef struct
{ uint_32t ks[KS_LENGTH];
aes_inf inf;
} aes_encrypt_ctx;
typedef struct
{ uint_32t ks[KS_LENGTH];
aes_inf inf;
} aes_decrypt_ctx;
/* This routine must be called before first use if non-static */
/* tables are being used */
AES_RETURN aes_init(void);
/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */
/* those in the range 128 <= key_len <= 256 are given in bits */
#if defined( AES_ENCRYPT )
#if defined( AES_128 ) || defined( AES_VAR)
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined( AES_192 ) || defined( AES_VAR)
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined( AES_256 ) || defined( AES_VAR)
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined( AES_VAR )
AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]);
#endif
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
#endif
#if defined( AES_DECRYPT )
#if defined( AES_128 ) || defined( AES_VAR)
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined( AES_192 ) || defined( AES_VAR)
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined( AES_256 ) || defined( AES_VAR)
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined( AES_VAR )
AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]);
#endif
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
#endif
#if defined( AES_MODES )
/* Multiple calls to the following subroutines for multiple block */
/* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */
/* long messages incremantally provided that the context AND the iv */
/* are preserved between all such calls. For the ECB and CBC modes */
/* each individual call within a series of incremental calls must */
/* process only full blocks (i.e. len must be a multiple of 16) but */
/* the CFB, OFB and CTR mode calls can handle multiple incremental */
/* calls of any length. Each mode is reset when a new AES key is */
/* set but ECB and CBC operations can be reset without setting a */
/* new key by setting a new IV value. To reset CFB, OFB and CTR */
/* without setting the key, aes_mode_reset() must be called and the */
/* IV must be set. NOTE: All these calls update the IV on exit so */
/* this has to be reset if a new operation with the same IV as the */
/* previous one is required (or decryption follows encryption with */
/* the same IV array). */
AES_RETURN aes_test_alignment_detection(unsigned int n);
AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, const aes_encrypt_ctx cx[1]);
AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, const aes_decrypt_ctx cx[1]);
AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, const aes_encrypt_ctx cx[1]);
AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, const aes_decrypt_ctx cx[1]);
AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]);
AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
#define aes_ofb_encrypt aes_ofb_crypt
#define aes_ofb_decrypt aes_ofb_crypt
AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
typedef void cbuf_inc(unsigned char *cbuf);
#define aes_ctr_encrypt aes_ctr_crypt
#define aes_ctr_decrypt aes_ctr_crypt
AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]);
#endif
#if defined(__cplusplus)
}
#endif
#endif
================================================
FILE: libs/minizip/source/aes/aes_via_ace.h
================================================
/*
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
*/
#ifndef AES_VIA_ACE_H
#define AES_VIA_ACE_H
#if defined( _MSC_VER )
# define INLINE __inline
#elif defined( __GNUC__ )
# define INLINE static inline
#else
# error VIA ACE requires Microsoft or GNU C
#endif
#define NEH_GENERATE 1
#define NEH_LOAD 2
#define NEH_HYBRID 3
#define MAX_READ_ATTEMPTS 1000
/* VIA Nehemiah RNG and ACE Feature Mask Values */
#define NEH_CPU_IS_VIA 0x00000001
#define NEH_CPU_READ 0x00000010
#define NEH_CPU_MASK 0x00000011
#define NEH_RNG_PRESENT 0x00000004
#define NEH_RNG_ENABLED 0x00000008
#define NEH_ACE_PRESENT 0x00000040
#define NEH_ACE_ENABLED 0x00000080
#define NEH_RNG_FLAGS (NEH_RNG_PRESENT | NEH_RNG_ENABLED)
#define NEH_ACE_FLAGS (NEH_ACE_PRESENT | NEH_ACE_ENABLED)
#define NEH_FLAGS_MASK (NEH_RNG_FLAGS | NEH_ACE_FLAGS)
/* VIA Nehemiah Advanced Cryptography Engine (ACE) Control Word Values */
#define NEH_GEN_KEY 0x00000000 /* generate key schedule */
#define NEH_LOAD_KEY 0x00000080 /* load schedule from memory */
#define NEH_ENCRYPT 0x00000000 /* encryption */
#define NEH_DECRYPT 0x00000200 /* decryption */
#define NEH_KEY128 0x00000000+0x0a /* 128 bit key */
#define NEH_KEY192 0x00000400+0x0c /* 192 bit key */
#define NEH_KEY256 0x00000800+0x0e /* 256 bit key */
#define NEH_ENC_GEN (NEH_ENCRYPT | NEH_GEN_KEY)
#define NEH_DEC_GEN (NEH_DECRYPT | NEH_GEN_KEY)
#define NEH_ENC_LOAD (NEH_ENCRYPT | NEH_LOAD_KEY)
#define NEH_DEC_LOAD (NEH_DECRYPT | NEH_LOAD_KEY)
#define NEH_ENC_GEN_DATA {\
NEH_ENC_GEN | NEH_KEY128, 0, 0, 0,\
NEH_ENC_GEN | NEH_KEY192, 0, 0, 0,\
NEH_ENC_GEN | NEH_KEY256, 0, 0, 0 }
#define NEH_ENC_LOAD_DATA {\
NEH_ENC_LOAD | NEH_KEY128, 0, 0, 0,\
NEH_ENC_LOAD | NEH_KEY192, 0, 0, 0,\
NEH_ENC_LOAD | NEH_KEY256, 0, 0, 0 }
#define NEH_ENC_HYBRID_DATA {\
NEH_ENC_GEN | NEH_KEY128, 0, 0, 0,\
NEH_ENC_LOAD | NEH_KEY192, 0, 0, 0,\
NEH_ENC_LOAD | NEH_KEY256, 0, 0, 0 }
#define NEH_DEC_GEN_DATA {\
NEH_DEC_GEN | NEH_KEY128, 0, 0, 0,\
NEH_DEC_GEN | NEH_KEY192, 0, 0, 0,\
NEH_DEC_GEN | NEH_KEY256, 0, 0, 0 }
#define NEH_DEC_LOAD_DATA {\
NEH_DEC_LOAD | NEH_KEY128, 0, 0, 0,\
NEH_DEC_LOAD | NEH_KEY192, 0, 0, 0,\
NEH_DEC_LOAD | NEH_KEY256, 0, 0, 0 }
#define NEH_DEC_HYBRID_DATA {\
NEH_DEC_GEN | NEH_KEY128, 0, 0, 0,\
NEH_DEC_LOAD | NEH_KEY192, 0, 0, 0,\
NEH_DEC_LOAD | NEH_KEY256, 0, 0, 0 }
#define neh_enc_gen_key(x) ((x) == 128 ? (NEH_ENC_GEN | NEH_KEY128) : \
(x) == 192 ? (NEH_ENC_GEN | NEH_KEY192) : (NEH_ENC_GEN | NEH_KEY256))
#define neh_enc_load_key(x) ((x) == 128 ? (NEH_ENC_LOAD | NEH_KEY128) : \
(x) == 192 ? (NEH_ENC_LOAD | NEH_KEY192) : (NEH_ENC_LOAD | NEH_KEY256))
#define neh_enc_hybrid_key(x) ((x) == 128 ? (NEH_ENC_GEN | NEH_KEY128) : \
(x) == 192 ? (NEH_ENC_LOAD | NEH_KEY192) : (NEH_ENC_LOAD | NEH_KEY256))
#define neh_dec_gen_key(x) ((x) == 128 ? (NEH_DEC_GEN | NEH_KEY128) : \
(x) == 192 ? (NEH_DEC_GEN | NEH_KEY192) : (NEH_DEC_GEN | NEH_KEY256))
#define neh_dec_load_key(x) ((x) == 128 ? (NEH_DEC_LOAD | NEH_KEY128) : \
(x) == 192 ? (NEH_DEC_LOAD | NEH_KEY192) : (NEH_DEC_LOAD | NEH_KEY256))
#define neh_dec_hybrid_key(x) ((x) == 128 ? (NEH_DEC_GEN | NEH_KEY128) : \
(x) == 192 ? (NEH_DEC_LOAD | NEH_KEY192) : (NEH_DEC_LOAD | NEH_KEY256))
#if defined( _MSC_VER ) && ( _MSC_VER > 1200 )
#define aligned_auto(type, name, no, stride) __declspec(align(stride)) type name[no]
#else
#define aligned_auto(type, name, no, stride) \
unsigned char _##name[no * sizeof(type) + stride]; \
type *name = (type*)(16 * ((((unsigned long)(_##name)) + stride - 1) / stride))
#endif
#if defined( _MSC_VER ) && ( _MSC_VER > 1200 )
#define aligned_array(type, name, no, stride) __declspec(align(stride)) type name[no]
#elif defined( __GNUC__ )
#define aligned_array(type, name, no, stride) type name[no] __attribute__ ((aligned(stride)))
#else
#define aligned_array(type, name, no, stride) type name[no]
#endif
/* VIA ACE codeword */
static unsigned char via_flags = 0;
#if defined ( _MSC_VER ) && ( _MSC_VER > 800 )
#define NEH_REKEY __asm pushfd __asm popfd
#define NEH_AES __asm _emit 0xf3 __asm _emit 0x0f __asm _emit 0xa7
#define NEH_ECB NEH_AES __asm _emit 0xc8
#define NEH_CBC NEH_AES __asm _emit 0xd0
#define NEH_CFB NEH_AES __asm _emit 0xe0
#define NEH_OFB NEH_AES __asm _emit 0xe8
#define NEH_RNG __asm _emit 0x0f __asm _emit 0xa7 __asm _emit 0xc0
INLINE int has_cpuid(void)
{ char ret_value;
__asm
{ pushfd /* save EFLAGS register */
mov eax,[esp] /* copy it to eax */
mov edx,0x00200000 /* CPUID bit position */
xor eax,edx /* toggle the CPUID bit */
push eax /* attempt to set EFLAGS to */
popfd /* the new value */
pushfd /* get the new EFLAGS value */
pop eax /* into eax */
xor eax,[esp] /* xor with original value */
and eax,edx /* has CPUID bit changed? */
setne al /* set to 1 if we have been */
mov ret_value,al /* able to change it */
popfd /* restore original EFLAGS */
}
return (int)ret_value;
}
INLINE int is_via_cpu(void)
{ char ret_value;
__asm
{ push ebx
xor eax,eax /* use CPUID to get vendor */
cpuid /* identity string */
xor eax,eax /* is it "CentaurHauls" ? */
sub ebx,0x746e6543 /* 'Cent' */
or eax,ebx
sub edx,0x48727561 /* 'aurH' */
or eax,edx
sub ecx,0x736c7561 /* 'auls' */
or eax,ecx
sete al /* set to 1 if it is VIA ID */
mov dl,NEH_CPU_READ /* mark CPU type as read */
or dl,al /* & store result in flags */
mov [via_flags],dl /* set VIA detected flag */
mov ret_value,al /* able to change it */
pop ebx
}
return (int)ret_value;
}
INLINE int read_via_flags(void)
{ char ret_value = 0;
__asm
{ mov eax,0xC0000000 /* Centaur extended CPUID */
cpuid
mov edx,0xc0000001 /* >= 0xc0000001 if support */
cmp eax,edx /* for VIA extended feature */
jnae no_rng /* flags is available */
mov eax,edx /* read Centaur extended */
cpuid /* feature flags */
mov eax,NEH_FLAGS_MASK /* mask out and save */
and eax,edx /* the RNG and ACE flags */
or [via_flags],al /* present & enabled flags */
mov ret_value,al /* able to change it */
no_rng:
}
return (int)ret_value;
}
INLINE unsigned int via_rng_in(void *buf)
{ char ret_value = 0x1f;
__asm
{ push edi
mov edi,buf /* input buffer address */
xor edx,edx /* try to fetch 8 bytes */
NEH_RNG /* do RNG read operation */
and ret_value,al /* count of bytes returned */
pop edi
}
return (int)ret_value;
}
INLINE void via_ecb_op5(
const void *k, const void *c, const void *s, void *d, int l)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
NEH_ECB
pop ebx
}
}
INLINE void via_cbc_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
mov eax, (v)
NEH_CBC
pop ebx
}
}
INLINE void via_cbc_op7(
const void *k, const void *c, const void *s, void *d, int l, void *v, void *w)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
mov eax, (v)
NEH_CBC
mov esi, eax
mov edi, (w)
movsd
movsd
movsd
movsd
pop ebx
}
}
INLINE void via_cfb_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
mov eax, (v)
NEH_CFB
pop ebx
}
}
INLINE void via_cfb_op7(
const void *k, const void *c, const void *s, void *d, int l, void *v, void *w)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
mov eax, (v)
NEH_CFB
mov esi, eax
mov edi, (w)
movsd
movsd
movsd
movsd
pop ebx
}
}
INLINE void via_ofb_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{ __asm
{ push ebx
NEH_REKEY
mov ebx, (k)
mov edx, (c)
mov esi, (s)
mov edi, (d)
mov ecx, (l)
mov eax, (v)
NEH_OFB
pop ebx
}
}
#elif defined( __GNUC__ )
#define NEH_REKEY asm("pushfl\n popfl\n\t")
#define NEH_ECB asm(".byte 0xf3, 0x0f, 0xa7, 0xc8\n\t")
#define NEH_CBC asm(".byte 0xf3, 0x0f, 0xa7, 0xd0\n\t")
#define NEH_CFB asm(".byte 0xf3, 0x0f, 0xa7, 0xe0\n\t")
#define NEH_OFB asm(".byte 0xf3, 0x0f, 0xa7, 0xe8\n\t")
#define NEH_RNG asm(".byte 0x0f, 0xa7, 0xc0\n\t");
INLINE int has_cpuid(void)
{ int val;
asm("pushfl\n\t");
asm("movl 0(%esp),%eax\n\t");
asm("xor $0x00200000,%eax\n\t");
asm("pushl %eax\n\t");
asm("popfl\n\t");
asm("pushfl\n\t");
asm("popl %eax\n\t");
asm("xorl 0(%esp),%edx\n\t");
asm("andl $0x00200000,%eax\n\t");
asm("movl %%eax,%0\n\t" : "=m" (val));
asm("popfl\n\t");
return val ? 1 : 0;
}
INLINE int is_via_cpu(void)
{ int val;
asm("pushl %ebx\n\t");
asm("xorl %eax,%eax\n\t");
asm("cpuid\n\t");
asm("xorl %eax,%eax\n\t");
asm("subl $0x746e6543,%ebx\n\t");
asm("orl %ebx,%eax\n\t");
asm("subl $0x48727561,%edx\n\t");
asm("orl %edx,%eax\n\t");
asm("subl $0x736c7561,%ecx\n\t");
asm("orl %ecx,%eax\n\t");
asm("movl %%eax,%0\n\t" : "=m" (val));
asm("popl %ebx\n\t");
val = (val ? 0 : 1);
via_flags = (val | NEH_CPU_READ);
return val;
}
INLINE int read_via_flags(void)
{ unsigned char val;
asm("movl $0xc0000000,%eax\n\t");
asm("cpuid\n\t");
asm("movl $0xc0000001,%edx\n\t");
asm("cmpl %edx,%eax\n\t");
asm("setae %al\n\t");
asm("movb %%al,%0\n\t" : "=m" (val));
if(!val) return 0;
asm("movl $0xc0000001,%eax\n\t");
asm("cpuid\n\t");
asm("movb %%dl,%0\n\t" : "=m" (val));
val &= NEH_FLAGS_MASK;
via_flags |= val;
return (int) val;
}
INLINE int via_rng_in(void *buf)
{ int val;
asm("pushl %edi\n\t");
asm("movl %0,%%edi\n\t" : : "m" (buf));
asm("xorl %edx,%edx\n\t");
NEH_RNG
asm("andl $0x0000001f,%eax\n\t");
asm("movl %%eax,%0\n\t" : "=m" (val));
asm("popl %edi\n\t");
return val;
}
INLINE volatile void via_ecb_op5(
const void *k, const void *c, const void *s, void *d, int l)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
NEH_ECB;
asm("popl %ebx\n\t");
}
INLINE volatile void via_cbc_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
asm("movl %0, %%eax\n\t" : : "m" (v));
NEH_CBC;
asm("popl %ebx\n\t");
}
INLINE volatile void via_cbc_op7(
const void *k, const void *c, const void *s, void *d, int l, void *v, void *w)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
asm("movl %0, %%eax\n\t" : : "m" (v));
NEH_CBC;
asm("movl %eax,%esi\n\t");
asm("movl %0, %%edi\n\t" : : "m" (w));
asm("movsl; movsl; movsl; movsl\n\t");
asm("popl %ebx\n\t");
}
INLINE volatile void via_cfb_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
asm("movl %0, %%eax\n\t" : : "m" (v));
NEH_CFB;
asm("popl %ebx\n\t");
}
INLINE volatile void via_cfb_op7(
const void *k, const void *c, const void *s, void *d, int l, void *v, void *w)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
asm("movl %0, %%eax\n\t" : : "m" (v));
NEH_CFB;
asm("movl %eax,%esi\n\t");
asm("movl %0, %%edi\n\t" : : "m" (w));
asm("movsl; movsl; movsl; movsl\n\t");
asm("popl %ebx\n\t");
}
INLINE volatile void via_ofb_op6(
const void *k, const void *c, const void *s, void *d, int l, void *v)
{
asm("pushl %ebx\n\t");
NEH_REKEY;
asm("movl %0, %%ebx\n\t" : : "m" (k));
asm("movl %0, %%edx\n\t" : : "m" (c));
asm("movl %0, %%esi\n\t" : : "m" (s));
asm("movl %0, %%edi\n\t" : : "m" (d));
asm("movl %0, %%ecx\n\t" : : "m" (l));
asm("movl %0, %%eax\n\t" : : "m" (v));
NEH_OFB;
asm("popl %ebx\n\t");
}
#else
#error VIA ACE is not available with this compiler
#endif
INLINE int via_ace_test(void)
{
return has_cpuid() && is_via_cpu() && ((read_via_flags() & NEH_ACE_FLAGS) == NEH_ACE_FLAGS);
}
#define VIA_ACE_AVAILABLE (((via_flags & NEH_ACE_FLAGS) == NEH_ACE_FLAGS) \
|| (via_flags & NEH_CPU_READ) && (via_flags & NEH_CPU_IS_VIA) || via_ace_test())
INLINE int via_rng_test(void)
{
return has_cpuid() && is_via_cpu() && ((read_via_flags() & NEH_RNG_FLAGS) == NEH_RNG_FLAGS);
}
#define VIA_RNG_AVAILABLE (((via_flags & NEH_RNG_FLAGS) == NEH_RNG_FLAGS) \
|| (via_flags & NEH_CPU_READ) && (via_flags & NEH_CPU_IS_VIA) || via_rng_test())
INLINE int read_via_rng(void *buf, int count)
{ int nbr, max_reads, lcnt = count;
unsigned char *p, *q;
aligned_auto(unsigned char, bp, 64, 16);
if(!VIA_RNG_AVAILABLE)
return 0;
do
{
max_reads = MAX_READ_ATTEMPTS;
do
nbr = via_rng_in(bp);
while
(nbr == 0 && --max_reads);
lcnt -= nbr;
p = (unsigned char*)buf; q = bp;
while(nbr--)
*p++ = *q++;
}
while
(lcnt && max_reads);
return count - lcnt;
}
#endif
================================================
FILE: libs/minizip/source/aes/aescrypt.c
================================================
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
*/
#include "aesopt.h"
#include "aestab.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c])
#define so(y,x,c) word_out(y, c, s(x,c))
#if defined(ARRAYS)
#define locals(y,x) x[4],y[4]
#else
#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
#endif
#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
s(y,2) = s(x,2); s(y,3) = s(x,3);
#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3)
#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)
#if ( FUNCS_IN_C & ENCRYPTION_IN_C )
/* Visual C++ .Net v7.1 provides the fastest encryption code when using
Pentium optimiation with small code but this is poor for decryption
so we need to control this with the following VC++ pragmas
*/
#if defined( _MSC_VER ) && !defined( _WIN64 )
#pragma optimize( "s", on )
#endif
/* Given the column (c) of the output state variable, the following
macros give the input state variables which are needed in its
computation for each row (r) of the state. All the alternative
macros give the same end values but expand into different ways
of calculating these values. In particular the complex macro
used for dynamically variable block sizes is designed to expand
to a compile time constant whenever possible but will expand to
conditional clauses on some branches (I am grateful to Frank
Yellin for this construction)
*/
#define fwd_var(x,r,c)\
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
: r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
: ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2)))
#if defined(FT4_SET)
#undef dec_fmvars
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c))
#elif defined(FT1_SET)
#undef dec_fmvars
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c))
#else
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c)))
#endif
#if defined(FL4_SET)
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c))
#elif defined(FL1_SET)
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c))
#else
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c))
#endif
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1])
{ uint_32t locals(b0, b1);
const uint_32t *kp;
#if defined( dec_fmvars )
dec_fmvars; /* declare variables for fwd_mcol() if needed */
#endif
if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 )
return EXIT_FAILURE;
kp = cx->ks;
state_in(b0, in, kp);
#if (ENC_UNROLL == FULL)
switch(cx->inf.b[0])
{
case 14 * 16:
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
kp += 2 * N_COLS;
case 12 * 16:
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
kp += 2 * N_COLS;
case 10 * 16:
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
round(fwd_rnd, b1, b0, kp + 3 * N_COLS);
round(fwd_rnd, b0, b1, kp + 4 * N_COLS);
round(fwd_rnd, b1, b0, kp + 5 * N_COLS);
round(fwd_rnd, b0, b1, kp + 6 * N_COLS);
round(fwd_rnd, b1, b0, kp + 7 * N_COLS);
round(fwd_rnd, b0, b1, kp + 8 * N_COLS);
round(fwd_rnd, b1, b0, kp + 9 * N_COLS);
round(fwd_lrnd, b0, b1, kp +10 * N_COLS);
}
#else
#if (ENC_UNROLL == PARTIAL)
{ uint_32t rnd;
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
{
kp += N_COLS;
round(fwd_rnd, b1, b0, kp);
kp += N_COLS;
round(fwd_rnd, b0, b1, kp);
}
kp += N_COLS;
round(fwd_rnd, b1, b0, kp);
#else
{ uint_32t rnd;
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
{
kp += N_COLS;
round(fwd_rnd, b1, b0, kp);
l_copy(b0, b1);
}
#endif
kp += N_COLS;
round(fwd_lrnd, b0, b1, kp);
}
#endif
state_out(out, b0);
return EXIT_SUCCESS;
}
#endif
#if ( FUNCS_IN_C & DECRYPTION_IN_C)
/* Visual C++ .Net v7.1 provides the fastest encryption code when using
Pentium optimiation with small code but this is poor for decryption
so we need to control this with the following VC++ pragmas
*/
#if defined( _MSC_VER ) && !defined( _WIN64 )
#pragma optimize( "t", on )
#endif
/* Given the column (c) of the output state variable, the following
macros give the input state variables which are needed in its
computation for each row (r) of the state. All the alternative
macros give the same end values but expand into different ways
of calculating these values. In particular the complex macro
used for dynamically variable block sizes is designed to expand
to a compile time constant whenever possible but will expand to
conditional clauses on some branches (I am grateful to Frank
Yellin for this construction)
*/
#define inv_var(x,r,c)\
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
: r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
: ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0)))
#if defined(IT4_SET)
#undef dec_imvars
#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c))
#elif defined(IT1_SET)
#undef dec_imvars
#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c))
#else
#define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)))
#endif
#if defined(IL4_SET)
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c))
#elif defined(IL1_SET)
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c))
#else
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))
#endif
/* This code can work with the decryption key schedule in the */
/* order that is used for encrytpion (where the 1st decryption */
/* round key is at the high end ot the schedule) or with a key */
/* schedule that has been reversed to put the 1st decryption */
/* round key at the low end of the schedule in memory (when */
/* AES_REV_DKS is defined) */
#ifdef AES_REV_DKS
#define key_ofs 0
#define rnd_key(n) (kp + n * N_COLS)
#else
#define key_ofs 1
#define rnd_key(n) (kp - n * N_COLS)
#endif
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1])
{ uint_32t locals(b0, b1);
#if defined( dec_imvars )
dec_imvars; /* declare variables for inv_mcol() if needed */
#endif
const uint_32t *kp;
if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 )
return EXIT_FAILURE;
kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0);
state_in(b0, in, kp);
#if (DEC_UNROLL == FULL)
kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2));
switch(cx->inf.b[0])
{
case 14 * 16:
round(inv_rnd, b1, b0, rnd_key(-13));
round(inv_rnd, b0, b1, rnd_key(-12));
case 12 * 16:
round(inv_rnd, b1, b0, rnd_key(-11));
round(inv_rnd, b0, b1, rnd_key(-10));
case 10 * 16:
round(inv_rnd, b1, b0, rnd_key(-9));
round(inv_rnd, b0, b1, rnd_key(-8));
round(inv_rnd, b1, b0, rnd_key(-7));
round(inv_rnd, b0, b1, rnd_key(-6));
round(inv_rnd, b1, b0, rnd_key(-5));
round(inv_rnd, b0, b1, rnd_key(-4));
round(inv_rnd, b1, b0, rnd_key(-3));
round(inv_rnd, b0, b1, rnd_key(-2));
round(inv_rnd, b1, b0, rnd_key(-1));
round(inv_lrnd, b0, b1, rnd_key( 0));
}
#else
#if (DEC_UNROLL == PARTIAL)
{ uint_32t rnd;
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
{
kp = rnd_key(1);
round(inv_rnd, b1, b0, kp);
kp = rnd_key(1);
round(inv_rnd, b0, b1, kp);
}
kp = rnd_key(1);
round(inv_rnd, b1, b0, kp);
#else
{ uint_32t rnd;
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
{
kp = rnd_key(1);
round(inv_rnd, b1, b0, kp);
l_copy(b0, b1);
}
#endif
kp = rnd_key(1);
round(inv_lrnd, b0, b1, kp);
}
#endif
state_out(out, b0);
return EXIT_SUCCESS;
}
#endif
#if defined(__cplusplus)
}
#endif
================================================
FILE: libs/minizip/source/aes/aeskey.c
================================================
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
*/
#include "aesopt.h"
#include "aestab.h"
#ifdef USE_VIA_ACE_IF_PRESENT
# include "aes_via_ace.h"
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
/* Initialise the key schedule from the user supplied key. The key
length can be specified in bytes, with legal values of 16, 24
and 32, or in bits, with legal values of 128, 192 and 256. These
values correspond with Nk values of 4, 6 and 8 respectively.
The following macros implement a single cycle in the key
schedule generation process. The number of cycles needed
for each cx->n_col and nk value is:
nk = 4 5 6 7 8
------------------------------
cx->n_col = 4 10 9 8 7 7
cx->n_col = 5 14 11 10 9 9
cx->n_col = 6 19 15 12 11 11
cx->n_col = 7 21 19 16 13 14
cx->n_col = 8 29 23 19 17 14
*/
#if defined( REDUCE_CODE_SIZE )
# define ls_box ls_sub
uint_32t ls_sub(const uint_32t t, const uint_32t n);
# define inv_mcol im_sub
uint_32t im_sub(const uint_32t x);
# ifdef ENC_KS_UNROLL
# undef ENC_KS_UNROLL
# endif
# ifdef DEC_KS_UNROLL
# undef DEC_KS_UNROLL
# endif
#endif
#if (FUNCS_IN_C & ENC_KEYING_IN_C)
#if defined(AES_128) || defined( AES_VAR )
#define ke4(k,i) \
{ k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
k[4*(i)+5] = ss[1] ^= ss[0]; \
k[4*(i)+6] = ss[2] ^= ss[1]; \
k[4*(i)+7] = ss[3] ^= ss[2]; \
}
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint_32t ss[4];
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
cx->ks[2] = ss[2] = word_in(key, 2);
cx->ks[3] = ss[3] = word_in(key, 3);
#ifdef ENC_KS_UNROLL
ke4(cx->ks, 0); ke4(cx->ks, 1);
ke4(cx->ks, 2); ke4(cx->ks, 3);
ke4(cx->ks, 4); ke4(cx->ks, 5);
ke4(cx->ks, 6); ke4(cx->ks, 7);
ke4(cx->ks, 8);
#else
{ uint_32t i;
for(i = 0; i < 9; ++i)
ke4(cx->ks, i);
}
#endif
ke4(cx->ks, 9);
cx->inf.l = 0;
cx->inf.b[0] = 10 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined(AES_192) || defined( AES_VAR )
#define kef6(k,i) \
{ k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
k[6*(i)+ 7] = ss[1] ^= ss[0]; \
k[6*(i)+ 8] = ss[2] ^= ss[1]; \
k[6*(i)+ 9] = ss[3] ^= ss[2]; \
}
#define ke6(k,i) \
{ kef6(k,i); \
k[6*(i)+10] = ss[4] ^= ss[3]; \
k[6*(i)+11] = ss[5] ^= ss[4]; \
}
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint_32t ss[6];
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
cx->ks[2] = ss[2] = word_in(key, 2);
cx->ks[3] = ss[3] = word_in(key, 3);
cx->ks[4] = ss[4] = word_in(key, 4);
cx->ks[5] = ss[5] = word_in(key, 5);
#ifdef ENC_KS_UNROLL
ke6(cx->ks, 0); ke6(cx->ks, 1);
ke6(cx->ks, 2); ke6(cx->ks, 3);
ke6(cx->ks, 4); ke6(cx->ks, 5);
ke6(cx->ks, 6);
#else
{ uint_32t i;
for(i = 0; i < 7; ++i)
ke6(cx->ks, i);
}
#endif
kef6(cx->ks, 7);
cx->inf.l = 0;
cx->inf.b[0] = 12 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined(AES_256) || defined( AES_VAR )
#define kef8(k,i) \
{ k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
k[8*(i)+ 9] = ss[1] ^= ss[0]; \
k[8*(i)+10] = ss[2] ^= ss[1]; \
k[8*(i)+11] = ss[3] ^= ss[2]; \
}
#define ke8(k,i) \
{ kef8(k,i); \
k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \
k[8*(i)+13] = ss[5] ^= ss[4]; \
k[8*(i)+14] = ss[6] ^= ss[5]; \
k[8*(i)+15] = ss[7] ^= ss[6]; \
}
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1])
{ uint_32t ss[8];
cx->ks[0] = ss[0] = word_in(key, 0);
cx->ks[1] = ss[1] = word_in(key, 1);
cx->ks[2] = ss[2] = word_in(key, 2);
cx->ks[3] = ss[3] = word_in(key, 3);
cx->ks[4] = ss[4] = word_in(key, 4);
cx->ks[5] = ss[5] = word_in(key, 5);
cx->ks[6] = ss[6] = word_in(key, 6);
cx->ks[7] = ss[7] = word_in(key, 7);
#ifdef ENC_KS_UNROLL
ke8(cx->ks, 0); ke8(cx->ks, 1);
ke8(cx->ks, 2); ke8(cx->ks, 3);
ke8(cx->ks, 4); ke8(cx->ks, 5);
#else
{ uint_32t i;
for(i = 0; i < 6; ++i)
ke8(cx->ks, i);
}
#endif
kef8(cx->ks, 6);
cx->inf.l = 0;
cx->inf.b[0] = 14 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined( AES_VAR )
AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1])
{
switch(key_len)
{
case 16: case 128: return aes_encrypt_key128(key, cx);
case 24: case 192: return aes_encrypt_key192(key, cx);
case 32: case 256: return aes_encrypt_key256(key, cx);
default: return EXIT_FAILURE;
}
}
#endif
#endif
#if (FUNCS_IN_C & DEC_KEYING_IN_C)
/* this is used to store the decryption round keys */
/* in forward or reverse order */
#ifdef AES_REV_DKS
#define v(n,i) ((n) - (i) + 2 * ((i) & 3))
#else
#define v(n,i) (i)
#endif
#if DEC_ROUND == NO_TABLES
#define ff(x) (x)
#else
#define ff(x) inv_mcol(x)
#if defined( dec_imvars )
#define d_vars dec_imvars
#endif
#endif
#if defined(AES_128) || defined( AES_VAR )
#define k4e(k,i) \
{ k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \
k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \
k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \
}
#if 1
#define kdf4(k,i) \
{ ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \
ss[1] = ss[1] ^ ss[3]; \
ss[2] = ss[2] ^ ss[3]; \
ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
ss[i % 4] ^= ss[4]; \
ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \
ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \
ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \
ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \
}
#define kd4(k,i) \
{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \
k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \
k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \
k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \
k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \
}
#define kdl4(k,i) \
{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \
k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \
k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \
k[v(40,(4*(i))+6)] = ss[0]; \
k[v(40,(4*(i))+7)] = ss[1]; \
}
#else
#define kdf4(k,i) \
{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \
}
#define kd4(k,i) \
{ ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \
ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \
}
#define kdl4(k,i) \
{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \
}
#endif
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint_32t ss[5];
#if defined( d_vars )
d_vars;
#endif
cx->ks[v(40,(0))] = ss[0] = word_in(key, 0);
cx->ks[v(40,(1))] = ss[1] = word_in(key, 1);
cx->ks[v(40,(2))] = ss[2] = word_in(key, 2);
cx->ks[v(40,(3))] = ss[3] = word_in(key, 3);
#ifdef DEC_KS_UNROLL
kdf4(cx->ks, 0); kd4(cx->ks, 1);
kd4(cx->ks, 2); kd4(cx->ks, 3);
kd4(cx->ks, 4); kd4(cx->ks, 5);
kd4(cx->ks, 6); kd4(cx->ks, 7);
kd4(cx->ks, 8); kdl4(cx->ks, 9);
#else
{ uint_32t i;
for(i = 0; i < 10; ++i)
k4e(cx->ks, i);
#if !(DEC_ROUND == NO_TABLES)
for(i = N_COLS; i < 10 * N_COLS; ++i)
cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
}
#endif
cx->inf.l = 0;
cx->inf.b[0] = 10 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined(AES_192) || defined( AES_VAR )
#define k6ef(k,i) \
{ k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \
k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \
k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \
}
#define k6e(k,i) \
{ k6ef(k,i); \
k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \
k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \
}
#define kdf6(k,i) \
{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \
ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \
ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \
}
#define kd6(k,i) \
{ ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \
ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \
ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \
ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \
}
#define kdl6(k,i) \
{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \
}
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint_32t ss[7];
#if defined( d_vars )
d_vars;
#endif
cx->ks[v(48,(0))] = ss[0] = word_in(key, 0);
cx->ks[v(48,(1))] = ss[1] = word_in(key, 1);
cx->ks[v(48,(2))] = ss[2] = word_in(key, 2);
cx->ks[v(48,(3))] = ss[3] = word_in(key, 3);
#ifdef DEC_KS_UNROLL
cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4));
cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5));
kdf6(cx->ks, 0); kd6(cx->ks, 1);
kd6(cx->ks, 2); kd6(cx->ks, 3);
kd6(cx->ks, 4); kd6(cx->ks, 5);
kd6(cx->ks, 6); kdl6(cx->ks, 7);
#else
cx->ks[v(48,(4))] = ss[4] = word_in(key, 4);
cx->ks[v(48,(5))] = ss[5] = word_in(key, 5);
{ uint_32t i;
for(i = 0; i < 7; ++i)
k6e(cx->ks, i);
k6ef(cx->ks, 7);
#if !(DEC_ROUND == NO_TABLES)
for(i = N_COLS; i < 12 * N_COLS; ++i)
cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
}
#endif
cx->inf.l = 0;
cx->inf.b[0] = 12 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined(AES_256) || defined( AES_VAR )
#define k8ef(k,i) \
{ k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \
k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \
k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \
}
#define k8e(k,i) \
{ k8ef(k,i); \
k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \
k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \
k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \
k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \
}
#define kdf8(k,i) \
{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \
ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \
ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \
ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \
ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \
}
#define kd8(k,i) \
{ ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \
ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \
ss[8] = ls_box(ss[3],0); \
ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \
ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \
ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \
ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \
}
#define kdl8(k,i) \
{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \
}
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1])
{ uint_32t ss[9];
#if defined( d_vars )
d_vars;
#endif
cx->ks[v(56,(0))] = ss[0] = word_in(key, 0);
cx->ks[v(56,(1))] = ss[1] = word_in(key, 1);
cx->ks[v(56,(2))] = ss[2] = word_in(key, 2);
cx->ks[v(56,(3))] = ss[3] = word_in(key, 3);
#ifdef DEC_KS_UNROLL
cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4));
cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5));
cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6));
cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7));
kdf8(cx->ks, 0); kd8(cx->ks, 1);
kd8(cx->ks, 2); kd8(cx->ks, 3);
kd8(cx->ks, 4); kd8(cx->ks, 5);
kdl8(cx->ks, 6);
#else
cx->ks[v(56,(4))] = ss[4] = word_in(key, 4);
cx->ks[v(56,(5))] = ss[5] = word_in(key, 5);
cx->ks[v(56,(6))] = ss[6] = word_in(key, 6);
cx->ks[v(56,(7))] = ss[7] = word_in(key, 7);
{ uint_32t i;
for(i = 0; i < 6; ++i)
k8e(cx->ks, i);
k8ef(cx->ks, 6);
#if !(DEC_ROUND == NO_TABLES)
for(i = N_COLS; i < 14 * N_COLS; ++i)
cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
}
#endif
cx->inf.l = 0;
cx->inf.b[0] = 14 * 16;
#ifdef USE_VIA_ACE_IF_PRESENT
if(VIA_ACE_AVAILABLE)
cx->inf.b[1] = 0xff;
#endif
return EXIT_SUCCESS;
}
#endif
#if defined( AES_VAR )
AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1])
{
switch(key_len)
{
case 16: case 128: return aes_decrypt_key128(key, cx);
case 24: case 192: return aes_decrypt_key192(key, cx);
case 32: case 256: return aes_decrypt_key256(key, cx);
default: return EXIT_FAILURE;
}
}
#endif
#endif
#if defined(__cplusplus)
}
#endif
================================================
FILE: libs/minizip/source/aes/aesopt.h
================================================
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
This file contains the compilation options for AES (Rijndael) and code
that is common across encryption, key scheduling and table generation.
OPERATION
These source code files implement the AES algorithm Rijndael designed by
Joan Daemen and Vincent Rijmen. This version is designed for the standard
block size of 16 bytes and for key sizes of 128, 192 and 256 bits (16, 24
and 32 bytes).
This version is designed for flexibility and speed using operations on
32-bit words rather than operations on bytes. It can be compiled with
either big or little endian internal byte order but is faster when the
native byte order for the processor is used.
THE CIPHER INTERFACE
The cipher interface is implemented as an array of bytes in which lower
AES bit sequence indexes map to higher numeric significance within bytes.
uint_8t (an unsigned 8-bit type)
uint_32t (an unsigned 32-bit type)
struct aes_encrypt_ctx (structure for the cipher encryption context)
struct aes_decrypt_ctx (structure for the cipher decryption context)
AES_RETURN the function return type
C subroutine calls:
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out,
const aes_encrypt_ctx cx[1]);
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out,
const aes_decrypt_ctx cx[1]);
IMPORTANT NOTE: If you are using this C interface with dynamic tables make sure that
you call aes_init() before AES is used so that the tables are initialised.
C++ aes class subroutines:
Class AESencrypt for encryption
Construtors:
AESencrypt(void)
AESencrypt(const unsigned char *key) - 128 bit key
Members:
AES_RETURN key128(const unsigned char *key)
AES_RETURN key192(const unsigned char *key)
AES_RETURN key256(const unsigned char *key)
AES_RETURN encrypt(const unsigned char *in, unsigned char *out) const
Class AESdecrypt for encryption
Construtors:
AESdecrypt(void)
AESdecrypt(const unsigned char *key) - 128 bit key
Members:
AES_RETURN key128(const unsigned char *key)
AES_RETURN key192(const unsigned char *key)
AES_RETURN key256(const unsigned char *key)
AES_RETURN decrypt(const unsigned char *in, unsigned char *out) const
*/
#if !defined( _AESOPT_H )
#define _AESOPT_H
#if defined( __cplusplus )
#include "aescpp.h"
#else
#include "aes.h"
#endif
/* PLATFORM SPECIFIC INCLUDES */
#include "brg_endian.h"
/* CONFIGURATION - THE USE OF DEFINES
Later in this section there are a number of defines that control the
operation of the code. In each section, the purpose of each define is
explained so that the relevant form can be included or excluded by
setting either 1's or 0's respectively on the branches of the related
#if clauses. The following local defines should not be changed.
*/
#define ENCRYPTION_IN_C 1
#define DECRYPTION_IN_C 2
#define ENC_KEYING_IN_C 4
#define DEC_KEYING_IN_C 8
#define NO_TABLES 0
#define ONE_TABLE 1
#define FOUR_TABLES 4
#define NONE 0
#define PARTIAL 1
#define FULL 2
/* --- START OF USER CONFIGURED OPTIONS --- */
/* 1. BYTE ORDER WITHIN 32 BIT WORDS
The fundamental data processing units in Rijndael are 8-bit bytes. The
input, output and key input are all enumerated arrays of bytes in which
bytes are numbered starting at zero and increasing to one less than the
number of bytes in the array in question. This enumeration is only used
for naming bytes and does not imply any adjacency or order relationship
from one byte to another. When these inputs and outputs are considered
as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to
byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte.
In this implementation bits are numbered from 0 to 7 starting at the
numerically least significant end of each byte (bit n represents 2^n).
However, Rijndael can be implemented more efficiently using 32-bit
words by packing bytes into words so that bytes 4*n to 4*n+3 are placed
into word[n]. While in principle these bytes can be assembled into words
in any positions, this implementation only supports the two formats in
which bytes in adjacent positions within words also have adjacent byte
numbers. This order is called big-endian if the lowest numbered bytes
in words have the highest numeric significance and little-endian if the
opposite applies.
This code can work in either order irrespective of the order used by the
machine on which it runs. Normally the internal byte order will be set
to the order of the processor on which the code is to be run but this
define can be used to reverse this in special situations
WARNING: Assembler code versions rely on PLATFORM_BYTE_ORDER being set.
This define will hence be redefined later (in section 4) if necessary
*/
#if 1
# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER
#elif 0
# define ALGORITHM_BYTE_ORDER IS_LITTLE_ENDIAN
#elif 0
# define ALGORITHM_BYTE_ORDER IS_BIG_ENDIAN
#else
# error The algorithm byte order is not defined
#endif
/* 2. VIA ACE SUPPORT */
#if !defined(__APPLE__) && defined( __GNUC__ ) && defined( __i386__ ) \
|| defined( _WIN32 ) && defined( _M_IX86 ) \
&& !(defined( _WIN64 ) || defined( _WIN32_WCE ) || defined( _MSC_VER ) && ( _MSC_VER <= 800 ))
# define VIA_ACE_POSSIBLE
#endif
/* Define this option if support for the VIA ACE is required. This uses
inline assembler instructions and is only implemented for the Microsoft,
Intel and GCC compilers. If VIA ACE is known to be present, then defining
ASSUME_VIA_ACE_PRESENT will remove the ordinary encryption/decryption
code. If USE_VIA_ACE_IF_PRESENT is defined then VIA ACE will be used if
it is detected (both present and enabled) but the normal AES code will
also be present.
When VIA ACE is to be used, all AES encryption contexts MUST be 16 byte
aligned; other input/output buffers do not need to be 16 byte aligned
but there are very large performance gains if this can be arranged.
VIA ACE also requires the decryption key schedule to be in reverse
order (which later checks below ensure).
*/
#if 1 && defined( VIA_ACE_POSSIBLE ) && !defined( USE_VIA_ACE_IF_PRESENT )
# define USE_VIA_ACE_IF_PRESENT
#endif
#if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( ASSUME_VIA_ACE_PRESENT )
# define ASSUME_VIA_ACE_PRESENT
# endif
/* 3. ASSEMBLER SUPPORT
This define (which can be on the command line) enables the use of the
assembler code routines for encryption, decryption and key scheduling
as follows:
ASM_X86_V1C uses the assembler (aes_x86_v1.asm) with large tables for
encryption and decryption and but with key scheduling in C
ASM_X86_V2 uses assembler (aes_x86_v2.asm) with compressed tables for
encryption, decryption and key scheduling
ASM_X86_V2C uses assembler (aes_x86_v2.asm) with compressed tables for
encryption and decryption and but with key scheduling in C
ASM_AMD64_C uses assembler (aes_amd64.asm) with compressed tables for
encryption and decryption and but with key scheduling in C
Change one 'if 0' below to 'if 1' to select the version or define
as a compilation option.
*/
#if 0 && !defined( ASM_X86_V1C )
# define ASM_X86_V1C
#elif 0 && !defined( ASM_X86_V2 )
# define ASM_X86_V2
#elif 0 && !defined( ASM_X86_V2C )
# define ASM_X86_V2C
#elif 0 && !defined( ASM_AMD64_C )
# define ASM_AMD64_C
#endif
#if (defined ( ASM_X86_V1C ) || defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) \
&& !defined( _M_IX86 ) || defined( ASM_AMD64_C ) && !defined( _M_X64 )
# error Assembler code is only available for x86 and AMD64 systems
#endif
/* 4. FAST INPUT/OUTPUT OPERATIONS.
On some machines it is possible to improve speed by transferring the
bytes in the input and output arrays to and from the internal 32-bit
variables by addressing these arrays as if they are arrays of 32-bit
words. On some machines this will always be possible but there may
be a large performance penalty if the byte arrays are not aligned on
the normal word boundaries. On other machines this technique will
lead to memory access errors when such 32-bit word accesses are not
properly aligned. The option SAFE_IO avoids such problems but will
often be slower on those machines that support misaligned access
(especially so if care is taken to align the input and output byte
arrays on 32-bit word boundaries). If SAFE_IO is not defined it is
assumed that access to byte arrays as if they are arrays of 32-bit
words will not cause problems when such accesses are misaligned.
*/
#if 1 && !defined( _MSC_VER )
# define SAFE_IO
#endif
/* 5. LOOP UNROLLING
The code for encryption and decrytpion cycles through a number of rounds
that can be implemented either in a loop or by expanding the code into a
long sequence of instructions, the latter producing a larger program but
one that will often be much faster. The latter is called loop unrolling.
There are also potential speed advantages in expanding two iterations in
a loop with half the number of iterations, which is called partial loop
unrolling. The following options allow partial or full loop unrolling
to be set independently for encryption and decryption
*/
#if 1
# define ENC_UNROLL FULL
#elif 0
# define ENC_UNROLL PARTIAL
#else
# define ENC_UNROLL NONE
#endif
#if 1
# define DEC_UNROLL FULL
#elif 0
# define DEC_UNROLL PARTIAL
#else
# define DEC_UNROLL NONE
#endif
#if 1
# define ENC_KS_UNROLL
#endif
#if 1
# define DEC_KS_UNROLL
#endif
/* 6. FAST FINITE FIELD OPERATIONS
If this section is included, tables are used to provide faster finite
field arithmetic (this has no effect if FIXED_TABLES is defined).
*/
#if 1
# define FF_TABLES
#endif
/* 7. INTERNAL STATE VARIABLE FORMAT
The internal state of Rijndael is stored in a number of local 32-bit
word varaibles which can be defined either as an array or as individual
names variables. Include this section if you want to store these local
varaibles in arrays. Otherwise individual local variables will be used.
*/
#if 1
# define ARRAYS
#endif
/* 8. FIXED OR DYNAMIC TABLES
When this section is included the tables used by the code are compiled
statically into the binary file. Otherwise the subroutine aes_init()
must be called to compute them before the code is first used.
*/
#if 1 && !(defined( _MSC_VER ) && ( _MSC_VER <= 800 ))
# define FIXED_TABLES
#endif
/* 9. MASKING OR CASTING FROM LONGER VALUES TO BYTES
In some systems it is better to mask longer values to extract bytes
rather than using a cast. This option allows this choice.
*/
#if 0
# define to_byte(x) ((uint_8t)(x))
#else
# define to_byte(x) ((x) & 0xff)
#endif
/* 10. TABLE ALIGNMENT
On some sytsems speed will be improved by aligning the AES large lookup
tables on particular boundaries. This define should be set to a power of
two giving the desired alignment. It can be left undefined if alignment
is not needed. This option is specific to the Microsft VC++ compiler -
it seems to sometimes cause trouble for the VC++ version 6 compiler.
*/
#if 1 && defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
# define TABLE_ALIGN 32
#endif
/* 11. REDUCE CODE AND TABLE SIZE
This replaces some expanded macros with function calls if AES_ASM_V2 or
AES_ASM_V2C are defined
*/
#if 1 && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))
# define REDUCE_CODE_SIZE
#endif
/* 12. TABLE OPTIONS
This cipher proceeds by repeating in a number of cycles known as 'rounds'
which are implemented by a round function which can optionally be speeded
up using tables. The basic tables are each 256 32-bit words, with either
one or four tables being required for each round function depending on
how much speed is required. The encryption and decryption round functions
are different and the last encryption and decrytpion round functions are
different again making four different round functions in all.
This means that:
1. Normal encryption and decryption rounds can each use either 0, 1
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
2. The last encryption and decryption rounds can also use either 0, 1
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
Include or exclude the appropriate definitions below to set the number
of tables used by this implementation.
*/
#if 1 /* set tables for the normal encryption round */
# define ENC_ROUND FOUR_TABLES
#elif 0
# define ENC_ROUND ONE_TABLE
#else
# define ENC_ROUND NO_TABLES
#endif
#if 1 /* set tables for the last encryption round */
# define LAST_ENC_ROUND FOUR_TABLES
#elif 0
# define LAST_ENC_ROUND ONE_TABLE
#else
# define LAST_ENC_ROUND NO_TABLES
#endif
#if 1 /* set tables for the normal decryption round */
# define DEC_ROUND FOUR_TABLES
#elif 0
# define DEC_ROUND ONE_TABLE
#else
# define DEC_ROUND NO_TABLES
#endif
#if 1 /* set tables for the last decryption round */
# define LAST_DEC_ROUND FOUR_TABLES
#elif 0
# define LAST_DEC_ROUND ONE_TABLE
#else
# define LAST_DEC_ROUND NO_TABLES
#endif
/* The decryption key schedule can be speeded up with tables in the same
way that the round functions can. Include or exclude the following
defines to set this requirement.
*/
#if 1
# define KEY_SCHED FOUR_TABLES
#elif 0
# define KEY_SCHED ONE_TABLE
#else
# define KEY_SCHED NO_TABLES
#endif
/* ---- END OF USER CONFIGURED OPTIONS ---- */
/* VIA ACE support is only available for VC++ and GCC */
#if !defined( _MSC_VER ) && !defined( __GNUC__ )
# if defined( ASSUME_VIA_ACE_PRESENT )
# undef ASSUME_VIA_ACE_PRESENT
# endif
# if defined( USE_VIA_ACE_IF_PRESENT )
# undef USE_VIA_ACE_IF_PRESENT
# endif
#endif
#if defined( ASSUME_VIA_ACE_PRESENT ) && !defined( USE_VIA_ACE_IF_PRESENT )
# define USE_VIA_ACE_IF_PRESENT
#endif
#if defined( USE_VIA_ACE_IF_PRESENT ) && !defined ( AES_REV_DKS )
# define AES_REV_DKS
#endif
/* Assembler support requires the use of platform byte order */
#if ( defined( ASM_X86_V1C ) || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) ) \
&& (ALGORITHM_BYTE_ORDER != PLATFORM_BYTE_ORDER)
# undef ALGORITHM_BYTE_ORDER
# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER
#endif
/* In this implementation the columns of the state array are each held in
32-bit words. The state array can be held in various ways: in an array
of words, in a number of individual word variables or in a number of
processor registers. The following define maps a variable name x and
a column number c to the way the state array variable is to be held.
The first define below maps the state into an array x[c] whereas the
second form maps the state into a number of individual variables x0,
x1, etc. Another form could map individual state colums to machine
register names.
*/
#if defined( ARRAYS )
# define s(x,c) x[c]
#else
# define s(x,c) x##c
#endif
/* This implementation provides subroutines for encryption, decryption
and for setting the three key lengths (separately) for encryption
and decryption. Since not all functions are needed, masks are set
up here to determine which will be implemented in C
*/
#if !defined( AES_ENCRYPT )
# define EFUNCS_IN_C 0
#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \
|| defined( ASM_X86_V2C ) || defined( ASM_AMD64_C )
# define EFUNCS_IN_C ENC_KEYING_IN_C
#elif !defined( ASM_X86_V2 )
# define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C )
#else
# define EFUNCS_IN_C 0
#endif
#if !defined( AES_DECRYPT )
# define DFUNCS_IN_C 0
#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \
|| defined( ASM_X86_V2C ) || defined( ASM_AMD64_C )
# define DFUNCS_IN_C DEC_KEYING_IN_C
#elif !defined( ASM_X86_V2 )
# define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C )
#else
# define DFUNCS_IN_C 0
#endif
#define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C )
/* END OF CONFIGURATION OPTIONS */
#define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2))
/* Disable or report errors on some combinations of options */
#if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES
# undef LAST_ENC_ROUND
# define LAST_ENC_ROUND NO_TABLES
#elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES
# undef LAST_ENC_ROUND
# define LAST_ENC_ROUND ONE_TABLE
#endif
#if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE
# undef ENC_UNROLL
# define ENC_UNROLL NONE
#endif
#if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES
# undef LAST_DEC_ROUND
# define LAST_DEC_ROUND NO_TABLES
#elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES
# undef LAST_DEC_ROUND
# define LAST_DEC_ROUND ONE_TABLE
#endif
#if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE
# undef DEC_UNROLL
# define DEC_UNROLL NONE
#endif
#if defined( bswap32 )
# define aes_sw32 bswap32
#elif defined( bswap_32 )
# define aes_sw32 bswap_32
#else
# define brot(x,n) (((uint_32t)(x) << n) | ((uint_32t)(x) >> (32 - n)))
# define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))
#endif
/* upr(x,n): rotates bytes within words by n positions, moving bytes to
higher index positions with wrap around into low positions
ups(x,n): moves bytes by n positions to higher index positions in
words but without wrap around
bval(x,n): extracts a byte from a word
WARNING: The definitions given here are intended only for use with
unsigned variables and with shift counts that are compile
time constants
*/
#if ( ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN )
# define upr(x,n) (((uint_32t)(x) << (8 * (n))) | ((uint_32t)(x) >> (32 - 8 * (n))))
# define ups(x,n) ((uint_32t) (x) << (8 * (n)))
# define bval(x,n) to_byte((x) >> (8 * (n)))
# define bytes2word(b0, b1, b2, b3) \
(((uint_32t)(b3) << 24) | ((uint_32t)(b2) << 16) | ((uint_32t)(b1) << 8) | (b0))
#endif
#if ( ALGORITHM_BYTE_ORDER == IS_BIG_ENDIAN )
# define upr(x,n) (((uint_32t)(x) >> (8 * (n))) | ((uint_32t)(x) << (32 - 8 * (n))))
# define ups(x,n) ((uint_32t) (x) >> (8 * (n)))
# define bval(x,n) to_byte((x) >> (24 - 8 * (n)))
# define bytes2word(b0, b1, b2, b3) \
(((uint_32t)(b0) << 24) | ((uint_32t)(b1) << 16) | ((uint_32t)(b2) << 8) | (b3))
#endif
#if defined( SAFE_IO )
# define word_in(x,c) bytes2word(((const uint_8t*)(x)+4*c)[0], ((const uint_8t*)(x)+4*c)[1], \
((const uint_8t*)(x)+4*c)[2], ((const uint_8t*)(x)+4*c)[3])
# define word_out(x,c,v) { ((uint_8t*)(x)+4*c)[0] = bval(v,0); ((uint_8t*)(x)+4*c)[1] = bval(v,1); \
((uint_8t*)(x)+4*c)[2] = bval(v,2); ((uint_8t*)(x)+4*c)[3] = bval(v,3); }
#elif ( ALGORITHM_BYTE_ORDER == PLATFORM_BYTE_ORDER )
# define word_in(x,c) (*((uint_32t*)(x)+(c)))
# define word_out(x,c,v) (*((uint_32t*)(x)+(c)) = (v))
#else
# define word_in(x,c) aes_sw32(*((uint_32t*)(x)+(c)))
# define word_out(x,c,v) (*((uint_32t*)(x)+(c)) = aes_sw32(v))
#endif
/* the finite field modular polynomial and elements */
#define WPOLY 0x011b
#define BPOLY 0x1b
/* multiply four bytes in GF(2^8) by 'x' {02} in parallel */
#define gf_c1 0x80808080
#define gf_c2 0x7f7f7f7f
#define gf_mulx(x) ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY))
/* The following defines provide alternative definitions of gf_mulx that might
give improved performance if a fast 32-bit multiply is not available. Note
that a temporary variable u needs to be defined where gf_mulx is used.
#define gf_mulx(x) (u = (x) & gf_c1, u |= (u >> 1), ((x) & gf_c2) << 1) ^ ((u >> 3) | (u >> 6))
#define gf_c4 (0x01010101 * BPOLY)
#define gf_mulx(x) (u = (x) & gf_c1, ((x) & gf_c2) << 1) ^ ((u - (u >> 7)) & gf_c4)
*/
/* Work out which tables are needed for the different options */
#if defined( ASM_X86_V1C )
# if defined( ENC_ROUND )
# undef ENC_ROUND
# endif
# define ENC_ROUND FOUR_TABLES
# if defined( LAST_ENC_ROUND )
# undef LAST_ENC_ROUND
# endif
# define LAST_ENC_ROUND FOUR_TABLES
# if defined( DEC_ROUND )
# undef DEC_ROUND
# endif
# define DEC_ROUND FOUR_TABLES
# if defined( LAST_DEC_ROUND )
# undef LAST_DEC_ROUND
# endif
# define LAST_DEC_ROUND FOUR_TABLES
# if defined( KEY_SCHED )
# undef KEY_SCHED
# define KEY_SCHED FOUR_TABLES
# endif
#endif
#if ( FUNCS_IN_C & ENCRYPTION_IN_C ) || defined( ASM_X86_V1C )
# if ENC_ROUND == ONE_TABLE
# define FT1_SET
# elif ENC_ROUND == FOUR_TABLES
# define FT4_SET
# else
# define SBX_SET
# endif
# if LAST_ENC_ROUND == ONE_TABLE
# define FL1_SET
# elif LAST_ENC_ROUND == FOUR_TABLES
# define FL4_SET
# elif !defined( SBX_SET )
# define SBX_SET
# endif
#endif
#if ( FUNCS_IN_C & DECRYPTION_IN_C ) || defined( ASM_X86_V1C )
# if DEC_ROUND == ONE_TABLE
# define IT1_SET
# elif DEC_ROUND == FOUR_TABLES
# define IT4_SET
# else
# define ISB_SET
# endif
# if LAST_DEC_ROUND == ONE_TABLE
# define IL1_SET
# elif LAST_DEC_ROUND == FOUR_TABLES
# define IL4_SET
# elif !defined(ISB_SET)
# define ISB_SET
# endif
#endif
#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )))
# if ((FUNCS_IN_C & ENC_KEYING_IN_C) || (FUNCS_IN_C & DEC_KEYING_IN_C))
# if KEY_SCHED == ONE_TABLE
# if !defined( FL1_SET ) && !defined( FL4_SET )
# define LS1_SET
# endif
# elif KEY_SCHED == FOUR_TABLES
# if !defined( FL4_SET )
# define LS4_SET
# endif
# elif !defined( SBX_SET )
# define SBX_SET
# endif
# endif
# if (FUNCS_IN_C & DEC_KEYING_IN_C)
# if KEY_SCHED == ONE_TABLE
# define IM1_SET
# elif KEY_SCHED == FOUR_TABLES
# define IM4_SET
# elif !defined( SBX_SET )
# define SBX_SET
# endif
# endif
#endif
/* generic definitions of Rijndael macros that use tables */
#define no_table(x,box,vf,rf,c) bytes2word( \
box[bval(vf(x,0,c),rf(0,c))], \
box[bval(vf(x,1,c),rf(1,c))], \
box[bval(vf(x,2,c),rf(2,c))], \
box[bval(vf(x,3,c),rf(3,c))])
#define one_table(x,op,tab,vf,rf,c) \
( tab[bval(vf(x,0,c),rf(0,c))] \
^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \
^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \
^ op(tab[bval(vf(x,3,c),rf(3,c))],3))
#define four_tables(x,tab,vf,rf,c) \
( tab[0][bval(vf(x,0,c),rf(0,c))] \
^ tab[1][bval(vf(x,1,c),rf(1,c))] \
^ tab[2][bval(vf(x,2,c),rf(2,c))] \
^ tab[3][bval(vf(x,3,c),rf(3,c))])
#define vf1(x,r,c) (x)
#define rf1(r,c) (r)
#define rf2(r,c) ((8+r-c)&3)
/* perform forward and inverse column mix operation on four bytes in long word x in */
/* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */
#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )))
#if defined( FM4_SET ) /* not currently used */
# define fwd_mcol(x) four_tables(x,t_use(f,m),vf1,rf1,0)
#elif defined( FM1_SET ) /* not currently used */
# define fwd_mcol(x) one_table(x,upr,t_use(f,m),vf1,rf1,0)
#else
# define dec_fmvars uint_32t g2
# define fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1))
#endif
#if defined( IM4_SET )
# define inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0)
#elif defined( IM1_SET )
# define inv_mcol(x) one_table(x,upr,t_use(i,m),vf1,rf1,0)
#else
# define dec_imvars uint_32t g2, g4, g9
# define inv_mcol(x) (g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \
(x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1))
#endif
#if defined( FL4_SET )
# define ls_box(x,c) four_tables(x,t_use(f,l),vf1,rf2,c)
#elif defined( LS4_SET )
# define ls_box(x,c) four_tables(x,t_use(l,s),vf1,rf2,c)
#elif defined( FL1_SET )
# define ls_box(x,c) one_table(x,upr,t_use(f,l),vf1,rf2,c)
#elif defined( LS1_SET )
# define ls_box(x,c) one_table(x,upr,t_use(l,s),vf1,rf2,c)
#else
# define ls_box(x,c) no_table(x,t_use(s,box),vf1,rf2,c)
#endif
#endif
#if defined( ASM_X86_V1C ) && defined( AES_DECRYPT ) && !defined( ISB_SET )
# define ISB_SET
#endif
#endif
================================================
FILE: libs/minizip/source/aes/aestab.c
================================================
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
*/
#define DO_TABLES
#include "aes.h"
#include "aesopt.h"
#if defined(FIXED_TABLES)
#define sb_data(w) {\
w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\
w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\
w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\
w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\
w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3
gitextract_9wj35k_u/
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── include/
│ ├── download.hpp
│ ├── extract.hpp
│ ├── title.h
│ └── titles.hpp
├── libs/
│ └── minizip/
│ ├── include/
│ │ ├── CDirEntry.h
│ │ ├── crypt.h
│ │ ├── defs.h
│ │ ├── ioapi.h
│ │ ├── ioapi_buf.h
│ │ ├── ioapi_mem.h
│ │ ├── iowin32.h
│ │ ├── tools.h
│ │ ├── unzip.h
│ │ ├── unzipper.h
│ │ ├── zip.h
│ │ └── zipper.h
│ └── source/
│ ├── CDirEntry.cpp
│ ├── aes/
│ │ ├── Makefile
│ │ ├── aes.h
│ │ ├── aes_via_ace.h
│ │ ├── aescrypt.c
│ │ ├── aeskey.c
│ │ ├── aesopt.h
│ │ ├── aestab.c
│ │ ├── aestab.h
│ │ ├── brg_endian.h
│ │ ├── brg_types.h
│ │ ├── entropy.c
│ │ ├── entropy.h
│ │ ├── fileenc.c
│ │ ├── fileenc.h
│ │ ├── hmac.c
│ │ ├── hmac.h
│ │ ├── prng.c
│ │ ├── prng.h
│ │ ├── pwd2key.c
│ │ ├── pwd2key.h
│ │ ├── sha1.c
│ │ └── sha1.h
│ ├── ioapi.c
│ ├── ioapi_buf.c
│ ├── ioapi_mem.c
│ ├── tools.cpp
│ ├── unzip.c
│ ├── unzipper.cpp
│ ├── zip.c
│ └── zipper.cpp
└── source/
├── download.cpp
├── extract.cpp
├── main.cpp
└── titles.cpp
SYMBOL INDEX (322 symbols across 40 files)
FILE: include/extract.hpp
type CFW (line 31) | enum CFW{
FILE: include/title.h
type Title (line 12) | struct Title {
FILE: libs/minizip/include/CDirEntry.h
function namespace (line 16) | namespace zipper
FILE: libs/minizip/include/crypt.h
function decrypt_byte (line 34) | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_...
function update_keys (line 47) | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32...
function init_keys (line 64) | static void init_keys(const char* passwd,unsigned long* pkeys,const unsi...
function crypthead (line 89) | static int crypthead(const char* passwd, /* password string */
FILE: libs/minizip/include/ioapi.h
type IT_INT_CUSTOM_TYPE (line 62) | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
type ZPOS64_T (line 66) | typedef uint64_t ZPOS64_T;
type ZPOS64_T (line 69) | typedef unsigned __int64 ZPOS64_T;
type ZPOS64_T (line 71) | typedef unsigned long long int ZPOS64_T;
type zlib_filefunc_def (line 110) | typedef struct zlib_filefunc_def_s
type zlib_filefunc64_def (line 128) | typedef struct zlib_filefunc64_def_s
type zlib_filefunc64_32_def (line 145) | typedef struct zlib_filefunc64_32_def_s
FILE: libs/minizip/include/ioapi_buf.h
type ourbuffer_t (line 42) | typedef struct ourbuffer_s {
FILE: libs/minizip/include/ioapi_mem.h
type ourmemory_t (line 41) | typedef struct ourmemory_s {
FILE: libs/minizip/include/tools.h
function namespace (line 8) | namespace zipper
FILE: libs/minizip/include/unzip.h
type unzFile__ (line 41) | typedef struct TagunzFile__ { int unused; } unzFile__;
type unzFile__ (line 42) | typedef unzFile__ *unzFile;
type voidp (line 44) | typedef voidp unzFile;
type tm_unz (line 58) | typedef struct tm_unz_s
type unz_global_info64 (line 70) | typedef struct unz_global_info64_s
type unz_global_info (line 77) | typedef struct unz_global_info_s
type unz_file_info64 (line 85) | typedef struct unz_file_info64_s
type unz_file_info (line 108) | typedef struct unz_file_info_s
type unz_file_pos (line 277) | typedef struct unz_file_pos_s
type unz64_file_pos (line 286) | typedef struct unz64_file_pos_s
FILE: libs/minizip/include/unzipper.h
function namespace (line 11) | namespace zipper {
FILE: libs/minizip/include/zip.h
type zipFile__ (line 39) | typedef struct TagzipFile__ { int unused; } zipFile__;
type zipFile__ (line 40) | typedef zipFile__ *zipFile;
type voidp (line 42) | typedef voidp zipFile;
type tm_zip (line 62) | typedef struct tm_zip_s
type zip_fileinfo (line 72) | typedef struct
FILE: libs/minizip/include/zipper.h
function namespace (line 9) | namespace zipper {
FILE: libs/minizip/source/CDirEntry.cpp
type _stat (line 22) | struct _stat
type stat (line 30) | struct stat
type _finddata_t (line 306) | struct _finddata_t
type dirent (line 345) | struct dirent
FILE: libs/minizip/source/aes/aes.h
type aes_inf (line 71) | typedef union
type aes_encrypt_ctx (line 76) | typedef struct
type aes_decrypt_ctx (line 81) | typedef struct
FILE: libs/minizip/source/aes/aes_via_ace.h
function INLINE (line 335) | INLINE int has_cpuid(void)
function INLINE (line 351) | INLINE int is_via_cpu(void)
function INLINE (line 370) | INLINE int read_via_flags(void)
function INLINE (line 387) | INLINE int via_rng_in(void *buf)
function INLINE (line 399) | INLINE volatile void via_ecb_op5(
function INLINE (line 413) | INLINE volatile void via_cbc_op6(
function INLINE (line 428) | INLINE volatile void via_cbc_op7(
function INLINE (line 446) | INLINE volatile void via_cfb_op6(
function INLINE (line 461) | INLINE volatile void via_cfb_op7(
function INLINE (line 479) | INLINE volatile void via_ofb_op6(
function INLINE (line 498) | INLINE int via_ace_test(void)
function INLINE (line 506) | INLINE int via_rng_test(void)
function INLINE (line 514) | INLINE int read_via_rng(void *buf, int count)
FILE: libs/minizip/source/aes/aeskey.c
function AES_RETURN (line 75) | AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx ...
function AES_RETURN (line 123) | AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx ...
function AES_RETURN (line 174) | AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx ...
function AES_RETURN (line 211) | AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_en...
function AES_RETURN (line 312) | AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx ...
function AES_RETURN (line 391) | AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx ...
function AES_RETURN (line 482) | AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx ...
function AES_RETURN (line 531) | AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_de...
FILE: libs/minizip/source/aes/aestab.c
function AES_RETURN (line 187) | AES_RETURN aes_init(void)
function uint_8t (line 211) | static uint_8t hibit(const uint_32t x)
function uint_8t (line 221) | static uint_8t gf_inv(const uint_8t x)
function uint_8t (line 256) | uint_8t fwd_affine(const uint_8t x)
function uint_8t (line 262) | uint_8t inv_affine(const uint_8t x)
function AES_RETURN (line 270) | AES_RETURN aes_init(void)
FILE: libs/minizip/source/aes/brg_types.h
type uint_8t (line 55) | typedef unsigned char uint_8t;
type uint_16t (line 64) | typedef unsigned short uint_16t;
type uint_32t (line 74) | typedef unsigned int uint_32t;
type uint_32t (line 77) | typedef unsigned long uint_32t;
type uint_64t (line 89) | typedef unsigned __int64 uint_64t;
type uint_64t (line 93) | typedef unsigned __int64 uint_64t;
type uint_64t (line 97) | typedef unsigned long long uint_64t;
type uint_64t (line 101) | typedef unsigned int long long uint_64t;
type uint_64t (line 106) | typedef unsigned int uint_64t;
type uint_64t (line 112) | typedef unsigned long uint_64t;
type uint_64t (line 118) | typedef unsigned long long uint_64t;
type uint_64t (line 124) | typedef unsigned long long uint_64t;
FILE: libs/minizip/source/aes/entropy.c
function entropy_fun (line 14) | int entropy_fun(unsigned char buf[], unsigned int len)
function entropy_fun (line 38) | int entropy_fun(unsigned char buf[], unsigned int len)
FILE: libs/minizip/source/aes/fileenc.c
function encr_data (line 52) | static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_...
function fcrypt_init (line 73) | int fcrypt_init(
function fcrypt_encrypt (line 119) | void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_...
function fcrypt_decrypt (line 127) | void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_...
function fcrypt_end (line 135) | int fcrypt_end(unsigned char mac[], fcrypt_ctx cx[1])
FILE: libs/minizip/source/aes/fileenc.h
type fcrypt_ctx (line 84) | typedef struct
FILE: libs/minizip/source/aes/hmac.c
function hmac_sha_begin (line 44) | void hmac_sha_begin(hmac_ctx cx[1])
function hmac_sha_key (line 50) | int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_...
function hmac_sha_data (line 74) | void hmac_sha_data(const unsigned char data[], unsigned long data_len, h...
function hmac_sha_end (line 106) | void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx c...
function hmac_sha (line 132) | void hmac_sha(const unsigned char key[], unsigned long key_len,
FILE: libs/minizip/source/aes/hmac.h
type hmac_ctx (line 81) | typedef struct
FILE: libs/minizip/source/aes/prng.c
function prng_mix (line 52) | static void prng_mix(unsigned char buf[])
function update_pool (line 81) | static void update_pool(prng_ctx ctx[1])
function prng_init (line 100) | void prng_init(prng_entropy_fn fun, prng_ctx ctx[1])
function prng_rand (line 122) | void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx...
function prng_end (line 146) | void prng_end(prng_ctx ctx[1])
FILE: libs/minizip/source/aes/prng.h
type prng_ctx (line 62) | typedef struct
FILE: libs/minizip/source/aes/pwd2key.c
function derive_key (line 44) | void derive_key(const unsigned char pwd[], /* the PASSWORD */
function main (line 165) | int main()
FILE: libs/minizip/source/aes/sha1.c
function VOID_RETURN (line 116) | VOID_RETURN sha1_compile(sha1_ctx ctx[1])
function VOID_RETURN (line 172) | VOID_RETURN sha1_begin(sha1_ctx ctx[1])
function VOID_RETURN (line 185) | VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha...
function VOID_RETURN (line 206) | VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1])
function VOID_RETURN (line 250) | VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsig...
FILE: libs/minizip/source/aes/sha1.h
type sha1_ctx (line 49) | typedef struct
FILE: libs/minizip/source/ioapi.c
function voidpf (line 45) | voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*...
function call_zseek64 (line 59) | long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filest...
function ZPOS64_T (line 70) | ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf fi...
function fill_zlib_filefunc64_32_def_from_filefunc32 (line 81) | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def*...
type FILE_IOPOSIX (line 107) | typedef struct
function voidpf (line 114) | static voidpf file_build_ioposix(FILE *file, const char *filename)
function voidpf (line 127) | static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* file...
function voidpf (line 146) | static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* fi...
function voidpf (line 165) | static voidpf ZCALLBACK fopendisk64_file_func (voidpf opaque, voidpf str...
function voidpf (line 190) | static voidpf ZCALLBACK fopendisk_file_func (voidpf opaque, voidpf strea...
function uLong (line 215) | static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, vo...
function uLong (line 226) | static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, c...
function ftell_file_func (line 237) | static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
function ZPOS64_T (line 248) | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
function fseek_file_func (line 259) | static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLo...
function fseek64_file_func (line 288) | static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, Z...
function fclose_file_func (line 320) | static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
function ferror_file_func (line 334) | static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
function fill_fopen_filefunc (line 345) | void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
function fill_fopen64_filefunc (line 358) | void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
FILE: libs/minizip/source/ioapi_buf.c
type ourstream_t (line 53) | typedef struct ourstream_s {
function print_buf_internal (line 74) | void print_buf_internal(voidpf opaque, voidpf stream, char *format, ...)
function voidpf (line 84) | voidpf fopen_buf_internal_func (opaque, stream, number_disk, mode)
function voidpf (line 102) | voidpf ZCALLBACK fopen_buf_func (opaque, filename, mode)
function voidpf (line 112) | voidpf ZCALLBACK fopen64_buf_func (opaque, filename, mode)
function voidpf (line 122) | voidpf ZCALLBACK fopendisk_buf_func (opaque, stream_cd, number_disk, mode)
function voidpf (line 134) | voidpf ZCALLBACK fopendisk64_buf_func (opaque, stream_cd, number_disk, m...
function fflush_buf (line 147) | long fflush_buf (opaque, stream)
function uLong (line 181) | uLong ZCALLBACK fread_buf_func (opaque, stream, buf, size)
function uLong (line 247) | uLong ZCALLBACK fwrite_buf_func (opaque, stream, buf, size)
function ZPOS64_T (line 308) | ZPOS64_T ftell_buf_internal_func (opaque, stream, position)
function ftell_buf_func (line 323) | long ZCALLBACK ftell_buf_func (opaque, stream)
function ZPOS64_T (line 333) | ZPOS64_T ZCALLBACK ftell64_buf_func (opaque, stream)
function fseek_buf_internal_func (line 343) | int fseek_buf_internal_func (opaque, stream, offset, origin)
function fseek_buf_func (line 419) | long ZCALLBACK fseek_buf_func (opaque, stream, offset, origin)
function fseek64_buf_func (line 436) | long ZCALLBACK fseek64_buf_func (opaque, stream, offset, origin)
function fclose_buf_func (line 453) | int ZCALLBACK fclose_buf_func (opaque, stream)
function ferror_buf_func (line 474) | int ZCALLBACK ferror_buf_func (opaque, stream)
function fill_buffer_filefunc (line 486) | void fill_buffer_filefunc (pzlib_filefunc_def, ourbuf)
function fill_buffer_filefunc64 (line 501) | void fill_buffer_filefunc64 (pzlib_filefunc_def, ourbuf)
FILE: libs/minizip/source/ioapi_mem.c
function voidpf (line 35) | voidpf ZCALLBACK fopen_mem_func (opaque, filename, mode)
function voidpf (line 62) | voidpf ZCALLBACK fopendisk_mem_func (opaque, stream, number_disk, mode)
function uLong (line 72) | uLong ZCALLBACK fread_mem_func (opaque, stream, buf, size)
function uLong (line 90) | uLong ZCALLBACK fwrite_mem_func (opaque, stream, buf, size)
function ftell_mem_func (line 126) | long ZCALLBACK ftell_mem_func (opaque, stream)
function fseek_mem_func (line 134) | long ZCALLBACK fseek_mem_func (opaque, stream, offset, origin)
function fclose_mem_func (line 163) | int ZCALLBACK fclose_mem_func (opaque, stream)
function ferror_mem_func (line 171) | int ZCALLBACK ferror_mem_func (opaque, stream)
function fill_memory_filefunc (line 179) | void fill_memory_filefunc (pzlib_filefunc_def, ourmem)
FILE: libs/minizip/source/tools.cpp
type zipper (line 21) | namespace zipper {
function getFileCrc (line 26) | void getFileCrc(std::istream& input_stream, std::vector<char>& buff, u...
function isLargeFile (line 47) | bool isLargeFile(std::istream& input_stream)
function checkFileExists (line 57) | bool checkFileExists(const std::string& filename)
function makedir (line 62) | bool makedir(const std::string& newdir)
function removeFolder (line 67) | void removeFolder(const std::string& foldername)
function isDirectory (line 84) | bool isDirectory(const std::string& path)
function parentDirectory (line 89) | std::string parentDirectory(const std::string& filepath)
function currentPath (line 94) | std::string currentPath()
function filesFromDirectory (line 104) | std::vector<std::string> filesFromDirectory(const std::string& path)
function fileNameFromPath (line 140) | std::string fileNameFromPath(const std::string& fullPath)
FILE: libs/minizip/source/unzip.c
type unz_file_info64_internal (line 94) | typedef struct unz_file_info64_internal_s
type file_in_zip64_read_info_s (line 106) | typedef struct
type unz64_s (line 140) | typedef struct
function local (line 169) | local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
function local (line 192) | local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefun...
function local (line 207) | local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filef...
function local (line 227) | local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefu...
function local (line 253) | local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_file...
function local (line 292) | local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def*...
function local (line 354) | local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_de...
function local (line 390) | local unzFile unzOpenInternal(const void *path, zlib_filefunc64_32_def* ...
function unzFile (line 550) | extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def* pzl...
function unzFile (line 561) | extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def...
function unzFile (line 574) | extern unzFile ZEXPORT unzOpen(const char *path)
function unzFile (line 579) | extern unzFile ZEXPORT unzOpen64(const void *path)
function unzClose (line 584) | extern int ZEXPORT unzClose(unzFile file)
function local (line 607) | local int unzGoToNextDisk(unzFile file)
function unzGetGlobalInfo (line 651) | extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglob...
function unzGetGlobalInfo64 (line 664) | extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* p...
function unzGetGlobalComment (line 674) | extern int ZEXPORT unzGetGlobalComment(unzFile file, char *comment, uLon...
function local (line 701) | local int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_i...
function unzGetCurrentFileInfo (line 959) | extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info * p...
function unzGetCurrentFileInfo64 (line 994) | extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64...
function local (line 1004) | local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* p...
function unzOpenCurrentFile3 (line 1090) | extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, int* l...
function unzOpenCurrentFile (line 1293) | extern int ZEXPORT unzOpenCurrentFile(unzFile file)
function unzOpenCurrentFilePassword (line 1298) | extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* ...
function unzOpenCurrentFile2 (line 1303) | extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* l...
function unzReadCurrentFile (line 1315) | extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned ...
function ZPOS64_T (line 1533) | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file)
function unzGetLocalExtrafield (line 1546) | extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsign...
function unzGoToFirstFile2 (line 1643) | extern int ZEXPORT unzGoToFirstFile2(unzFile file, unz_file_info64 *pfil...
function unzGoToFirstFile (line 1661) | extern int ZEXPORT unzGoToFirstFile(unzFile file)
function unzGoToNextFile2 (line 1666) | extern int ZEXPORT unzGoToNextFile2(unzFile file, unz_file_info64 *pfile...
function unzGoToNextFile (line 1691) | extern int ZEXPORT unzGoToNextFile(unzFile file)
function unzLocateFile (line 1696) | extern int ZEXPORT unzLocateFile(unzFile file, const char *filename, unz...
function unzGetFilePos (line 1741) | extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos)
function unzGoToFilePos (line 1753) | extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos)
function unzGetFilePos64 (line 1764) | extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
function unzGoToFilePos64 (line 1780) | extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* ...
function uLong (line 1800) | extern uLong ZEXPORT unzGetOffset(unzFile file)
function ZPOS64_T (line 1810) | extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
function unzSetOffset (line 1825) | extern int ZEXPORT unzSetOffset(unzFile file, uLong pos)
function unzSetOffset64 (line 1830) | extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
function z_off_t (line 1846) | extern z_off_t ZEXPORT unztell(unzFile file)
function ZPOS64_T (line 1859) | extern ZPOS64_T ZEXPORT unztell64(unzFile file)
function unzeof (line 1875) | extern int ZEXPORT unzeof(unzFile file)
FILE: libs/minizip/source/unzipper.cpp
type zipper (line 10) | namespace zipper {
type Unzipper::Impl (line 12) | struct Unzipper::Impl
method initMemory (line 21) | bool initMemory(zlib_filefunc_def& filefunc)
method locateEntry (line 27) | bool locateEntry(const std::string& name)
method ZipEntry (line 32) | ZipEntry currentEntryInfo()
method iterEntries (line 48) | void iterEntries(std::function<void(ZipEntry&)> callback)
method getEntries (line 73) | void getEntries(std::vector<ZipEntry>& entries)
method extractCurrentEntry (line 100) | bool extractCurrentEntry(ZipEntry& entryinfo, int (extractStrategy)(...
method extractCurrentEntryToFile (line 120) | bool extractCurrentEntryToFile(ZipEntry& entryinfo, const std::strin...
method extractCurrentEntryToStream (line 144) | bool extractCurrentEntryToStream(ZipEntry& entryinfo, std::ostream& ...
method extractCurrentEntryToMemory (line 168) | bool extractCurrentEntryToMemory(ZipEntry& entryinfo, std::vector<un...
method changeFileDate (line 192) | void changeFileDate(const std::string& filename, uLong dosdate, tm_u...
method extractToFile (line 230) | int extractToFile(const std::string& filename, ZipEntry& info)
method extractToStream (line 259) | int extractToStream(std::ostream& stream, ZipEntry& info)
method extractToMemory (line 296) | int extractToMemory(std::vector<unsigned char>& outvec, ZipEntry& info)
method Impl (line 330) | Impl(Unzipper& outer) : m_outer(outer), m_zipmem(), m_filefunc()
method close (line 339) | void close()
method initFile (line 345) | bool initFile(const std::string& filename)
method initWithStream (line 357) | bool initWithStream(std::istream& stream)
method initWithVector (line 374) | bool initWithVector(std::vector<unsigned char>& buffer)
method entries (line 387) | std::vector<ZipEntry> entries()
method extractAll (line 396) | bool extractAll(const std::string& destination, const std::map<std::...
method extractEntry (line 419) | bool extractEntry(const std::string& name, const std::string& destin...
method extractEntryToStream (line 434) | bool extractEntryToStream(const std::string& name, std::ostream& str...
method extractEntryToMemory (line 447) | bool extractEntryToMemory(const std::string& name, std::vector<unsig...
FILE: libs/minizip/source/zip.c
type linkedlist_datablock_internal (line 110) | typedef struct linkedlist_datablock_internal_s
type linkedlist_data (line 119) | typedef struct linkedlist_data_s
type curfile64_info (line 125) | typedef struct
type zip64_internal (line 164) | typedef struct
function local (line 187) | local linkedlist_datablock_internal* allocate_new_datablock()
function local (line 204) | local void free_datablock(linkedlist_datablock_internal* ldi)
function local (line 216) | local void init_linkedlist(linkedlist_data* ll)
function local (line 223) | local void free_linkedlist(linkedlist_data* ll)
function local (line 231) | local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uL...
function local (line 283) | local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
function local (line 319) | local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filef...
function local (line 345) | local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbB...
function local (line 365) | local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefun...
function local (line 380) | local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filef...
function local (line 400) | local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefu...
function local (line 426) | local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_file...
function local (line 466) | local int zipGetDiskSizeAvailable(zipFile file, ZPOS64_T *size_available)
function local (line 480) | local int zipGoToSpecificDisk(zipFile file, int number_disk, int open_ex...
function local (line 504) | local int zipGoToFirstDisk(zipFile file)
function local (line 528) | local int zipGoToNextDisk(zipFile file)
function local (line 564) | local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def*...
function local (line 626) | local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_de...
function zipFile (line 662) | extern zipFile ZEXPORT zipOpen4(const void *pathname, int append, ZPOS64...
function zipFile (line 908) | extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcha...
function zipFile (line 920) | extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zip...
function zipFile (line 934) | extern zipFile ZEXPORT zipOpen3(const char *pathname, int append, ZPOS64...
function zipFile (line 946) | extern zipFile ZEXPORT zipOpen3_64(const void *pathname, int append, ZPO...
function zipFile (line 960) | extern zipFile ZEXPORT zipOpen(const char* pathname, int append)
function zipFile (line 965) | extern zipFile ZEXPORT zipOpen64(const void* pathname, int append)
function zipOpenNewFileInZip4_64 (line 970) | extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* fil...
function zipOpenNewFileInZip4 (line 1317) | extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filena...
function zipOpenNewFileInZip3 (line 1327) | extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filena...
function zipOpenNewFileInZip3_64 (line 1337) | extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* fil...
function zipOpenNewFileInZip2 (line 1347) | extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filena...
function zipOpenNewFileInZip2_64 (line 1356) | extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* fil...
function zipOpenNewFileInZip64 (line 1365) | extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filen...
function zipOpenNewFileInZip (line 1374) | extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filenam...
function local (line 1385) | local int zip64FlushWriteBuffer(zip64_internal* zi)
function zipWriteInFileInZip (line 1470) | extern int ZEXPORT zipWriteInFileInZip(zipFile file,const void* buf,unsi...
function zipCloseFileInZipRaw (line 1565) | extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed...
function zipCloseFileInZipRaw64 (line 1570) | extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompr...
function zipCloseFileInZip (line 1843) | extern int ZEXPORT zipCloseFileInZip(zipFile file)
function zipClose (line 1848) | extern int ZEXPORT zipClose(zipFile file, const char* global_comment)
FILE: libs/minizip/source/zipper.cpp
type zipper (line 9) | namespace zipper {
type Zipper::Impl (line 11) | struct Zipper::Impl
method Impl (line 18) | Impl(Zipper& outer) : m_outer(outer), m_zipmem(), m_filefunc()
method initFile (line 24) | bool initFile(const std::string& filename)
method initWithStream (line 49) | bool initWithStream(std::iostream& stream)
method initWithVector (line 68) | bool initWithVector(std::vector<unsigned char>& buffer)
method initMemory (line 84) | bool initMemory(int mode, zlib_filefunc_def& filefunc)
method add (line 90) | bool add(std::istream& input_stream, const std::string& nameInZip, c...
method close (line 169) | void close()
FILE: source/download.cpp
function WriteMemoryCallback (line 21) | static size_t WriteMemoryCallback(void *contents, size_t size, size_t nu...
function download_progress (line 38) | int download_progress(void *p, double dltotal, double dlnow, double ulto...
function downloadFile (line 55) | bool downloadFile(const char *url, const char *output, int api)
type MemoryStruct (line 110) | struct MemoryStruct {
function WriteMemoryCallback2 (line 115) | static size_t WriteMemoryCallback2(void *contents, size_t size, size_t n...
function fetchVersion (line 136) | std::string fetchVersion(const char *url, const char *range){
FILE: source/extract.cpp
function getInstalledTitles (line 3) | std::vector<std::string> getInstalledTitles(std::vector<NcmStorageId> st...
function getInstalledTitlesNs (line 27) | std::vector<Title> getInstalledTitlesNs(){
function formatApplicationId (line 117) | std::string formatApplicationId(u64 ApplicationId){
function excludeTitles (line 123) | std::vector<Title> excludeTitles(const char* path, std::vector<Title> li...
function caselessCompare (line 176) | bool caselessCompare (const std::string& a, const std::string& b){
function extractCheats (line 180) | int extractCheats(std::string zipPath, std::vector<Title> titles, int cf...
function removeCheats (line 293) | int removeCheats(int cfw){
FILE: source/main.cpp
function initServices (line 22) | void initServices(){
function exitServices (line 29) | void exitServices(){
function readVersion (line 36) | std::string readVersion(std::string path){
function saveVersion (line 47) | void saveVersion(std::string path, std::string version){
function isServiceRunning (line 54) | bool isServiceRunning(const char *serviceName) {
function CFW (line 67) | CFW getCFW(){
function run (line 73) | bool run(){
function cleanUp (line 157) | void cleanUp(){
function viewTitles (line 164) | void viewTitles() {
function viewHeader (line 182) | void viewHeader() {
function viewMain (line 189) | void viewMain() {
function clearConsole (line 204) | void clearConsole() {
function main (line 210) | int main(int argc, char* argv[])
FILE: source/titles.cpp
function writeTitlesToFile (line 9) | void writeTitlesToFile(std::vector<Title> titles) {
function readTitlesFromFile (line 25) | std::vector<Title> readTitlesFromFile() {
function outputUpdatedTitles (line 50) | void outputUpdatedTitles() {
function printTitles (line 66) | void printTitles(std::vector<Title> titles) {
Condensed preview — 55 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (550K chars).
[
{
"path": ".gitignore",
"chars": 93,
"preview": "build/\r\ncheatsUploader/\r\n.vscode/\r\nBACKUP/\r\ntest/\r\n*.elf\r\n*.nrp\r\n*.nacp\r\n*.nro\r\n*.zip\r\n*.ai\r\n"
},
{
"path": "LICENSE",
"chars": 35823,
"preview": " GNU GENERAL PUBLIC LICENSE\r\n Version 3, 29 June 2007\r\n\r\n Copyright (C) 2007 Fr"
},
{
"path": "Makefile",
"chars": 8110,
"preview": "#---------------------------------------------------------------------------------\r\n.SUFFIXES:\r\n#-----------------------"
},
{
"path": "README.md",
"chars": 1957,
"preview": "# NOT SUPPORTED ANYMORE, USE THIS INSTEAD: https://github.com/HamletDuFromage/AIO-switch-updater\r\nWhile this app will st"
},
{
"path": "include/download.hpp",
"chars": 495,
"preview": "#ifndef _DOWNLOAD_H_\r\n#define _DOWNLOAD_H_\r\n\r\n#define ON 1\r\n#define OFF 0\r\n\r\n\r\n#include <stdio."
},
{
"path": "include/extract.hpp",
"chars": 1212,
"preview": "#ifndef EXTRACT_HPP\r\n#define EXTRACT_HPP\r\n\r\n#include <string>\r\n#include <vector>\r\n#include <switch.h>\r\n#include <sstream"
},
{
"path": "include/title.h",
"chars": 454,
"preview": "#include <iostream>\r\n\r\n#ifndef TITLE\r\n#define TITLE\r\n\r\n/* Defines the Title structure\r\n id: the title ID\r\n name: t"
},
{
"path": "include/titles.hpp",
"chars": 448,
"preview": "#ifndef TITLES_HPP\r\n#define TITLES_HPP\r\n\r\n#define UPDATED_TITLES_PATH \"/config/cheats-updater/updated.dat\"\r\n\r\n#include <"
},
{
"path": "libs/minizip/include/CDirEntry.h",
"chars": 7029,
"preview": "// Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual\r\n// Properties, Inc., EML Research, gGmbH, University "
},
{
"path": "libs/minizip/include/crypt.h",
"chars": 5002,
"preview": "/* crypt.h -- base code for traditional PKWARE encryption\r\n Version 1.01e, February 12th, 2005\r\n\r\n Copyright (C) 199"
},
{
"path": "libs/minizip/include/defs.h",
"chars": 1307,
"preview": "#pragma once\r\n\r\nextern \"C\"\r\n{\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <string.h>\r\n#include <time.h>\r\n#include"
},
{
"path": "libs/minizip/include/ioapi.h",
"chars": 7125,
"preview": "/* ioapi.h -- IO base function header for compress/uncompress .zip\r\n part of the MiniZip project\r\n\r\n Copyright (C) 1"
},
{
"path": "libs/minizip/include/ioapi_buf.h",
"chars": 2018,
"preview": "/* ioapi_buf.h -- IO base function header for compress/uncompress .zip\r\n files using zlib + zip or unzip API\r\n\r\n Thi"
},
{
"path": "libs/minizip/include/ioapi_mem.h",
"chars": 2088,
"preview": "/* ioapi_mem.h -- IO base function header for compress/uncompress .zip\r\n files using zlib + zip or unzip API\r\n\r\n Thi"
},
{
"path": "libs/minizip/include/iowin32.h",
"chars": 951,
"preview": "/* iowin32.h -- IO base function header for compress/uncompress .zip\r\n Version 1.1, February 14h, 2010\r\n part of the"
},
{
"path": "libs/minizip/include/tools.h",
"chars": 671,
"preview": "#pragma once\r\n\r\n#include <string>\r\n#include <vector>\r\n#include <istream>\r\n\r\n\r\nnamespace zipper \r\n{\r\n void getFileCrc(st"
},
{
"path": "libs/minizip/include/unzip.h",
"chars": 14536,
"preview": "/* unzip.h -- IO for uncompress .zip files using zlib\r\n Version 1.1, February 14h, 2010\r\n part of the MiniZip projec"
},
{
"path": "libs/minizip/include/unzipper.h",
"chars": 2432,
"preview": "#pragma once\r\n\r\n#include <vector>\r\n#include <istream>\r\n#include <ostream>\r\n#include <sstream>\r\n#include <string>\r\n#inclu"
},
{
"path": "libs/minizip/include/zip.h",
"chars": 9375,
"preview": "/* zip.h -- IO on .zip files using zlib\r\n Version 1.1, February 14h, 2010\r\n part of the MiniZip project\r\n\r\n Copyri"
},
{
"path": "libs/minizip/include/zipper.h",
"chars": 1090,
"preview": "#pragma once\r\n\r\n#include <iostream>\r\n#include <string>\r\n#include <sstream>\r\n#include <vector>\r\n#include <memory>\r\n\r\nname"
},
{
"path": "libs/minizip/source/CDirEntry.cpp",
"chars": 14363,
"preview": "// Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual\r\n// Properties, Inc., University of Heidelberg,"
},
{
"path": "libs/minizip/source/aes/Makefile",
"chars": 338,
"preview": "CC=cc\r\nCFLAGS=-O -DHAVE_AES\r\nOBJS=aescrypt.o aeskey.o aestab.o entropy.o fileenc.o hmac.o prng.o pwd2key.o sha1.o\r\nARFLA"
},
{
"path": "libs/minizip/source/aes/aes.h",
"chars": 7267,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/aes_via_ace.h",
"chars": 17409,
"preview": "/*\r\nCopyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.\r\n\r\nThe redistribution and use of this so"
},
{
"path": "libs/minizip/source/aes/aescrypt.c",
"chars": 10139,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/aeskey.c",
"chars": 16384,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/aesopt.h",
"chars": 26845,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/aestab.c",
"chars": 15633,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/aestab.h",
"chars": 5332,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/brg_endian.h",
"chars": 5290,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/brg_types.h",
"chars": 8194,
"preview": "/*\r\n---------------------------------------------------------------------------\r\nCopyright (c) 1998-2010, Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/entropy.c",
"chars": 1067,
"preview": "#ifdef _WIN32\r\n#include <windows.h>\r\n#else\r\n#include <sys/stat.h>\r\n#include <fcntl.h>\r\n#endif\r\n\r\n#if defined(__cplusplus"
},
{
"path": "libs/minizip/source/aes/entropy.h",
"chars": 209,
"preview": "\r\n#ifndef _ENTROPY_FUN_H\r\n#define _ENTROPY_FUN_H\r\n\r\n#if defined(__cplusplus)\r\nextern \"C\"\r\n{\r\n#endif\r\n\r\nint entropy_fun(u"
},
{
"path": "libs/minizip/source/aes/fileenc.c",
"chars": 4905,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman "
},
{
"path": "libs/minizip/source/aes/fileenc.h",
"chars": 4357,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman "
},
{
"path": "libs/minizip/source/aes/hmac.c",
"chars": 5247,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/hmac.h",
"chars": 3043,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/prng.c",
"chars": 5340,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman "
},
{
"path": "libs/minizip/source/aes/prng.h",
"chars": 3098,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman "
},
{
"path": "libs/minizip/source/aes/pwd2key.c",
"chars": 6211,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/pwd2key.h",
"chars": 2053,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/sha1.c",
"chars": 8711,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/aes/sha1.h",
"chars": 2430,
"preview": "/*\r\n ---------------------------------------------------------------------------\r\n Copyright (c) 2002, Dr Brian Gladman,"
},
{
"path": "libs/minizip/source/ioapi.c",
"chars": 12714,
"preview": "/* ioapi.h -- IO base function header for compress/uncompress .zip\r\n part of the MiniZip project\r\n\r\n Copyright (C) 1"
},
{
"path": "libs/minizip/source/ioapi_buf.c",
"chars": 17941,
"preview": "/* ioapi_buf.h -- IO base function header for compress/uncompress .zip\r\n files using zlib + zip or unzip API\r\n\r\n Thi"
},
{
"path": "libs/minizip/source/ioapi_mem.c",
"chars": 5051,
"preview": "/* ioapi_mem.h -- IO base function header for compress/uncompress .zip\r\n files using zlib + zip or unzip API\r\n\r\n Thi"
},
{
"path": "libs/minizip/source/tools.cpp",
"chars": 3302,
"preview": "#include \"tools.h\"\r\n#include \"defs.h\"\r\n#include <algorithm>\r\n#include <iterator>\r\n\r\n#include <CDirEntry.h>\r\n\r\n#include <"
},
{
"path": "libs/minizip/source/unzip.c",
"chars": 71634,
"preview": "/* unzip.c -- IO for uncompress .zip files using zlib\r\n Version 1.1, February 14h, 2010\r\n part of the MiniZip projec"
},
{
"path": "libs/minizip/source/unzipper.cpp",
"chars": 14737,
"preview": "#include \"unzipper.h\"\r\n#include \"defs.h\"\r\n#include \"tools.h\"\r\n\r\n#include <functional>\r\n#include <exception>\r\n#include <f"
},
{
"path": "libs/minizip/source/zip.c",
"chars": 75879,
"preview": "/* zip.c -- IO on .zip files using zlib\r\n Version 1.1, February 14h, 2010\r\n part of the MiniZip project\r\n\r\n Copyri"
},
{
"path": "libs/minizip/source/zipper.cpp",
"chars": 7935,
"preview": "#include \"zipper.h\"\r\n#include \"defs.h\"\r\n#include \"tools.h\"\r\n#include \"CDirEntry.h\"\r\n\r\n#include <fstream>\r\n#include <stde"
},
{
"path": "source/download.cpp",
"chars": 5744,
"preview": "\r\n#include \"download.hpp\"\r\n\r\n#define API_AGENT \"HamletDuFromage\"\r\n#define _1MiB 0x100000\r\n\r\ntypedef struct\r\n"
},
{
"path": "source/extract.cpp",
"chars": 12009,
"preview": "#include \"extract.hpp\"\r\n\r\nstd::vector<std::string> getInstalledTitles(std::vector<NcmStorageId> storageId){\r\n std::ve"
},
{
"path": "source/main.cpp",
"chars": 9903,
"preview": "#include <iostream>\r\n#include <tuple>\r\n#include <fstream>\r\n#include <filesystem>\r\n\r\n#include \"unzipper.h\"\r\n#include \"tit"
},
{
"path": "source/titles.cpp",
"chars": 2353,
"preview": "#include \"titles.hpp\"\r\n\r\n\r\n/**\r\n * writeTitlesToFile\r\n * Writes the input vector to the updated.dat file in config\r\n * S"
}
]
About this extraction
This page contains the full source code of the HamletDuFromage/switch-cheats-updater GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 55 files (503.2 KB), approximately 143.6k tokens, and a symbol index with 322 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.