File libtatsu-1.0.4+8git.20241227.obscpio of Package libtatsu
07070100000000000041ED000000000000000000000003676DFA4F00000000000000000000000000000000000000000000002500000000libtatsu-1.0.4+8git.20241227/.github07070100000001000041ED000000000000000000000002676DFA4F00000000000000000000000000000000000000000000002F00000000libtatsu-1.0.4+8git.20241227/.github/workflows07070100000002000081A4000000000000000000000001676DFA4F00001D7A000000000000000000000000000000000000003900000000libtatsu-1.0.4+8git.20241227/.github/workflows/build.ymlname: build
on:
push:
pull_request:
schedule:
- cron: '0 0 1 * *'
jobs:
build-linux-ubuntu:
runs-on: ubuntu-latest
steps:
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
- name: prepare environment
run: |
echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV
- name: fetch libplist
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
name: libplist-latest_${{env.target_triplet}}
repo: libimobiledevice/libplist
- name: install external dependencies
run: |
mkdir extract
for I in *.tar; do
tar -C extract -xvf $I
done
rm -rf extract/lib
sudo cp -r extract/* /
sudo ldconfig
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: autogen
run: ./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- name: make
run: make
- name: make install
run: sudo make install
- name: prepare artifact
run: |
mkdir -p dest
DESTDIR=`pwd`/dest make install
tar -C dest -cf libtatsu.tar usr
- name: publish artifact
uses: actions/upload-artifact@v4
with:
name: libtatsu-latest_${{env.target_triplet}}
path: libtatsu.tar
build-macOS:
runs-on: macOS-latest
steps:
- name: install dependencies
run: |
if test -x "`which port`"; then
sudo port install libtool autoconf automake pkgconfig
else
brew install libtool autoconf automake pkgconfig
fi
shell: bash
- name: fetch libplist
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
name: libplist-latest_macOS
repo: libimobiledevice/libplist
- name: install external dependencies
run: |
mkdir extract
for I in *.tar; do
tar -C extract -xvf $I
done
sudo cp -r extract/* /
- uses: actions/checkout@v4
- name: install additional requirements
run: |
SDKDIR=`xcrun --sdk macosx --show-sdk-path 2>/dev/null`
echo "SDKDIR=$SDKDIR" >> $GITHUB_ENV
TESTARCHS="arm64 x86_64"
USEARCHS=
for ARCH in $TESTARCHS; do
if echo "int main(int argc, char **argv) { return 0; }" |clang -arch $ARCH -o /dev/null -isysroot $SDKDIR -x c - 2>/dev/null; then
USEARCHS="$USEARCHS -arch $ARCH"
fi
done
export CFLAGS="$USEARCHS -isysroot $SDKDIR"
echo "Using CFLAGS: $CFLAGS"
echo "BUILD_CFLAGS=$CFLAGS" >> $GITHUB_ENV
mkdir -p lib
curl -o lib/libcrypto.35.tbd -Ls \
https://gist.github.com/nikias/94c99fd145a75a5104415e5117b0cafa/raw/5209dfbff5a871a14272afe4794e76eb4cf6f062/libcrypto.35.tbd
curl -o lib/libssl.35.tbd -Ls \
https://gist.github.com/nikias/94c99fd145a75a5104415e5117b0cafa/raw/5209dfbff5a871a14272afe4794e76eb4cf6f062/libssl.35.tbd
LIBRESSL_VER=2.2.7
FILENAME="libressl-$LIBRESSL_VER.tar.gz"
curl -o $FILENAME -Ls "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$FILENAME"
mkdir -p deps
tar -C deps -xzf $FILENAME
echo "LIBRESSL_CFLAGS=-I`pwd`/deps/libressl-$LIBRESSL_VER/include" >> $GITHUB_ENV
echo "LIBRESSL_LIBS=-Xlinker `pwd`/lib/libssl.35.tbd -Xlinker `pwd`/lib/libcrypto.35.tbd" >> $GITHUB_ENV
FILENAME="libzip-static.tar.bz2"
curl -o $FILENAME.b64 -Ls "https://gist.github.com/nikias/3da15d03120382f87b44029cd8495a02/raw/99cd8138fed99e8f6530b6f179f787342c698e1f/libzip-1.7.1_static_macOS.tar.bz2"
base64 -D < $FILENAME.b64 > $FILENAME
tar -C deps -xjf $FILENAME
echo "LIBZIP_CFLAGS=-I`pwd`/deps/include" >> $GITHUB_ENV
echo "LIBZIP_LIBS=`pwd`/deps/lib/libzip.a -Xlinker ${SDKDIR}/usr/lib/libbz2.tbd -Xlinker ${SDKDIR}/usr/lib/liblzma.tbd -lz" >> $GITHUB_ENV
- name: autogen
run: |
export CFLAGS="${{env.BUILD_CFLAGS}} -Wno-nullability-completeness -Wno-expansion-to-defined"
echo "Using CFLAGS: $CFLAGS"
./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \
libcurl_CFLAGS="-I${{env.SDKDIR}}/usr/include" libcurl_LIBS="-lcurl"
- name: make
run: make
- name: make install
run: sudo make install
- name: prepare artifact
run: |
mkdir -p dest
DESTDIR=`pwd`/dest make install
tar -C dest -cf libtatsu.tar usr
- name: publish artifact
uses: actions/upload-artifact@v4
with:
name: libtatsu-latest_macOS
path: libtatsu.tar
build-windows:
runs-on: windows-2019
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
include: [
{ msystem: MINGW64, arch: x86_64 },
{ msystem: MINGW32, arch: i686 }
]
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
release: false
update: false
install: >-
base-devel
git
mingw-w64-${{ matrix.arch }}-gcc
make
libtool
autoconf
automake-wrapper
liblzma
- name: prepare environment
run: |
dest=`echo ${{ matrix.msystem }} |tr [:upper:] [:lower:]`
echo "dest=$dest" >> $GITHUB_ENV
echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV
- name: fetch libplist
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
name: libplist-latest_${{ matrix.arch }}-${{ env.dest }}
repo: libimobiledevice/libplist
- name: install external dependencies
run: |
mkdir extract
for I in *.tar; do
tar -C extract -xvf $I
done
cp -r extract/* /
- uses: actions/checkout@v4
- name: install additional requirements
run: |
mkdir deps
FILENAME="libcurl-8.1.0-static.tar.bz2"
curl -o $FILENAME.b64 -Ls "https://gist.github.com/nikias/6c397a0a2f4f4eafd91b81cccd22b761/raw/85216e60af6787f3b351291165eb91bd585ff09a/libcurl-8.1.0-static-${{matrix.arch}}-${{env.dest}}.tar.bz2"
base64 -d < $FILENAME.b64 > $FILENAME
tar -C deps -xjf $FILENAME
echo "LIBCURL_CFLAGS=-I`pwd`/deps/include -DCURL_STATICLIB" >> $GITHUB_ENV
echo "LIBCURL_LIBS=-Xlinker `pwd`/deps/lib/libcurl.a -Xlinker /${{env.dest}}/lib/libzstd.a -Xlinker /${{env.dest}}/lib/libz.a -Xlinker -lws2_32 -Xlinker -lcrypt32 -Xlinker -lwldap32 -Xlinker -lbcrypt -Xlinker -lssl -Xlinker -lcrypto" >> $GITHUB_ENV
- name: autogen
run: |
./autogen.sh CC=gcc CXX=g++ \
libcurl_CFLAGS="${{env.LIBCURL_CFLAGS}}" libcurl_LIBS="${{env.LIBCURL_LIBS}}"
- name: make
run: make
- name: make install
run: make install
- name: prepare artifact
run: |
mkdir -p dest
DESTDIR=`pwd`/dest make install
tar -C dest -cf libtatsu.tar ${{ env.dest }}
- name: publish artifact
uses: actions/upload-artifact@v4
with:
name: libtatsu-latest_${{ matrix.arch }}-${{ env.dest }}
path: libtatsu.tar
07070100000003000081A4000000000000000000000001676DFA4F0000021B000000000000000000000000000000000000002800000000libtatsu-1.0.4+8git.20241227/.gitignore# git-ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
*.[oa]
*~
*.po
*.lo
*.la
autom4te.cache/*
*.in
*/.deps/*
m4/*
*.swp
*.patch
aclocal.m4
config.h
config.log
config.sub
config.guess
config.status
configure
depcomp
install-sh
compile
main
ltmain.sh
missing
mkinstalldirs
libtool
*Makefile
py-compile
stamp-h1
src/.libs
src/libtatsu-1.0.pc
.idea/
.DS_Store
.vscode/
07070100000004000081A4000000000000000000000001676DFA4F00006742000000000000000000000000000000000000002500000000libtatsu-1.0.4+8git.20241227/COPYING GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser 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 Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey 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 library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
07070100000005000081A4000000000000000000000001676DFA4F00000143000000000000000000000000000000000000002900000000libtatsu-1.0.4+8git.20241227/Makefile.amAUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src include
EXTRA_DIST = \
README.md \
git-version-gen
dist-hook:
@if ! git diff --quiet; then echo "Uncommitted changes present; not releasing"; exit 1; fi
echo $(VERSION) > $(distdir)/.tarball-version
indent:
indent -kr -ut -ts4 -l120 src/*.c src/*.h
07070100000006000081A4000000000000000000000001676DFA4F00000283000000000000000000000000000000000000002200000000libtatsu-1.0.4+8git.20241227/NEWSVersion 1.0.4
~~~~~~~~~~~~~
Changes:
- Updated for iPhone 16 device family
Version 1.0.3
~~~~~~~~~~~~~
Fixes:
- Fix TSS request generation for non-img4 requests
Version 1.0.2
~~~~~~~~~~~~~
Bugfix release
Fixes:
- Revert strict 'Trusted' check and only bail out when not trusted and without RestoreRequestRules;
this caused TSS requests to be incomplete resulting in restore failures.
Changes:
- Abort if we get an unhandled status code, instead of retrying
- Print debug plist data in XML format
Version 1.0.1
~~~~~~~~~~~~~
Changes:
- tss: Only consider components that are 'Trusted'
Version 1.0.0
~~~~~~~~~~~~~
First release.
07070100000007000081A4000000000000000000000001676DFA4F00001E42000000000000000000000000000000000000002700000000libtatsu-1.0.4+8git.20241227/README.md# libtatsu
Library handling the communication with Apple's Tatsu Signing Server (TSS).

## Table of Contents
- [Features](#features)
- [Building](#building)
- [Prerequisites](#prerequisites)
- [Linux (Debian/Ubuntu based)](#linux-debianubuntu-based)
- [macOS](#macos)
- [Windows](#windows)
- [Configuring the source tree](#configuring-the-source-tree)
- [Building and installation](#building-and-installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [Links](#links)
- [License](#license)
- [Credits](#credits)
## Features
This library is part of the [libimobiledevice](https://github.com/libimobiledevice)
project. The main purpose of this library is to allow creating TSS request
payloads, sending them to Apple's TSS server, and retrieving and processing
the response.
The code was originally part of [idevicerestore](https://github.com/libimobiledevice/idevicerestore)
and has been split out to its own library, while obviously [idevicerestore](https://github.com/libimobiledevice/idevicerestore)
will remain the main consumer.
## Building
### Prerequisites
You need to have a working compiler (gcc/clang) and development environent
available. This project uses autotools for the build process, allowing to
have common build steps across different platforms.
Only the prerequisites differ and they are described in this section.
libtatsu requires [libplist](https://github.com/libimobiledevice/libplist)
**version 2.6.0** or later.
Check the [Building](https://github.com/libimobiledevice/libplist?tab=readme-ov-file#building)
section of the README on how to build it. Note that some platforms might have it as a package.
Also [libcurl](https://github.com/curl/curl) is required, but most platforms
already have it available as a package.
#### Linux (Debian/Ubuntu based)
* Install all required dependencies and build tools:
```shell
sudo apt-get install \
build-essential \
pkg-config \
checkinstall \
git \
autoconf \
automake \
libtool-bin \
libplist-dev \
libcurl4-openssl-dev
```
In case libplist-dev is not available, you can manually build and install it. See note above.
#### macOS
* Make sure the Xcode command line tools are installed. Then, use either [MacPorts](https://www.macports.org/)
or [Homebrew](https://brew.sh/) to install `automake`, `autoconf`, `libtool`, etc.
Using MacPorts:
```shell
sudo port install libtool autoconf automake pkgconfig
```
Using Homebrew:
```shell
brew install libtool autoconf automake pkg-config
```
For libcurl, it is recommended to use the system specific library:
```shell
export libcurl_CFLAGS="-I`xcrun --sdk macosx --show-sdk-path 2>/dev/null`/usr/include"
export libcurl_LIBS="-lcurl"
```
#### Windows
* Using [MSYS2](https://www.msys2.org/) is the official way of compiling this project on Windows. Download the MSYS2 installer
and follow the installation steps.
It is recommended to use the _MSYS2 MinGW 64-bit_ shell. Run it and make sure the required dependencies are installed:
```shell
pacman -S base-devel \
git \
mingw-w64-x86_64-gcc \
make \
libtool \
autoconf \
automake-wrapper \
pkg-config \
libcurl-devel
```
NOTE: You can use a different shell and different compiler according to your needs. Adapt the above command accordingly.
### Configuring the source tree
You can build the source code from a git checkout, or from a `.tar.bz2` release tarball from [Releases](https://github.com/libimobiledevice/libtatsu/releases).
Before we can build it, the source tree has to be configured for building. The steps depend on where you got the source from.
Since libtatsu depends on other packages, you should set the pkg-config environment variable `PKG_CONFIG_PATH`
accordingly. Make sure to use a path with the same prefix as the dependencies. If they are installed in `/usr/local` you would do
```shell
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
```
* **From git**
If you haven't done already, clone the actual project repository and change into the directory.
```shell
git clone https://github.com/libimobiledevice/libtatsu
cd libtatsu
```
Configure the source tree for building:
```shell
./autogen.sh
```
* **From release tarball (.tar.bz2)**
When using an official [release tarball](https://github.com/libimobiledevice/libtatsu/releases) (`libtatsu-x.y.z.tar.bz2`)
the procedure is slightly different.
Extract the tarball:
```shell
tar xjf libtatsu-x.y.z.tar.bz2
cd libtatsu-x.y.z
```
Configure the source tree for building:
```shell
./configure
```
Both `./configure` and `./autogen.sh` (which generates and calls `configure`) accept a few options, for example `--prefix` to allow
building for a different target folder. You can simply pass them like this:
```shell
./autogen.sh --prefix=/usr/local
```
or
```shell
./configure --prefix=/usr/local
```
Once the command is successful, the last few lines of output will look like this:
```
[...]
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
Configuration for libtatsu 1.0.0:
-------------------------------------------
Install prefix: .........: /usr/local
Now type 'make' to build libtatsu 1.0.0,
and then 'make install' for installation.
```
### Building and installation
If you followed all the steps successfully, and `autogen.sh` or `configure` did not print any errors,
you are ready to build the project. This is simply done with
```shell
make
```
If no errors are emitted you are ready for installation. Depending on whether
the current user has permissions to write to the destination directory or not,
you would either run
```shell
make install
```
_OR_
```shell
sudo make install
```
If you are on Linux, you want to run `sudo ldconfig` after installation to
make sure the installed libraries are made available.
## Usage
This library is directly used by idevicerestore and libimobiledevice, so there
is no need to do anything in particular. Feel free to use it in your project,
check the header files for available functions. A documentation might be added
later.
## Contributing
We welcome contributions from anyone and are grateful for every pull request!
If you'd like to contribute, please fork the `master` branch, change, commit and
send a pull request for review. Once approved it can be merged into the main
code base.
If you plan to contribute larger changes or a major refactoring, please create a
ticket first to discuss the idea upfront to ensure less effort for everyone.
Please make sure your contribution adheres to:
* Try to follow the code style of the project
* Commit messages should describe the change well without being too short
* Try to split larger changes into individual commits of a common domain
## Links
* Homepage: https://libimobiledevice.org/
* Repository: https://github.com/libimobiledevice/libtatsu.git
* Issue Tracker: https://github.com/libimobiledevice/libtatsu/issues
* Mailing List: https://lists.libimobiledevice.org/mailman/listinfo/libimobiledevice-devel
* Twitter: https://twitter.com/libimobiledev
## License
This library is licensed under the [GNU Lesser General Public License v2.1](https://www.gnu.org/licenses/lgpl-2.1.en.html),
also included in the repository in the `COPYING` file.
## Credits
Apple, iPhone, iPad, iPod, iPod Touch, Apple TV, Apple Watch, Mac, iOS,
iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc.
This project is an independent software library and has not been authorized,
sponsored, or otherwise approved by Apple Inc.
README Updated on: 2024-10-22
07070100000008000081ED000000000000000000000001676DFA4F0000016D000000000000000000000000000000000000002800000000libtatsu-1.0.4+8git.20241227/autogen.sh#!/bin/sh
olddir=`pwd`
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
(
cd "$srcdir"
gprefix=`which glibtoolize 2>&1 >/dev/null`
if [ $? -eq 0 ]; then
glibtoolize --force
else
libtoolize --force
fi
aclocal -I m4
autoheader
automake --add-missing
autoconf
cd "$olddir"
)
if [ -z "$NOCONFIGURE" ]; then
$srcdir/configure "$@"
fi
07070100000009000081A4000000000000000000000001676DFA4F00000CE5000000000000000000000000000000000000002A00000000libtatsu-1.0.4+8git.20241227/configure.ac# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([libtatsu], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libtatsu/issues], [], [https://github.com/libimobiledevice/libtatsu])
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
dnl libtool versioning
# +1 : 0 : +1 == adds new functions to the interface
# +1 : 0 : 0 == changes or removes functions (changes include both
# changes to the signature and the semantic)
# ? :+1 : ? == just internal changes
# CURRENT : REVISION : AGE
LIBTATSU_SO_VERSION=0:2:0
# Check if we have a version defined
if test -z $PACKAGE_VERSION; then
AC_MSG_ERROR([PACKAGE_VERSION is not defined. Make sure to configure a source tree checked out from git or that .tarball-version is present.])
fi
dnl Minimum package versions
LIBPLIST_VERSION=2.6.0
LIBCURL_VERSION=7.0
AC_SUBST(LIBTATSU_SO_VERSION)
AC_SUBST(LIBPLIST_VERSION)
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
# Checks for libraries.
PKG_CHECK_MODULES(libplist, libplist-2.0 >= $LIBPLIST_VERSION)
PKG_CHECK_MODULES(libcurl, libcurl >= $LIBCURL_VERSION)
# Checks for header files.
AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"])
if test "x$ac_cv_have_endian_h" = "xno"; then
AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian])
AC_DEFINE(__BIG_ENDIAN,4321,[big endian])
AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], [])
if test "x$ac_cv_c_bigendian" = "xyes"; then
AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order])
else
AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order])
fi
fi
# Check for operating system
AC_MSG_CHECKING([for platform-specific build settings])
case ${host_os} in
*mingw32*|*cygwin*)
AC_MSG_RESULT([${host_os}])
win32=true
AC_DEFINE(WINVER, 0x0501, [minimum Windows version])
deplibs_check_method='pass_all'
;;
darwin*)
AC_MSG_RESULT([${host_os}])
AC_CHECK_FUNCS([pthread_once pthread_cancel])
;;
*)
AC_MSG_RESULT([${host_os}])
;;
esac
AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden")
if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
GLOBAL_CFLAGS+=" -DLIBTATSU_STATIC"
fi
AC_SUBST(GLOBAL_CFLAGS)
# check for large file support
AC_SYS_LARGEFILE
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_CONFIG_FILES([
Makefile
src/Makefile
src/libtatsu-1.0.pc
include/Makefile
])
AC_OUTPUT
echo "
Configuration for $PACKAGE $VERSION:
-------------------------------------------
Install prefix: .........: $prefix
Now type 'make' to build $PACKAGE $VERSION,
and then 'make install' for installation.
"
0707010000000A000081ED000000000000000000000001676DFA4F00000265000000000000000000000000000000000000002D00000000libtatsu-1.0.4+8git.20241227/git-version-gen#!/bin/sh
SRCDIR=`dirname $0`
echo "AAHAHAHAHAAHAHH" >> log.log
if test -n "$1"; then
VER=$1
else
if test -r "${SRCDIR}/.git" && test -x "`which git`" ; then
git update-index -q --refresh
if ! VER=`git describe --tags --dirty 2>/dev/null`; then
COMMIT=`git rev-parse --short HEAD`
DIRTY=`git diff --quiet HEAD || echo "-dirty"`
VER=`sed -n '1,/RE/s/Version \(.*\)/\1/p' ${SRCDIR}/NEWS`-git-${COMMIT}${DIRTY}
fi
else
if test -f "${SRCDIR}/.tarball-version"; then
VER=`cat "${SRCDIR}/.tarball-version"`
fi
fi
fi
VER=`printf %s "$VER" | head -n1`
printf %s "$VER"
0707010000000B000041ED000000000000000000000003676DFA4F00000000000000000000000000000000000000000000002500000000libtatsu-1.0.4+8git.20241227/include0707010000000C000081A4000000000000000000000001676DFA4F0000003F000000000000000000000000000000000000003100000000libtatsu-1.0.4+8git.20241227/include/Makefile.amnobase_include_HEADERS = \
libtatsu/tss.h \
libtatsu/tatsu.h
0707010000000D000041ED000000000000000000000002676DFA4F00000000000000000000000000000000000000000000002E00000000libtatsu-1.0.4+8git.20241227/include/libtatsu0707010000000E000081A4000000000000000000000001676DFA4F000004AD000000000000000000000000000000000000003600000000libtatsu-1.0.4+8git.20241227/include/libtatsu/tatsu.h/*
* tatsu.h
* Common definitions
*
* Copyright (c) 2024 Nikias Bassen, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __TATSU_H
#define __TATSU_H
#ifndef LIBTATSU_API
#ifdef LIBTATSU_STATIC
#define LIBTATSU_API
#elif defined(_WIN32)
#define LIBTATSU_API __declspec(dllimport)
#else
#define LIBTATSU_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
LIBTATSU_API const char* libtatsu_version();
#ifdef __cplusplus
}
#endif
#endif
0707010000000F000081A4000000000000000000000001676DFA4F00000F0B000000000000000000000000000000000000003400000000libtatsu-1.0.4+8git.20241227/include/libtatsu/tss.h/*
* tss.h
* Definitions for communicating with Apple's TSS server.
*
* Copyright (c) 2012-2024 Nikias Bassen, All Rights Reserved.
* Copyright (c) 2013 Martin Szulecki. All Rights Reserved.
* Copyright (c) 2010 Joshua Hill. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBTATSU_TSS_H
#define LIBTATSU_TSS_H
#include <libtatsu/tatsu.h>
#include <plist/plist.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* parameters */
LIBTATSU_API int tss_parameters_add_from_manifest(plist_t parameters, plist_t build_identity, bool include_manifest);
/* request */
LIBTATSU_API plist_t tss_request_new(plist_t overrides);
LIBTATSU_API int tss_request_add_local_policy_tags(plist_t request, plist_t parameters);
LIBTATSU_API int tss_request_add_common_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_ap_recovery_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_baseband_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name);
LIBTATSU_API int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name);
LIBTATSU_API int tss_request_add_vinyl_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_rose_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_veridian_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_tcon_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_timer_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_cryptex_tags(plist_t request, plist_t parameters, plist_t overrides);
LIBTATSU_API int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters);
LIBTATSU_API int tss_request_add_ap_img3_tags(plist_t request, plist_t parameters);
/* i/o */
LIBTATSU_API plist_t tss_request_send(plist_t request, const char* server_url_string);
/* response */
LIBTATSU_API int tss_response_get_ap_img4_ticket(plist_t response, unsigned char** ticket, unsigned int* length);
LIBTATSU_API int tss_response_get_ap_ticket(plist_t response, unsigned char** ticket, unsigned int* length);
LIBTATSU_API int tss_response_get_baseband_ticket(plist_t response, unsigned char** ticket, unsigned int* length);
LIBTATSU_API int tss_response_get_path_by_entry(plist_t response, const char* entry, char** path);
LIBTATSU_API int tss_response_get_blob_by_path(plist_t response, const char* path, unsigned char** blob);
LIBTATSU_API int tss_response_get_blob_by_entry(plist_t response, const char* entry, unsigned char** blob);
LIBTATSU_API void tss_set_debug_level(int level);
#ifdef __cplusplus
}
#endif
#endif
07070100000010000041ED000000000000000000000002676DFA4F00000000000000000000000000000000000000000000002000000000libtatsu-1.0.4+8git.20241227/m407070100000011000081A4000000000000000000000001676DFA4F00000607000000000000000000000000000000000000003400000000libtatsu-1.0.4+8git.20241227/m4/as-compiler-flag.m4dnl as-compiler-flag.m4 0.1.0
dnl autostars m4 macro for detection of compiler flags
dnl David Schleef <ds@schleef.org>
dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
AC_DEFUN([AS_COMPILER_FLAG],
[
AC_MSG_CHECKING([to see if compiler understands $1])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
m4_ifvaln([$2],[$2])
true
else
m4_ifvaln([$3],[$3])
true
fi
AC_MSG_RESULT([$flag_ok])
])
dnl AS_COMPILER_FLAGS(VAR, FLAGS)
dnl Tries to compile with the given CFLAGS.
AC_DEFUN([AS_COMPILER_FLAGS],
[
list=$2
flags_supported=""
flags_unsupported=""
AC_MSG_CHECKING([for supported compiler flags])
for each in $list
do
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $each"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
flags_supported="$flags_supported $each"
else
flags_unsupported="$flags_unsupported $each"
fi
done
AC_MSG_RESULT([$flags_supported])
if test "X$flags_unsupported" != X ; then
AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
fi
$1="$$1 $flags_supported"
])
07070100000012000041ED000000000000000000000002676DFA4F00000000000000000000000000000000000000000000002100000000libtatsu-1.0.4+8git.20241227/src07070100000013000081A4000000000000000000000001676DFA4F00000212000000000000000000000000000000000000002D00000000libtatsu-1.0.4+8git.20241227/src/Makefile.amAM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)
AM_CFLAGS = $(GLOBAL_CFLAGS) $(libcurl_CFLAGS) $(libplist_CFLAGS)
AM_LDFLAGS = $(libcurl_LIBS) $(libplist_LIBS)
lib_LTLIBRARIES = libtatsu.la
libtatsu_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBTATSU_SO_VERSION) -no-undefined
libtatsu_la_LIBADD =
libtatsu_la_SOURCES = \
tss.c \
tatsu.c \
common.h
if WIN32
libtatsu_la_LDFLAGS += -avoid-version -static-libgcc
libtatsu_la_LIBADD += -lws2_32
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libtatsu-1.0.pc
07070100000014000081A4000000000000000000000001676DFA4F000004B4000000000000000000000000000000000000002A00000000libtatsu-1.0.4+8git.20241227/src/common.h/*
* common.h
*
* Copyright (c) 2024 Nikias Bassen, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __COMMON_H
#define __COMMON_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef LIBTATSU_STATIC
#define LIBTATSU_API
#elif defined(_WIN32)
#define LIBTATSU_API __declspec( dllexport )
#else
#if __GNUC__ >= 4
#define LIBTATSU_API __attribute__((visibility("default")))
#else
#define LIBTATSU_API
#endif
#endif
#include "libtatsu/tatsu.h"
#endif
07070100000015000081A4000000000000000000000001676DFA4F00000131000000000000000000000000000000000000003400000000libtatsu-1.0.4+8git.20241227/src/libtatsu-1.0.pc.inprefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: @PACKAGE_NAME@
Description: Tatsu Signing Server library for handling idevice personalization
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ltatsu
Cflags: -I${includedir}
Requires: libplist-2.0 >= @LIBPLIST_VERSION@
07070100000016000081A4000000000000000000000001676DFA4F00000403000000000000000000000000000000000000002900000000libtatsu-1.0.4+8git.20241227/src/tatsu.c/*
* tatsu.c
*
* Copyright (c) 2024 Nikias Bassen, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "common.h"
const char* libtatsu_version()
{
#ifndef PACKAGE_VERSION
#error PACKAGE_VERSION is not defined!
#endif
return PACKAGE_VERSION;
}
07070100000017000081A4000000000000000000000001676DFA4F0000EAD3000000000000000000000000000000000000002700000000libtatsu-1.0.4+8git.20241227/src/tss.c/*
* tss.c
* Functions for communicating with Apple's TSS server
*
* Copyright (c) 2012-2024 Nikias Bassen, All Rights Reserved.
* Copyright (c) 2010-2013 Martin Szulecki. All Rights Reserved.
* Copyright (c) 2010 Joshua Hill. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <windows.h>
#define sleep(n) Sleep(n * 1000)
#endif
#include <curl/curl.h>
#include <plist/plist.h>
#include "common.h"
#include "libtatsu/tss.h"
#define USER_AGENT_STRING "InetURL/1.0"
#define AUTH_VERSION "1033.0.6"
#ifdef _WIN32
#define TSS_CLIENT_VERSION_STRING "libauthinstall_Win-"AUTH_VERSION""
#else
#define TSS_CLIENT_VERSION_STRING "libauthinstall-"AUTH_VERSION""
#endif
#define ECID_STRSIZE 0x20
typedef struct {
int length;
char* content;
} tss_response;
static int debug_level = 0;
static void error(const char* fmt, ...)
{
va_list args;
if (debug_level < 1)
return;
/* run the real fprintf */
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
static void debug(const char* fmt, ...)
{
va_list args;
if (debug_level < 2)
return;
/* run the real fprintf */
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
static void debug_plist(plist_t plist)
{
if (debug_level < 2)
return;
plist_write_to_stream(plist, stderr, PLIST_FORMAT_XML, PLIST_OPT_NONE);
}
#define GET_RAND(min, max) ((rand() % (max - min)) + min)
static char *generate_guid(void)
{
char *guid = (char *) malloc(sizeof(char) * 37);
const char *chars = "ABCDEF0123456789";
srand(time(NULL));
int i = 0;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
guid[i] = '-';
continue;
} else {
guid[i] = chars[GET_RAND(0, 16)];
}
}
guid[36] = '\0';
return guid;
}
plist_t tss_request_new(plist_t overrides)
{
plist_t request = plist_new_dict();
plist_dict_set_item(request, "@HostPlatformInfo",
#ifdef _WIN32
plist_new_string("windows")
#else
plist_new_string("mac")
#endif
);
plist_dict_set_item(request, "@VersionInfo", plist_new_string(TSS_CLIENT_VERSION_STRING));
char* guid = generate_guid();
if (guid) {
plist_dict_set_item(request, "@UUID", plist_new_string(guid));
free(guid);
}
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return request;
}
int tss_request_add_local_policy_tags(plist_t request, plist_t parameters)
{
plist_dict_set_item(request, "@ApImg4Ticket", plist_new_bool(1));
if (plist_dict_copy_bool(request, parameters, "Ap,LocalBoot", NULL) < 0) {
error("ERROR: Unable to find required Ap,LocalBoot in parameters\n");
return -1;
}
if (plist_dict_copy_item(request, parameters, "Ap,LocalPolicy", NULL) < 0) {
error("ERROR: Unable to find required Ap,LocalPolicy in parameters\n");
return -1;
}
if (plist_dict_copy_data(request, parameters, "Ap,NextStageIM4MHash", NULL) < 0) {
error("ERROR: Unable to find required Ap,NextStageIM4MHash in parameters\n");
return -1;
}
plist_dict_copy_data(request, parameters, "Ap,RecoveryOSPolicyNonceHash", NULL);
plist_dict_copy_data(request, parameters, "Ap,VolumeUUID", NULL);
plist_dict_copy_uint(request, parameters, "ApECID", NULL);
plist_dict_copy_uint(request, parameters, "ApChipID", NULL);
plist_dict_copy_uint(request, parameters, "ApBoardID", NULL);
plist_dict_copy_uint(request, parameters, "ApSecurityDomain", NULL);
plist_dict_copy_data(request, parameters, "ApNonce", NULL);
if (!plist_dict_get_item(request, "ApSecurityMode")) {
/* copy from parameters if available */
if (plist_dict_copy_bool(request, parameters, "ApSecurityMode", NULL) < 0) {
error("ERROR: Unable to find required ApSecurityMode in parameters\n");
return -1;
}
}
if (!plist_dict_get_item(request, "ApProductionMode")) {
/* copy from parameters if available */
if (plist_dict_copy_bool(request, parameters, "ApProductionMode", NULL) < 0) {
error("ERROR: Unable to find required ApProductionMode in parameters\n");
return -1;
}
}
return 0;
}
int tss_parameters_add_from_manifest(plist_t parameters, plist_t build_identity, bool include_manifest)
{
plist_t node = NULL;
if (plist_dict_copy_data(parameters, build_identity, "UniqueBuildID", NULL) < 0) {
error("ERROR: Unable to find UniqueBuildID node\n");
return -1;
}
plist_dict_copy_string(parameters, build_identity, "Ap,OSLongVersion", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,OSReleaseType", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,ProductMarketingVersion", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,ProductType", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,SDKPlatform", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,Target", NULL);
plist_dict_copy_string(parameters, build_identity, "Ap,TargetType", NULL);
if (plist_dict_copy_uint(parameters, build_identity, "ApChipID", NULL) < 0) {;
error("ERROR: Unable to find ApChipID node\n");
return -1;
}
if (plist_dict_copy_uint(parameters, build_identity, "ApBoardID", NULL) < 0) {
error("ERROR: Unable to find ApBoardID node\n");
return -1;
}
plist_dict_copy_uint(parameters, build_identity, "ApSecurityDomain", NULL);
plist_dict_copy_uint(parameters, build_identity, "BMU,BoardID", NULL);
plist_dict_copy_uint(parameters, build_identity, "BMU,ChipID", NULL);
if (plist_dict_copy_uint(parameters, build_identity, "BbChipID", NULL) < 0) {
debug("NOTE: Unable to find BbChipID node\n");
}
if (plist_dict_copy_data(parameters, build_identity, "BbProvisioningManifestKeyHash", NULL) < 0) {
debug("NOTE: Unable to find BbProvisioningManifestKeyHash node\n");
}
if (plist_dict_copy_data(parameters, build_identity, "BbActivationManifestKeyHash", NULL) < 0) {
debug("NOTE: Unable to find BbActivationManifestKeyHash node\n");
}
if (plist_dict_copy_data(parameters, build_identity, "BbCalibrationManifestKeyHash", NULL) < 0) {
debug("NOTE: Unable to find BbCalibrationManifestKeyHash node\n");
}
if (plist_dict_copy_data(parameters, build_identity, "BbFactoryActivationManifestKeyHash", NULL) < 0) {
debug("NOTE: Unable to find BbFactoryActivationManifestKeyHash node\n");
}
if (plist_dict_copy_data(parameters, build_identity, "BbFDRSecurityKeyHash", NULL) < 0) {
debug("NOTE: Unable to find BbFDRSecurityKeyHash node\n");
}
/* BbSkeyId - Used by XMM 6180/GSM */
if (plist_dict_copy_data(parameters, build_identity, "BbSkeyId", NULL) < 0) {
debug("NOTE: Unable to find BbSkeyId node\n");
}
/* SE,ChipID - Used for SE firmware request */
plist_dict_copy_uint(parameters, build_identity, "SE,ChipID", NULL);
/* Savage,ChipID - Used for Savage firmware request */
plist_dict_copy_uint(parameters, build_identity, "Savage,ChipID", NULL);
/* add Savage,PatchEpoch - Used for Savage firmware request */
plist_dict_copy_uint(parameters, build_identity, "Savage,PatchEpoch", NULL);
/* Yonkers,BoardID - Used for Yonkers firmware request */
plist_dict_copy_uint(parameters, build_identity, "Yonkers,BoardID", NULL);
/* Yonkers,ChipID - Used for Yonkers firmware request */
plist_dict_copy_uint(parameters, build_identity, "Yonkers,ChipID", NULL);
/* add Yonkers,PatchEpoch - Used for Yonkers firmware request */
plist_dict_copy_uint(parameters, build_identity, "Yonkers,PatchEpoch", NULL);
plist_dict_copy_uint(parameters, build_identity, "Rap,BoardID", NULL);
plist_dict_copy_uint(parameters, build_identity, "Rap,ChipID", NULL);
plist_dict_copy_uint(parameters, build_identity, "Rap,SecurityDomain", NULL);
plist_dict_copy_uint(parameters, build_identity, "Baobab,BoardID", NULL);
plist_dict_copy_uint(parameters, build_identity, "Baobab,ChipID", NULL);
plist_dict_copy_uint(parameters, build_identity, "Baobab,ManifestEpoch", NULL);
plist_dict_copy_uint(parameters, build_identity, "Baobab,SecurityDomain", NULL);
plist_dict_copy_uint(parameters, build_identity, "eUICC,ChipID", NULL);
plist_dict_copy_uint(parameters, build_identity, "NeRDEpoch", NULL);
plist_dict_copy_data(parameters, build_identity, "PearlCertificationRootPub", NULL);
plist_dict_copy_bool(parameters, build_identity, "AllowNeRDBoot", NULL);
if (plist_dict_get_item(parameters, "NeRDEpoch")) {
plist_dict_set_item(parameters, "PermitNeRDPivot", plist_new_data(NULL, 0));
}
plist_dict_copy_uint(parameters, build_identity, "Timer,BoardID,1", NULL);
plist_dict_copy_uint(parameters, build_identity, "Timer,BoardID,2", NULL);
plist_dict_copy_uint(parameters, build_identity, "Timer,ChipID,1", NULL);
plist_dict_copy_uint(parameters, build_identity, "Timer,ChipID,2", NULL);
plist_dict_copy_uint(parameters, build_identity, "Timer,SecurityDomain,1", NULL);
plist_dict_copy_uint(parameters, build_identity, "Timer,SecurityDomain,2", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,ChipID", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,Type", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,SubType", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,ProductClass", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,UseProductClass", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,NonceDomain", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,Version", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,PreauthorizationVersion", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,FakeRoot", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,SystemOS", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,SystemVolume", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,SystemTrustCache", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,AppOS", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,AppVolume", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,AppTrustCache", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,MobileAssetBrainOS", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,MobileAssetBrainVolume", NULL);
plist_dict_copy_item(parameters, build_identity, "Cryptex1,MobileAssetBrainTrustCache", NULL);
plist_dict_copy_item(parameters, build_identity, "USBPortController1,BoardID", NULL);
plist_dict_copy_item(parameters, build_identity, "USBPortController1,ChipID", NULL);
plist_dict_copy_item(parameters, build_identity, "USBPortController1,SecurityDomain", NULL);
node = plist_dict_get_item(build_identity, "Info");
if (node) {
plist_dict_copy_bool(parameters, node, "RequiresUIDMode", NULL);
}
if (include_manifest) {
/* add build identity manifest dictionary */
node = plist_dict_get_item(build_identity, "Manifest");
if (!node || plist_get_node_type(node) != PLIST_DICT) {
error("ERROR: Unable to find Manifest node\n");
return -1;
}
plist_dict_set_item(parameters, "Manifest", plist_copy(node));
}
return 0;
}
int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters)
{
if (!parameters) {
error("ERROR: Missing required AP parameters\n");
return -1;
}
plist_dict_copy_string(request, parameters, "Ap,OSLongVersion", NULL);
plist_dict_copy_string(request, parameters, "Ap,OSReleaseType", NULL);
plist_dict_copy_string(request, parameters, "Ap,ProductMarketingVersion", NULL);
plist_dict_copy_string(request, parameters, "Ap,ProductType", NULL);
plist_dict_copy_string(request, parameters, "Ap,SDKPlatform", NULL);
plist_dict_copy_string(request, parameters, "Ap,Target", NULL);
plist_dict_copy_string(request, parameters, "Ap,TargetType", NULL);
if (plist_dict_copy_data(request, parameters, "ApNonce", NULL) < 0) {
error("ERROR: Unable to find required ApNonce in parameters\n");
return -1;
}
plist_dict_set_item(request, "@ApImg4Ticket", plist_new_bool(1));
if (!plist_dict_get_item(request, "ApSecurityMode")) {
/* copy from parameters if available */
if (plist_dict_copy_bool(request, parameters, "ApSecurityMode", NULL) < 0) {
error("ERROR: Unable to find required ApSecurityMode in parameters\n");
return -1;
}
}
if (!plist_dict_get_item(request, "ApProductionMode")) {
/* ApProductionMode */
if (plist_dict_copy_bool(request, parameters, "ApProductionMode", NULL) < 0) {
error("ERROR: Unable to find required ApProductionMode in parameters\n");
return -1;
}
}
plist_dict_copy_data(request, parameters, "SepNonce", plist_dict_get_item(parameters, "SepNonce") ? NULL : "ApSepNonce");
plist_dict_copy_uint(request, parameters, "NeRDEpoch", NULL);
plist_dict_copy_data(request, parameters, "PearlCertificationRootPub", NULL);
plist_dict_copy_bool(request, parameters, "AllowNeRDBoot", NULL);
plist_dict_copy_item(request, parameters, "PermitNeRDPivot", NULL);
if (plist_dict_get_item(parameters, "UID_MODE")) {
plist_dict_copy_item(request, parameters, "UID_MODE", NULL);
} else if (plist_dict_get_bool(parameters, "RequiresUIDMode")) {
// The logic here is missing why this value is expected to be 'false'
plist_dict_set_item(request, "UID_MODE", plist_new_bool(0));
}
// FIXME: I didn't understand yet when this value is set, so for now we use a workaround
if (plist_dict_get_item(parameters, "ApSikaFuse")) {
plist_dict_copy_item(request, parameters, "Ap,SikaFuse", "ApSikaFuse");
} else if (plist_dict_get_bool(parameters, "RequiresUIDMode")) {
// Workaround: We have only seen Ap,SikaFuse together with UID_MODE
plist_dict_set_item(request, "Ap,SikaFuse", plist_new_int(0));
}
return 0;
}
int tss_request_add_ap_img3_tags(plist_t request, plist_t parameters)
{
if (!parameters) {
error("ERROR: Missing required AP parameters\n");
return -1;
}
if (plist_dict_copy_data(request, parameters, "ApNonce", NULL) < 0) {
error("WARNING: Unable to find ApNonce in parameters\n");
}
plist_dict_set_item(request, "@APTicket", plist_new_bool(1));
if (plist_dict_copy_uint(request, parameters, "ApBoardID", NULL) < 0) {
error("ERROR: Unable to find required ApBoardID in request\n");
return -1;
}
if (plist_dict_copy_uint(request, parameters, "ApChipID", NULL) < 0) {
error("ERROR: Unable to find required ApChipID in request\n");
return -1;
}
if (plist_dict_copy_uint(request, parameters, "ApSecurityDomain", NULL) < 0) {
error("ERROR: Unable to find required ApSecurityDomain in request\n");
return -1;
}
if (plist_dict_copy_bool(request, parameters, "ApProductionMode", NULL) < 0) {
error("ERROR: Unable to find required ApProductionMode in parameters\n");
return -1;
}
return 0;
}
int tss_request_add_common_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_dict_copy_uint(request, parameters, "ApECID", NULL);
plist_dict_copy_data(request, parameters, "UniqueBuildID", NULL);
plist_dict_copy_uint(request, parameters, "ApChipID", NULL);
plist_dict_copy_uint(request, parameters, "ApBoardID", NULL);
plist_dict_copy_uint(request, parameters, "ApSecurityDomain", NULL);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
static void tss_entry_apply_restore_request_rules(plist_t tss_entry, plist_t parameters, plist_t rules)
{
if (!tss_entry || !rules) {
return;
}
if (plist_get_node_type(tss_entry) != PLIST_DICT) {
return;
}
if (plist_get_node_type(rules) != PLIST_ARRAY) {
return;
}
uint32_t i;
for (i = 0; i < plist_array_get_size(rules); i++) {
plist_t rule = plist_array_get_item(rules, i);
plist_t conditions = plist_dict_get_item(rule, "Conditions");
plist_dict_iter iter = NULL;
plist_dict_new_iter(conditions, &iter);
char* key = NULL;
plist_t value = NULL;
plist_t value2 = NULL;
int conditions_fulfilled = 1;
while (conditions_fulfilled) {
plist_dict_next_item(conditions, iter, &key, &value);
if (key == NULL)
break;
if (!strcmp(key, "ApRawProductionMode")) {
value2 = plist_dict_get_item(parameters, "ApProductionMode");
} else if (!strcmp(key, "ApCurrentProductionMode")) {
value2 = plist_dict_get_item(parameters, "ApProductionMode");
} else if (!strcmp(key, "ApRawSecurityMode")) {
value2 = plist_dict_get_item(parameters, "ApSecurityMode");
} else if (!strcmp(key, "ApRequiresImage4")) {
value2 = plist_dict_get_item(parameters, "ApSupportsImg4");
} else if (!strcmp(key, "ApDemotionPolicyOverride")) {
value2 = plist_dict_get_item(parameters, "DemotionPolicy");
} else if (!strcmp(key, "ApInRomDFU")) {
value2 = plist_dict_get_item(parameters, "ApInRomDFU");
} else {
error("WARNING: Unhandled condition '%s' while parsing RestoreRequestRules\n", key);
value2 = NULL;
}
if (value2) {
conditions_fulfilled = plist_compare_node_value(value, value2);
} else {
conditions_fulfilled = 0;
}
free(key);
}
free(iter);
iter = NULL;
if (!conditions_fulfilled) {
continue;
}
plist_t actions = plist_dict_get_item(rule, "Actions");
plist_dict_new_iter(actions, &iter);
while (1) {
plist_dict_next_item(actions, iter, &key, &value);
if (key == NULL)
break;
uint8_t bv = 255;
plist_get_bool_val(value, &bv);
if (bv != 255) {
value2 = plist_dict_get_item(tss_entry, key);
if (value2) {
plist_dict_remove_item(tss_entry, key);
}
debug("DEBUG: Adding %s=%s to TSS entry\n", key, (bv) ? "true" : "false");
plist_dict_set_item(tss_entry, key, plist_new_bool(bv));
}
free(key);
}
}
}
static int is_fw_payload(plist_t info_dict)
{
return plist_dict_get_bool(info_dict, "IsFirmwarePayload")
|| plist_dict_get_bool(info_dict, "IsSecondaryFirmwarePayload")
|| plist_dict_get_bool(info_dict, "IsFUDFirmware")
|| plist_dict_get_bool(info_dict, "IsLoadedByiBoot")
|| plist_dict_get_bool(info_dict, "IsEarlyAccessFirmware")
|| plist_dict_get_bool(info_dict, "IsiBootEANFirmware")
|| plist_dict_get_bool(info_dict, "IsiBootNonEssentialFirmware");
}
int tss_request_add_ap_recovery_tags(plist_t request, plist_t parameters, plist_t overrides)
{
/* loop over components from build manifest */
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: Unable to find restore manifest\n");
return -1;
}
/* add components to request */
char* key = NULL;
plist_t manifest_entry = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
free(key);
key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
error("ERROR: Unable to fetch BuildManifest entry\n");
free(key);
return -1;
}
/* do not populate BaseBandFirmware, only in basebaseband request */
if ((strcmp(key, "BasebandFirmware") == 0)) {
continue;
}
// Compared to ac2, not needed for RecoveryOSRootTicket
if ((strcmp(key, "SE,UpdatePayload") == 0)) {
continue;
}
if ((strcmp(key, "BaseSystem") == 0)) {
continue;
}
if ((strcmp(key, "ANS") == 0)) {
continue;
}
if ((strcmp(key, "Ap,AudioBootChime") == 0)) {
continue;
}
if ((strcmp(key, "Ap,CIO") == 0)) {
continue;
}
if ((strcmp(key, "Ap,RestoreCIO") == 0)) {
continue;
}
if ((strcmp(key, "Ap,RestoreTMU") == 0)) {
continue;
}
if ((strcmp(key, "Ap,TMU") == 0)) {
continue;
}
if ((strcmp(key, "Ap,rOSLogo1") == 0)) {
continue;
}
if ((strcmp(key, "Ap,rOSLogo2") == 0)) {
continue;
}
if ((strcmp(key, "AppleLogo") == 0)) {
continue;
}
if ((strcmp(key, "DCP") == 0)) {
continue;
}
if ((strcmp(key, "LLB") == 0)) {
continue;
}
if ((strcmp(key, "RecoveryMode") == 0)) {
continue;
}
if ((strcmp(key, "RestoreANS") == 0)) {
continue;
}
if ((strcmp(key, "RestoreDCP") == 0)) {
continue;
}
if ((strcmp(key, "RestoreDeviceTree") == 0)) {
continue;
}
if ((strcmp(key, "RestoreKernelCache") == 0)) {
continue;
}
if ((strcmp(key, "RestoreLogo") == 0)) {
continue;
}
if ((strcmp(key, "RestoreRamDisk") == 0)) {
continue;
}
if ((strcmp(key, "RestoreSEP") == 0)) {
continue;
}
if ((strcmp(key, "SEP") == 0)) {
continue;
}
if ((strcmp(key, "ftap") == 0)) {
continue;
}
if ((strcmp(key, "ftsp") == 0)) {
continue;
}
if ((strcmp(key, "iBEC") == 0)) {
continue;
}
if ((strcmp(key, "iBSS") == 0)) {
continue;
}
if ((strcmp(key, "rfta") == 0)) {
continue;
}
if ((strcmp(key, "rfts") == 0)) {
continue;
}
/* FIXME: only used with diagnostics firmware */
if (strcmp(key, "Diags") == 0) {
continue;
}
plist_t info_dict = plist_dict_get_item(manifest_entry, "Info");
if (!info_dict) {
continue;
}
if (plist_dict_get_bool(parameters, "_OnlyFWComponents")) {
if (!plist_dict_get_bool(manifest_entry, "Trusted")) {
debug("DEBUG: %s: Skipping '%s' as it is not trusted\n", __func__, key);
continue;
}
if (!is_fw_payload(info_dict)) {
debug("DEBUG: %s: Skipping '%s' as it is not a firmware payload\n", __func__, key);
continue;
}
}
/* copy this entry */
plist_t tss_entry = plist_copy(manifest_entry);
/* remove obsolete Info node */
plist_dict_remove_item(tss_entry, "Info");
/* handle RestoreRequestRules */
plist_t rules = plist_access_path(manifest_entry, 2, "Info", "RestoreRequestRules");
if (rules) {
debug("DEBUG: Applying restore request rules for entry %s\n", key);
tss_entry_apply_restore_request_rules(tss_entry, parameters, rules);
}
/* Make sure we have a Digest key for Trusted items even if empty */
if (plist_dict_get_bool(manifest_entry, "Trusted") && !plist_dict_get_item(manifest_entry, "Digest")) {
debug("DEBUG: No Digest data, using empty value for entry %s\n", key);
plist_dict_set_item(tss_entry, "Digest", plist_new_data(NULL, 0));
}
/* finally add entry to request */
plist_dict_set_item(request, key, tss_entry);
}
free(key);
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrides)
{
/* loop over components from build manifest */
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: Unable to find restore manifest\n");
return -1;
}
/* add components to request */
char* key = NULL;
plist_t manifest_entry = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
free(key);
key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
error("ERROR: Unable to fetch BuildManifest entry\n");
free(key);
return -1;
}
/* do not populate BaseBandFirmware, only in basebaseband request */
if ((strcmp(key, "BasebandFirmware") == 0)) {
continue;
}
// Compared to ac2, not needed
if ((strcmp(key, "SE,UpdatePayload") == 0)) {
continue;
}
// Compared to ac2, not needed
if ((strcmp(key, "BaseSystem") == 0)) {
continue;
}
/* FIXME: only used with diagnostics firmware */
if (strcmp(key, "Diags") == 0) {
continue;
}
if (strcmp(key, "Ap,ExclaveOS") == 0) {
continue;
}
plist_t info_dict = plist_dict_get_item(manifest_entry, "Info");
if (!info_dict) {
continue;
}
uint8_t trusted = plist_dict_get_bool(manifest_entry, "Trusted");
uint8_t supports_img4 = plist_dict_get_bool(parameters, "ApSupportsImg4");
if (supports_img4) {
if (!plist_dict_get_item(info_dict, "RestoreRequestRules") && !trusted) {
debug("DEBUG: %s: Skipping '%s' as it doesn't have RestoreRequestRules and is not Trusted\n", __func__, key);
continue;
}
}
if (plist_dict_get_bool(parameters, "_OnlyFWComponents")) {
if (!trusted) {
debug("DEBUG: %s: Skipping '%s' as it is not trusted\n", __func__, key);
continue;
}
if (!is_fw_payload(info_dict)) {
debug("DEBUG: %s: Skipping '%s' as it is not a firmware payload\n", __func__, key);
continue;
}
}
/* skip components with IsFTAB:true */
if (plist_dict_get_bool(info_dict, "IsFTAB")) {
debug("DEBUG: %s: Skipping FTAB component '%s'\n", __func__, key);
continue;
}
/* copy this entry */
plist_t tss_entry = plist_copy(manifest_entry);
/* remove obsolete Info node */
plist_dict_remove_item(tss_entry, "Info");
/* handle RestoreRequestRules */
plist_t rules = plist_access_path(manifest_entry, 2, "Info", "RestoreRequestRules");
if (rules) {
debug("DEBUG: Applying restore request rules for entry %s\n", key);
tss_entry_apply_restore_request_rules(tss_entry, parameters, rules);
} else if (supports_img4) {
plist_dict_copy_bool(tss_entry, parameters, "EPRO", "ApProductionMode");
plist_dict_copy_bool(tss_entry, parameters, "ESEC", "ApSecurityMode");
}
/* Make sure we have a Digest key for Trusted items even if empty */
if (trusted && !plist_dict_get_item(manifest_entry, "Digest")) {
debug("DEBUG: No Digest data, using empty value for entry %s\n", key);
plist_dict_set_item(tss_entry, "Digest", plist_new_data(NULL, 0));
}
/* empty entry is not needed */
if (plist_dict_get_size(tss_entry) == 0) {
continue;
}
/* finally add entry to request */
plist_dict_set_item(request, key, tss_entry);
}
free(key);
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_baseband_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_copy_uint(request, parameters, "BbChipID", NULL);
plist_dict_copy_data(request, parameters, "BbProvisioningManifestKeyHash", NULL);
/* BbActivationManifestKeyHash - Used by Qualcomm MDM6610 */
plist_dict_copy_data(request, parameters, "BbActivationManifestKeyHash", NULL);
plist_dict_copy_data(request, parameters, "BbCalibrationManifestKeyHash", NULL);
plist_dict_copy_data(request, parameters, "BbFactoryActivationManifestKeyHash", NULL);
plist_dict_copy_data(request, parameters, "BbFDRSecurityKeyHash", NULL);
/* BbSkeyId - Used by XMM 6180/GSM */
plist_dict_copy_data(request, parameters, "BbSkeyId", NULL);
plist_dict_copy_data(request, parameters, "BbNonce", NULL);
plist_dict_copy_uint(request, parameters, "BbGoldCertId", NULL);
uint64_t bb_chip_id = plist_dict_get_uint(request, "BbChipID");
uint32_t bb_cert_id = (uint32_t)plist_dict_get_uint(request, "BbGoldCertId");
if (plist_dict_copy_data(request, parameters, "BbSNUM", NULL) < 0) {
error("ERROR: Unable to find required BbSNUM in parameters\n");
return -1;
}
/* BasebandFirmware */
node = plist_access_path(parameters, 2, "Manifest", "BasebandFirmware");
if (!node || plist_get_node_type(node) != PLIST_DICT) {
error("ERROR: Unable to get BasebandFirmware node\n");
return -1;
}
plist_t bbfwdict = plist_copy(node);
node = NULL;
if (plist_dict_get_item(bbfwdict, "Info")) {
plist_dict_remove_item(bbfwdict, "Info");
}
if (bb_chip_id == 0x68) {
/* depending on the BasebandCertId remove certain nodes */
if (bb_cert_id == 0x26F3FACC || bb_cert_id == 0x5CF2EC4E || bb_cert_id == 0x8399785A) {
plist_dict_remove_item(bbfwdict, "PSI2-PartialDigest");
plist_dict_remove_item(bbfwdict, "RestorePSI2-PartialDigest");
} else {
plist_dict_remove_item(bbfwdict, "PSI-PartialDigest");
plist_dict_remove_item(bbfwdict, "RestorePSI-PartialDigest");
}
}
plist_dict_set_item(request, "BasebandFirmware", bbfwdict);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
if (plist_dict_copy_uint(request, parameters, "SE,ChipID", NULL) < 0) {
error("ERROR: %s: Unable to find required SE,ChipID in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_data(request, parameters, "SE,ID", NULL) < 0) {
error("ERROR: %s: Unable to find required SE,ID in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_data(request, parameters, "SE,Nonce", NULL) < 0) {
error("ERROR: %s: Unable to find required SE,Nonce in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_data(request, parameters, "SE,RootKeyIdentifier", NULL) < 0) {
error("ERROR: %s: Unable to find required SE,RootKeyIdentifier in parameters\n", __func__);
return -1;
}
/* 'IsDev' determines whether we have Production or Development */
uint8_t is_dev = plist_dict_get_bool(parameters, "SE,IsDev");
/* add SE,* components from build manifest to request */
char* key = NULL;
plist_t manifest_entry = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
free(key);
key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
error("ERROR: Unable to fetch BuildManifest entry\n");
free(key);
return -1;
}
if (strncmp(key, "SE,", 3)) {
continue;
}
/* copy this entry */
plist_t tss_entry = plist_copy(manifest_entry);
/* remove Info node */
plist_dict_remove_item(tss_entry, "Info");
/* remove Development or Production key/hash node */
if (is_dev) {
if (plist_dict_get_item(tss_entry, "ProductionCMAC"))
plist_dict_remove_item(tss_entry, "ProductionCMAC");
if (plist_dict_get_item(tss_entry, "ProductionUpdatePayloadHash"))
plist_dict_remove_item(tss_entry, "ProductionUpdatePayloadHash");
} else {
if (plist_dict_get_item(tss_entry, "DevelopmentCMAC"))
plist_dict_remove_item(tss_entry, "DevelopmentCMAC");
if (plist_dict_get_item(tss_entry, "DevelopmentUpdatePayloadHash"))
plist_dict_remove_item(tss_entry, "DevelopmentUpdatePayloadHash");
}
/* add entry to request */
plist_dict_set_item(request, key, tss_entry);
}
free(key);
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
/* fallback in case no @SE2,Ticket or @SE,Ticket was provided */
if (!plist_dict_get_item(request, "@SE2,Ticket") && !plist_dict_get_item(request, "@SE,Ticket")) {
plist_dict_set_item(request, "@SE,Ticket", plist_new_bool(1));
}
return 0;
}
int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the Savage,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@Savage,Ticket", plist_new_bool(1));
if (plist_dict_copy_data(request, parameters, "Savage,UID", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,UID in parameters\n", __func__);
return -1;
}
/* add SEP */
node = plist_access_path(manifest_node, 2, "SEP", "Digest");
if (!node) {
error("ERROR: Unable to get SEP digest from manifest\n");
return -1;
}
plist_t dict = plist_new_dict();
plist_dict_set_item(dict, "Digest", plist_copy(node));
plist_dict_set_item(request, "SEP", dict);
if (plist_dict_copy_uint(request, parameters, "Savage,PatchEpoch", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,PatchEpoch in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_uint(request, parameters, "Savage,ChipID", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,ChipID in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_bool(request, parameters, "Savage,AllowOfflineBoot", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,AllowOfflineBoot in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_bool(request, parameters, "Savage,ReadFWKey", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,ReadFWKey in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_bool(request, parameters, "Savage,ProductionMode", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,ProductionMode in parameters\n", __func__);
return -1;
}
const char *comp_name = NULL;
uint8_t isprod = plist_dict_get_bool(request, "Savage,ProductionMode");
/* get the right component name */
comp_name = (isprod) ? "Savage,B0-Prod-Patch" : "Savage,B0-Dev-Patch";
node = plist_dict_get_item(parameters, "Savage,Revision");
if (node && (plist_get_node_type(node) == PLIST_DATA)) {
uint64_t savage_rev_len = 0;
const unsigned char *savage_rev = (const unsigned char*)plist_get_data_ptr(node, &savage_rev_len);
if (savage_rev_len > 0) {
if (((savage_rev[0] | 0x10) & 0xF0) == 0x30) {
comp_name = (isprod) ? "Savage,B2-Prod-Patch" : "Savage,B2-Dev-Patch";
} else if ((savage_rev[0] & 0xF0) == 0xA0) {
comp_name = (isprod) ? "Savage,BA-Prod-Patch" : "Savage,BA-Dev-Patch";
}
}
}
/* add Savage,B?-*-Patch */
node = plist_dict_get_item(manifest_node, comp_name);
if (!node) {
error("ERROR: Unable to get %s entry from manifest\n", comp_name);
return -1;
}
dict = plist_copy(node);
plist_dict_remove_item(dict, "Info");
plist_dict_set_item(request, comp_name, dict);
if (component_name) {
*component_name = strdup(comp_name);
}
if (plist_dict_copy_data(request, parameters, "Savage,Nonce", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,Nonce in parameters\n", __func__);
return -1;
}
if (plist_dict_copy_bool(request, parameters, "Savage,ReadECKey", NULL) < 0) {
error("ERROR: %s: Unable to find required Savage,ReadECKey in parameters\n", __func__);
return -1;
}
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the Savage,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@Yonkers,Ticket", plist_new_bool(1));
/* add SEP */
node = plist_access_path(manifest_node, 2, "SEP", "Digest");
if (!node) {
error("ERROR: Unable to get SEP digest from manifest\n");
return -1;
}
plist_t dict = plist_new_dict();
plist_dict_set_item(dict, "Digest", plist_copy(node));
plist_dict_set_item(request, "SEP", dict);
{
static const char *keys[] = {"Yonkers,AllowOfflineBoot", "Yonkers,BoardID", "Yonkers,ChipID", "Yonkers,ECID", "Yonkers,Nonce", "Yonkers,PatchEpoch", "Yonkers,ProductionMode", "Yonkers,ReadECKey", "Yonkers,ReadFWKey", };
int i;
for (i = 0; i < (int)(sizeof(keys) / sizeof(keys[0])); ++i) {
node = plist_dict_get_item(parameters, keys[i]);
if (!node) {
error("ERROR: %s: Unable to find required %s in parameters\n", __func__, keys[i]);
}
plist_dict_set_item(request, keys[i], plist_copy(node));
node = NULL;
}
}
char *comp_name = NULL;
plist_t comp_node = NULL;
uint8_t isprod = plist_dict_get_bool(parameters, "Yonkers,ProductionMode");
uint64_t fabrevision = plist_dict_get_uint(parameters, "Yonkers,FabRevision");
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (iter) {
node = NULL;
comp_name = NULL;
plist_dict_next_item(manifest_node, iter, &comp_name, &node);
if (comp_name == NULL) {
node = NULL;
break;
}
if (strncmp(comp_name, "Yonkers,", 8) == 0) {
int target_node = 1;
plist_t sub_node;
if ((sub_node = plist_dict_get_item(node, "EPRO")) != NULL && plist_get_node_type(sub_node) == PLIST_BOOLEAN) {
uint8_t b = 0;
plist_get_bool_val(sub_node, &b);
target_node &= ((isprod) ? b : !b);
}
if ((sub_node = plist_dict_get_item(node, "FabRevision")) != NULL && plist_get_node_type(sub_node) == PLIST_UINT) {
uint64_t v = 0;
plist_get_uint_val(sub_node, &v);
target_node &= (v == fabrevision);
}
if (target_node) {
comp_node = node;
break;
}
}
free(comp_name);
}
free(iter);
if (comp_name == NULL) {
error("ERROR: No Yonkers node for %s/%lu\n", (isprod) ? "Production" : "Development", (unsigned long)fabrevision);
return -1;
}
/* add Yonkers,SysTopPatch* */
if (comp_node != NULL) {
plist_t comp_dict = plist_copy(comp_node);
plist_dict_remove_item(comp_dict, "Info");
plist_dict_set_item(request, comp_name, comp_dict);
}
if (component_name) {
*component_name = comp_name;
} else {
free(comp_name);
}
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_vinyl_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the eUICC,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@eUICC,Ticket", plist_new_bool(1));
plist_dict_copy_bool(request, parameters, "eUICC,ApProductionMode", "ApProductionMode");
plist_dict_copy_uint(request, parameters, "eUICC,ChipID", NULL);
plist_dict_copy_data(request, parameters, "eUICC,EID", NULL);
plist_dict_copy_data(request, parameters, "eUICC,RootKeyIdentifier", NULL);
if (!plist_dict_get_item(request, "eUICC,Gold")) {
plist_t n = plist_access_path(parameters, 2, "Manifest", "eUICC,Gold");
if (n) {
plist_t p = plist_new_dict();
plist_dict_copy_data(p, n, "Digest", NULL);
plist_dict_set_item(request, "eUICC,Gold", p);
}
}
if (!plist_dict_get_item(request, "eUICC,Main")) {
plist_t n = plist_access_path(parameters, 2, "Manifest", "eUICC,Main");
if (n) {
plist_t p = plist_new_dict();
plist_dict_copy_data(p, n, "Digest", NULL);
plist_dict_set_item(request, "eUICC,Main", p);
}
}
/* set Nonce for eUICC,Gold component */
node = plist_dict_get_item(parameters, "EUICCGoldNonce");
if (node) {
plist_t n = plist_dict_get_item(request, "eUICC,Gold");
if (n) {
plist_dict_set_item(n, "Nonce", plist_copy(node));
}
}
/* set Nonce for eUICC,Main component */
node = plist_dict_get_item(parameters, "EUICCMainNonce");
if (node) {
plist_t n = plist_dict_get_item(request, "eUICC,Main");
if (n) {
plist_dict_set_item(n, "Nonce", plist_copy(node));
}
}
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_rose_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the Rap,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@Rap,Ticket", plist_new_bool(1));
plist_dict_copy_uint(request, parameters, "Rap,BoardID", NULL);
plist_dict_copy_uint(request, parameters, "Rap,ChipID", NULL);
plist_dict_copy_uint(request, parameters, "Rap,ECID", NULL);
plist_dict_copy_data(request, parameters, "Rap,Nonce", NULL);
plist_dict_copy_bool(request, parameters, "Rap,ProductionMode", NULL);
plist_dict_copy_uint(request, parameters, "Rap,SecurityDomain", NULL);
plist_dict_copy_bool(request, parameters, "Rap,SecurityMode", NULL);
plist_dict_copy_data(request, parameters, "Rap,FdrRootCaDigest", NULL);
char *comp_name = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (iter) {
node = NULL;
comp_name = NULL;
plist_dict_next_item(manifest_node, iter, &comp_name, &node);
if (comp_name == NULL) {
node = NULL;
break;
}
if (strncmp(comp_name, "Rap,", 4) == 0) {
plist_t manifest_entry = plist_copy(node);
/* handle RestoreRequestRules */
plist_t rules = plist_access_path(manifest_entry, 2, "Info", "RestoreRequestRules");
if (rules) {
debug("DEBUG: Applying restore request rules for entry %s\n", comp_name);
tss_entry_apply_restore_request_rules(manifest_entry, parameters, rules);
}
/* Make sure we have a Digest key for Trusted items even if empty */
if (plist_dict_get_bool(manifest_entry, "Trusted") && !plist_dict_get_item(manifest_entry, "Digest")) {
debug("DEBUG: No Digest data, using empty value for entry %s\n", comp_name);
plist_dict_set_item(manifest_entry, "Digest", plist_new_data(NULL, 0));
}
plist_dict_remove_item(manifest_entry, "Info");
/* finally add entry to request */
plist_dict_set_item(request, comp_name, manifest_entry);
}
free(comp_name);
}
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_veridian_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the BMU,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@BMU,Ticket", plist_new_bool(1));
plist_dict_copy_uint(request, parameters, "BMU,BoardID", NULL);
plist_dict_copy_uint(request, parameters, "BMU,ChipID", "ChipID");
plist_dict_copy_data(request, parameters, "BMU,Nonce", "Nonce");
plist_dict_copy_bool(request, parameters, "BMU,ProductionMode", "ProductionMode");
plist_dict_copy_uint(request, parameters, "BMU,UniqueID", "UniqueID");
char *comp_name = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (iter) {
node = NULL;
comp_name = NULL;
plist_dict_next_item(manifest_node, iter, &comp_name, &node);
if (comp_name == NULL) {
node = NULL;
break;
}
if (strncmp(comp_name, "BMU,", 4) == 0) {
plist_t manifest_entry = plist_copy(node);
/* handle RestoreRequestRules */
plist_t rules = plist_access_path(manifest_entry, 2, "Info", "RestoreRequestRules");
if (rules) {
debug("DEBUG: Applying restore request rules for entry %s\n", comp_name);
tss_entry_apply_restore_request_rules(manifest_entry, parameters, rules);
}
/* Make sure we have a Digest key for Trusted items even if empty */
if (plist_dict_get_bool(manifest_entry, "Trusted") && !plist_dict_get_item(manifest_entry, "Digest")) {
debug("DEBUG: No Digest data, using empty value for entry %s\n", comp_name);
plist_dict_set_item(manifest_entry, "Digest", plist_new_data(NULL, 0));
}
plist_dict_remove_item(manifest_entry, "Info");
/* finally add entry to request */
plist_dict_set_item(request, comp_name, manifest_entry);
}
free(comp_name);
}
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_tcon_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the Baobab,Ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
plist_dict_set_item(request, "@Baobab,Ticket", plist_new_bool(1));
plist_dict_copy_uint(request, parameters, "Baobab,BoardID", NULL);
plist_dict_copy_uint(request, parameters, "Baobab,ChipID", NULL);
plist_dict_copy_data(request, parameters, "Baobab,ECID", NULL);
plist_dict_copy_uint(request, parameters, "Baobab,Life", NULL);
plist_dict_copy_uint(request, parameters, "Baobab,ManifestEpoch", NULL);
plist_dict_copy_bool(request, parameters, "Baobab,ProductionMode", NULL);
plist_dict_copy_uint(request, parameters, "Baobab,SecurityDomain", NULL);
plist_dict_copy_data(request, parameters, "Baobab,UpdateNonce", NULL);
uint8_t isprod = plist_dict_get_bool(parameters, "Baobab,ProductionMode");
char *comp_name = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (iter) {
node = NULL;
comp_name = NULL;
plist_dict_next_item(manifest_node, iter, &comp_name, &node);
if (comp_name == NULL) {
node = NULL;
break;
}
if (strncmp(comp_name, "Baobab,", 7) == 0) {
plist_t manifest_entry = plist_copy(node);
plist_dict_remove_item(manifest_entry, "Info");
plist_dict_set_item(manifest_entry, "EPRO", plist_new_bool(isprod));
/* finally add entry to request */
plist_dict_set_item(request, comp_name, manifest_entry);
}
free(comp_name);
}
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_timer_tags(plist_t request, plist_t parameters, plist_t overrides)
{
plist_t node = NULL;
uint32_t tag = 0;
plist_t manifest_node = plist_dict_get_item(parameters, "Manifest");
if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
error("ERROR: %s: Unable to get restore manifest from parameters\n", __func__);
return -1;
}
/* add tags indicating we want to get the Timer ticket */
plist_dict_set_item(request, "@BBTicket", plist_new_bool(1));
node = plist_dict_get_item(parameters, "TicketName");
if (!node) {
error("ERROR: %s: Missing TicketName\n", __func__);
return -1;
}
char key[64];
snprintf(key, sizeof(key), "@%s", plist_get_string_ptr(node, NULL));
plist_dict_set_item(request, key, plist_new_bool(1));
tag = (uint32_t)plist_dict_get_uint(parameters, "TagNumber");
snprintf(key, sizeof(key), "Timer,BoardID,%u", tag);
plist_dict_copy_uint(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,ChipID,%u", tag);
plist_dict_copy_uint(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,SecurityDomain,%u", tag);
plist_dict_copy_uint(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,SecurityMode,%u", tag);
plist_dict_copy_bool(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,ProductionMode,%u", tag);
plist_dict_copy_bool(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,ECID,%u", tag);
plist_dict_copy_uint(request, parameters, key, NULL);
snprintf(key, sizeof(key), "Timer,Nonce,%u", tag);
plist_dict_copy_data(request, parameters, key, NULL);
char *comp_name = NULL;
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (iter) {
node = NULL;
comp_name = NULL;
plist_dict_next_item(manifest_node, iter, &comp_name, &node);
if (comp_name == NULL) {
node = NULL;
break;
}
if (!strncmp(comp_name, "Timer,", 6)) {
plist_t manifest_entry = plist_copy(node);
/* handle RestoreRequestRules */
plist_t rules = plist_access_path(manifest_entry, 2, "Info", "RestoreRequestRules");
if (rules) {
debug("DEBUG: Applying restore request rules for entry %s\n", comp_name);
tss_entry_apply_restore_request_rules(manifest_entry, parameters, rules);
}
/* Make sure we have a Digest key for Trusted items even if empty */
if (plist_dict_get_bool(manifest_entry, "Trusted") && !plist_dict_get_item(manifest_entry, "Digest")) {
debug("DEBUG: No Digest data, using empty value for entry %s\n", comp_name);
plist_dict_set_item(manifest_entry, "Digest", plist_new_data(NULL, 0));
}
plist_dict_remove_item(manifest_entry, "Info");
/* finally add entry to request */
plist_dict_set_item(request, comp_name, manifest_entry);
}
free(comp_name);
}
free(iter);
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
int tss_request_add_cryptex_tags(plist_t request, plist_t parameters, plist_t overrides)
{
tss_request_add_common_tags(request, parameters, NULL);
if (plist_dict_get_item(parameters, "Ap,LocalPolicy")) {
/* Cryptex1LocalPolicy */
tss_request_add_local_policy_tags(request, parameters);
plist_dict_copy_data(request, parameters, "Ap,NextStageCryptex1IM4MHash", NULL);
} else {
/* Cryptex1 */
plist_dict_set_item(request, "@Cryptex1,Ticket", plist_new_bool(1));
plist_dict_copy_bool(request, parameters, "ApSecurityMode", NULL);
plist_dict_copy_bool(request, parameters, "ApProductionMode", NULL);
plist_dict_iter iter = NULL;
plist_dict_new_iter(parameters, &iter);
plist_t value = NULL;
while (1) {
char *key = NULL;
plist_dict_next_item(parameters, iter, &key, &value);
if (key == NULL)
break;
if (strncmp(key, "Cryptex1", 8) == 0) {
plist_dict_set_item(request, key, plist_copy(value));
}
free(key);
}
}
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
}
return 0;
}
static size_t tss_write_callback(char* data, size_t size, size_t nmemb, tss_response* response)
{
size_t total = size * nmemb;
if (total != 0) {
response->content = realloc(response->content, response->length + total + 1);
memcpy(response->content + response->length, data, total);
response->content[response->length + total] = '\0';
response->length += total;
}
return total;
}
plist_t tss_request_send(plist_t tss_request, const char* server_url_string)
{
debug_plist(tss_request);
char* request = NULL;
int status_code = -1;
int retry = 0;
int max_retries = 15;
unsigned int size = 0;
char curl_error_message[CURL_ERROR_SIZE];
const char* urls[6] = {
"https://gs.apple.com/TSS/controller?action=2",
"https://gs.apple.com.akadns.net/TSS/controller?action=2",
"https://gs.apple.com.v.aaplimg.com/TSS/controller?action=2",
"http://gs.apple.com/TSS/controller?action=2",
"http://gs.apple.com.akadns.net/TSS/controller?action=2",
"http://gs.apple.com.v.aaplimg.com/TSS/controller?action=2"
};
plist_to_xml(tss_request, &request, &size);
tss_response* response = NULL;
memset(curl_error_message, '\0', CURL_ERROR_SIZE);
while (retry++ < max_retries) {
response = NULL;
CURL* handle = curl_easy_init();
if (handle == NULL) {
break;
}
struct curl_slist* header = NULL;
header = curl_slist_append(header, "Cache-Control: no-cache");
header = curl_slist_append(header, "Content-type: text/xml; charset=\"utf-8\"");
header = curl_slist_append(header, "Expect:");
response = malloc(sizeof(tss_response));
if (response == NULL) {
fprintf(stderr, "Unable to allocate sufficient memory\n");
return NULL;
}
response->length = 0;
response->content = malloc(1);
response->content[0] = '\0';
/* disable SSL verification to allow download from untrusted https locations */
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, curl_error_message);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, (curl_write_callback)&tss_write_callback);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, response);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, header);
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, request);
curl_easy_setopt(handle, CURLOPT_USERAGENT, USER_AGENT_STRING);
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, (long)strlen(request));
if (server_url_string) {
curl_easy_setopt(handle, CURLOPT_URL, server_url_string);
debug("Request URL set to %s\n", server_url_string);
} else {
int url_index = (retry - 1) % 6;
curl_easy_setopt(handle, CURLOPT_URL, urls[url_index]);
debug("Request URL set to %s\n", urls[url_index]);
}
if (debug_level >= 2) {
curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
}
debug("Sending TSS request attempt %d... ", retry);
curl_easy_perform(handle);
curl_slist_free_all(header);
curl_easy_cleanup(handle);
if (strstr(response->content, "MESSAGE=SUCCESS")) {
status_code = 0;
debug("response successfully received\n");
break;
}
if (response->length > 0) {
error("TSS server returned: %s\n", response->content);
}
char* status = strstr(response->content, "STATUS=");
if (status) {
sscanf(status+7, "%d&%*s", &status_code);
}
if (status_code == -1) {
error("%s\n", curl_error_message);
// no status code in response. retry
free(response->content);
free(response);
response = NULL;
sleep(2);
continue;
} else if (status_code == 8) {
// server error (invalid bb request?)
break;
} else if (status_code == 49) {
// server error (invalid bb data, e.g. BbSNUM?)
break;
} else if (status_code == 69 || status_code == 94) {
// This device isn't eligible for the requested build.
break;
} else if (status_code == 100) {
// server error, most likely the request was malformed
break;
} else if (status_code == 126) {
// An internal error occured, most likely the request was malformed
break;
} else {
error("ERROR: tss_send_request: Unhandled status code %d\n", status_code);
break;
}
}
if (status_code != 0) {
if (response && strstr(response->content, "MESSAGE=") != NULL) {
char* message = strstr(response->content, "MESSAGE=") + strlen("MESSAGE=");
error("ERROR: TSS request failed (status=%d, message=%s)\n", status_code, message);
} else {
error("ERROR: TSS request failed: %s (status=%d)\n", curl_error_message, status_code);
}
free(request);
if (response) free(response->content);
if (response) free(response);
return NULL;
}
char* tss_data = strstr(response->content, "<?xml");
if (tss_data == NULL) {
error("ERROR: Incorrectly formatted TSS response\n");
free(request);
free(response->content);
free(response);
return NULL;
}
uint32_t tss_size = 0;
plist_t tss_resp = NULL;
tss_size = response->length - (tss_data - response->content);
plist_from_xml(tss_data, tss_size, &tss_resp);
free(response->content);
free(response);
debug_plist(tss_resp);
free(request);
return tss_resp;
}
static int tss_response_get_data_by_key(plist_t response, const char* name, unsigned char** buffer, unsigned int* length)
{
plist_t node = plist_dict_get_item(response, name);
if (!node || plist_get_node_type(node) != PLIST_DATA) {
debug("DEBUG: %s: No entry '%s' in TSS response\n", __func__, name);
return -1;
}
char* data = NULL;
uint64_t len = 0;
plist_get_data_val(node, &data, &len);
if (data) {
*length = (unsigned int)len;
*buffer = (unsigned char*)data;
return 0;
} else {
error("ERROR: Unable to get %s data from TSS response\n", name);
return -1;
}
}
int tss_response_get_ap_img4_ticket(plist_t response, unsigned char** ticket, unsigned int* length)
{
return tss_response_get_data_by_key(response, "ApImg4Ticket", ticket, length);
}
int tss_response_get_ap_ticket(plist_t response, unsigned char** ticket, unsigned int* length)
{
return tss_response_get_data_by_key(response, "APTicket", ticket, length);
}
int tss_response_get_baseband_ticket(plist_t response, unsigned char** ticket, unsigned int* length)
{
return tss_response_get_data_by_key(response, "BBTicket", ticket, length);
}
int tss_response_get_path_by_entry(plist_t response, const char* entry, char** path)
{
char* path_string = NULL;
plist_t path_node = NULL;
plist_t entry_node = NULL;
*path = NULL;
entry_node = plist_dict_get_item(response, entry);
if (!entry_node || plist_get_node_type(entry_node) != PLIST_DICT) {
debug("DEBUG: %s: No entry '%s' in TSS response\n", __func__, entry);
return -1;
}
path_node = plist_dict_get_item(entry_node, "Path");
if (!path_node || plist_get_node_type(path_node) != PLIST_STRING) {
debug("NOTE: Unable to find %s path in TSS entry\n", entry);
return -1;
}
plist_get_string_val(path_node, &path_string);
*path = path_string;
return 0;
}
int tss_response_get_blob_by_path(plist_t tss, const char* path, unsigned char** blob)
{
uint32_t i = 0;
uint32_t tss_size = 0;
uint64_t blob_size = 0;
char* entry_key = NULL;
char* blob_data = NULL;
char* entry_path = NULL;
plist_t tss_entry = NULL;
plist_t blob_node = NULL;
plist_t path_node = NULL;
plist_dict_iter iter = NULL;
*blob = NULL;
plist_dict_new_iter(tss, &iter);
tss_size = plist_dict_get_size(tss);
for (i = 0; i < tss_size; i++) {
plist_dict_next_item(tss, iter, &entry_key, &tss_entry);
if (entry_key == NULL)
break;
if (!tss_entry || plist_get_node_type(tss_entry) != PLIST_DICT) {
continue;
}
path_node = plist_dict_get_item(tss_entry, "Path");
if (!path_node || plist_get_node_type(path_node) != PLIST_STRING) {
error("ERROR: Unable to find TSS path node in entry %s\n", entry_key);
free(iter);
return -1;
}
plist_get_string_val(path_node, &entry_path);
if (strcmp(path, entry_path) == 0) {
blob_node = plist_dict_get_item(tss_entry, "Blob");
if (!blob_node || plist_get_node_type(blob_node) != PLIST_DATA) {
error("ERROR: Unable to find TSS blob node in entry %s\n", entry_key);
free(iter);
return -1;
}
plist_get_data_val(blob_node, &blob_data, &blob_size);
break;
}
free(entry_key);
}
free(iter);
if (blob_data == NULL || blob_size <= 0) {
return -1;
}
*blob = (unsigned char*)blob_data;
return 0;
}
int tss_response_get_blob_by_entry(plist_t response, const char* entry, unsigned char** blob)
{
uint64_t blob_size = 0;
char* blob_data = NULL;
plist_t blob_node = NULL;
plist_t tss_entry = NULL;
*blob = NULL;
tss_entry = plist_dict_get_item(response, entry);
if (!tss_entry || plist_get_node_type(tss_entry) != PLIST_DICT) {
debug("DEBUG: %s: No entry '%s' in TSS response\n", __func__, entry);
return -1;
}
blob_node = plist_dict_get_item(tss_entry, "Blob");
if (!blob_node || plist_get_node_type(blob_node) != PLIST_DATA) {
error("ERROR: Unable to find blob in %s entry\n", entry);
return -1;
}
plist_get_data_val(blob_node, &blob_data, &blob_size);
*blob = (unsigned char*)blob_data;
return 0;
}
void tss_set_debug_level(int level)
{
debug_level = level;
}
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!237 blocks