├── settings.gradle
├── trustedintents
├── project.properties
├── AndroidManifest.xml
├── build.gradle
├── setup-ant
├── trustedintents.pom
├── src
│ ├── info
│ │ └── guardianproject
│ │ │ ├── trustedintents
│ │ │ ├── ApkSignaturePin.java
│ │ │ └── TrustedIntents.java
│ │ │ ├── GuardianProjectRSA1024.java
│ │ │ └── GuardianProjectRSA4096.java
│ └── org
│ │ ├── torproject
│ │ └── TorProjectRSA1024.java
│ │ └── iilab
│ │ └── IilabEngineeringRSA2048Pin.java
└── custom_rules.xml
├── ic_launcher.png
├── test
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ └── values
│ │ └── strings.xml
├── libs
│ ├── android-junit-report-1.5.8.jar
│ └── android-junit-report-1.5.8.README
├── .classpath
├── project.properties
├── custom_rules.xml
├── AndroidManifest.xml
├── ant.properties
├── .project
└── src
│ ├── info
│ └── guardianproject
│ │ └── trustedintents
│ │ └── test
│ │ ├── ThisPackagePin.java
│ │ ├── ApkSignaturePinTests.java
│ │ ├── ReceiverTestActivity.java
│ │ ├── ReceiverTestActivityUnitTestCase.java
│ │ └── TrustedIntentsTests.java
│ └── com
│ └── android
│ ├── AndroidIncludedAppsPin.java
│ └── AndroidSystemPin.java
├── app
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── content_main.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── info
│ │ │ └── guardianproject
│ │ │ └── trustedintents
│ │ │ └── example
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── info
│ │ │ └── guardianproject
│ │ │ └── trustedintents
│ │ │ └── example
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── info
│ │ └── guardianproject
│ │ └── trustedintents
│ │ └── example
│ │ └── ApplicationTest.java
└── build.gradle
├── jenkins-build
├── .classpath
├── .gitignore
├── .project
├── README.md
├── make-release-build
└── LICENSE.txt
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':trustedintents'
2 |
--------------------------------------------------------------------------------
/trustedintents/project.properties:
--------------------------------------------------------------------------------
1 | target=android-19
2 | android.library=true
3 |
--------------------------------------------------------------------------------
/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/ic_launcher.png
--------------------------------------------------------------------------------
/test/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/test/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/test/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/test/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/libs/android-junit-report-1.5.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/test/libs/android-junit-report-1.5.8.jar
--------------------------------------------------------------------------------
/test/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/test/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardianproject/TrustedIntents/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TrustedIntentsTests
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TrustedIntents
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/test/libs/android-junit-report-1.5.8.README:
--------------------------------------------------------------------------------
1 |
2 | Needed for Jenkins to get JUnit reports.
3 |
4 | * https://github.com/jsankey/android-junit-report
5 | * https://github.com/downloads/jsankey/android-junit-report/android-junit-report-1.5.8.jar
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/trustedintents/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/jenkins-build:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 | set -x
5 |
6 | if [ -z $ANDROID_HOME ]; then
7 | if [ -e ~/.android/bashrc ]; then
8 | . ~/.android/bashrc
9 | else
10 | echo "ANDROID_HOME must be set!"
11 | exit
12 | fi
13 | fi
14 |
15 | export PATH=$PATH:$ANDROID_HOME/tools
16 |
17 | cd trustedintents
18 | ./setup-ant
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/info/guardianproject/trustedintents/example/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package info.guardianproject.trustedintents.example;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/info/guardianproject/trustedintents/example/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package info.guardianproject.trustedintents.example;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/test/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "info.guardianproject.trustedintents"
9 | minSdkVersion 7
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | }
15 |
16 | dependencies {
17 | compile fileTree(dir: 'libs', include: ['*.jar'])
18 | compile project (':trustedintents')
19 | testCompile 'junit:junit:4.12'
20 | compile 'com.android.support:appcompat-v7:23.1.1'
21 | compile 'com.android.support:design:23.1.1'
22 | }
23 |
--------------------------------------------------------------------------------
/trustedintents/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | sourceSets.main {
8 | manifest.srcFile 'AndroidManifest.xml'
9 | java.srcDirs = ['src']
10 | resources.srcDirs = ['src']
11 | aidl.srcDirs = ['src']
12 | renderscript.srcDirs = ['src']
13 | res.srcDirs = ['res']
14 | assets.srcDirs = ['assets']
15 | }
16 | }
17 |
18 | dependencies {
19 | compile fileTree(dir: 'libs', include: ['*.jar'])
20 | }
21 |
22 | task jar(type: Jar) {
23 | from android.sourceSets.main.java.srcDirs
24 | }
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Android build products
2 | bin/
3 | gen/
4 | obj/
5 |
6 | # test products
7 | junit-report.xml
8 |
9 | # only hide in library project, not test/ project
10 | /libs/
11 | /res/
12 |
13 | # products of "android create project" or "android update project"
14 | build.xml
15 | ant.properties
16 | default.properties
17 | local.properties
18 | proguard-project.txt
19 | proguard.cfg
20 | proguard-rules.pro
21 |
22 | # emacs detritus
23 | *~
24 |
25 | # Eclipse detritus
26 | .settings
27 |
28 | # Mac OS X detritus
29 | .DS_Store
30 |
31 | # Windows thumbnail db
32 | Thumbs.db
33 |
34 | # Android Studio
35 | *.iml
36 | .idea/
37 | .gradle/
38 | build/
39 | gradle.properties
40 |
--------------------------------------------------------------------------------
/test/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library.reference.1=../../TrustedIntents
16 |
--------------------------------------------------------------------------------
/trustedintents/setup-ant:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 | set -x
5 |
6 | if ! which android > /dev/null; then
7 | if [ -z $ANDROID_HOME ]; then
8 | if [ -e ~/.android/bashrc ]; then
9 | . ~/.android/bashrc
10 | else
11 | echo "'android' not found, ANDROID_HOME must be set!"
12 | exit
13 | fi
14 | else
15 | export PATH="${ANDROID_HOME}/tools:$PATH"
16 | fi
17 | fi
18 |
19 | # fetch target from project.properties
20 | eval `grep '^target=' project.properties`
21 |
22 | CURDIR=`pwd`
23 |
24 | android update lib-project --path ${CURDIR} --target $target
25 | android update test-project --path ${CURDIR}/../test --main ${CURDIR}
26 |
--------------------------------------------------------------------------------
/test/custom_rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 | Downloading XML test report (/data/data/${tested.package}/files/junit-report.xml)…
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 | tested.project.dir=../trustedintents
19 | test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TrustedIntents
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/test/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TrustedIntentsTests
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | This is a library for flexible trusted interactions between Android apps. It
3 | is modeled after Android's `signature` protection level for permissions. The
4 | key difference is that the framework allows the trusted signature to be set,
5 | rather than requiring to match the current app's signature.
6 |
7 | For more info:
8 |
9 | * https://dev.guardianproject.info/projects/bazaar/wiki/Trusted_Intent_Interaction
10 | * https://guardianproject.info/2014/01/21/improving-trust-and-flexibility-in-interactions-between-android-apps/
11 | * https://developer.android.com/guide/topics/manifest/permission-element.html#plevel
12 |
13 | License
14 | -------
15 |
16 | This library is licensed under the LGPLv2.1. We believe this is compatible
17 | with all reasonable uses, including proprietary software, but let us know if
18 | it provides difficulties for you. For more info on how that works with Java,
19 | see:
20 |
21 | https://www.gnu.org/licenses/lgpl-java.en.html
22 |
--------------------------------------------------------------------------------
/test/src/info/guardianproject/trustedintents/test/ThisPackagePin.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents.test;
3 |
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 | import android.content.pm.PackageManager.NameNotFoundException;
7 | import android.content.pm.Signature;
8 |
9 | import info.guardianproject.trustedintents.ApkSignaturePin;
10 |
11 | public class ThisPackagePin extends ApkSignaturePin {
12 |
13 | public ThisPackagePin(PackageManager pm) {
14 | PackageInfo pkgInfo;
15 | try {
16 | pkgInfo = pm.getPackageInfo(
17 | ReceiverTestActivityUnitTestCase.class.getPackage().getName(),
18 | PackageManager.GET_SIGNATURES);
19 | Signature[] signatures = pkgInfo.signatures;
20 | certificates = new byte[signatures.length][];
21 | for (int i = 0; i < certificates.length; i++)
22 | certificates[i] = signatures[i].toByteArray();
23 | } catch (NameNotFoundException e) {
24 | e.printStackTrace();
25 | assert false;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/make-release-build:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # bash is required because we need bash's printf to guarantee a cross-platform
3 | # timestamp format.
4 |
5 | set -e
6 | set -x
7 |
8 | if [ -z $ANDROID_HOME ]; then
9 | if [ -e ~/.android/bashrc ]; then
10 | . ~/.android/bashrc
11 | else
12 | echo "ANDROID_HOME must be set!"
13 | exit
14 | fi
15 | fi
16 |
17 | # standardize timezone to reduce build differences
18 | export TZ=UTC
19 |
20 | git reset --hard
21 | git clean -fdx
22 |
23 | cd trustedintents
24 | ./setup-ant
25 |
26 | ant release-all
27 |
28 | jarname=trustedintents-$(git describe)
29 | rm -f ${jarname}*.asc
30 |
31 | # standardize timestamps in ZIP headers
32 | if which strip-nondeterminism > /dev/null; then
33 | for f in ${jarname}*.jar; do
34 | strip-nondeterminism -t jar -T $(git log -n1 --format=format:%at) $f
35 | done
36 | fi
37 |
38 | for f in ${jarname}*.jar; do
39 | sha256sum $f
40 | done
41 |
42 | if which gpg > /dev/null; then
43 | if [ -z "`gpg --list-secret-keys`" ]; then
44 | echo "No GPG secret keys found, not signing APK"
45 | else
46 | for f in ${jarname}*.*; do
47 | gpg --armor --detach-sign $f
48 | done
49 | fi
50 | else
51 | echo "gpg not found, not signing APK"
52 | fi
53 |
--------------------------------------------------------------------------------
/test/src/info/guardianproject/trustedintents/test/ApkSignaturePinTests.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents.test;
3 |
4 | import android.test.AndroidTestCase;
5 | import android.util.Log;
6 |
7 | import com.android.AndroidIncludedAppsPin;
8 | import com.android.AndroidSystemPin;
9 |
10 | import info.guardianproject.trustedintents.ApkSignaturePin;
11 |
12 | public class ApkSignaturePinTests extends AndroidTestCase {
13 | private static final String TAG = "ApkSignatureTests";
14 |
15 | private String androidSystemFingerprint = "27196e386b875e76adf700e7ea84e4c6eee33dfa";
16 | private String androidIncludedAppsFingerprint = "61ed377e85d386a8dfee6b864bd85b0bfaa5af81";
17 |
18 | public void testFingerprints() {
19 | ApkSignaturePin android = new AndroidSystemPin();
20 | assertTrue(android.doFingerprintsMatchCertificates());
21 | Log.i(TAG, androidSystemFingerprint + " == " + android.getSHA1Fingerprint());
22 | assertEquals(androidSystemFingerprint, android.getSHA1Fingerprint());
23 |
24 | ApkSignaturePin comAndroid = new AndroidIncludedAppsPin();
25 | assertTrue(comAndroid.doFingerprintsMatchCertificates());
26 | Log.i(TAG, androidIncludedAppsFingerprint + " == " + comAndroid.getSHA1Fingerprint());
27 | assertEquals(androidIncludedAppsFingerprint, comAndroid.getSHA1Fingerprint());
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/test/src/info/guardianproject/trustedintents/test/ReceiverTestActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents.test;
3 |
4 | import android.app.Activity;
5 | import android.content.ComponentName;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager.NameNotFoundException;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 |
11 | import info.guardianproject.trustedintents.TrustedIntents;
12 |
13 | import java.security.cert.CertificateException;
14 |
15 | public class ReceiverTestActivity extends Activity {
16 | private static final String TAG = "TestActivity";
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | Intent intent = getIntent();
21 | Log.i(TAG, "intent package: " + intent.getPackage());
22 | ComponentName componentName = getCallingActivity();
23 | if (componentName != null)
24 | Log.i(TAG, " componentName package: " + componentName.getPackageName()
25 | + " componentName class: " + componentName.getClassName());
26 |
27 | TrustedIntents ti = TrustedIntents.get(this);
28 | ti.addTrustedSigner(ThisPackagePin.class);
29 | try {
30 | ti.getIntentFromTrustedSender(this);
31 | } catch (NameNotFoundException e) {
32 | e.printStackTrace();
33 | assert false;
34 | } catch (CertificateException e) {
35 | e.printStackTrace();
36 | assert false;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/trustedintents/trustedintents.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | info.guardianproject.trustedintents
6 | trustedintents
7 | 0.0
8 | TrustedIntents
9 | https://guardianproject.info/code/trustedintents
10 | TrustedIntents is a library for flexible trusted interactions between Android apps. It is modeled after Android's `signature` protection level for permissions. The key difference is that the framework allows the trusted signature to be set, rather than requiring to match the current app's signature.
11 |
12 |
13 | LGPLv2.1
14 | https://github.com/guardianproject/TrustedIntents/blob/master/LICENSE.txt
15 |
16 |
17 |
18 |
19 | guardianproject
20 | Guardian Project
21 | support@guardianproject.info
22 |
23 |
24 |
25 | https://dev.guardianproject.info/projects/trustedintents/issues
26 | Redmine
27 |
28 |
29 | scm:https://github.com/guardianproject/TrustedIntents.git
30 | scm:git@github.com:guardianproject/TrustedIntents.git
31 | scm:https://github.com/guardianproject/TrustedIntents
32 |
33 |
34 |
--------------------------------------------------------------------------------
/test/src/info/guardianproject/trustedintents/test/ReceiverTestActivityUnitTestCase.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents.test;
3 |
4 | import android.app.Instrumentation;
5 | import android.content.ComponentName;
6 | import android.content.Intent;
7 | import android.test.ActivityUnitTestCase;
8 | import android.text.TextUtils;
9 |
10 | public class ReceiverTestActivityUnitTestCase extends ActivityUnitTestCase {
11 | private static final String TAG = "ReceiverActivityTestCase";
12 |
13 | private Instrumentation instrumentation;
14 |
15 | public ReceiverTestActivityUnitTestCase() {
16 | super(ReceiverTestActivity.class);
17 | }
18 |
19 | @Override
20 | protected void setUp() throws Exception {
21 | super.setUp();
22 | instrumentation = getInstrumentation();
23 | }
24 |
25 | public void testSettingComponent() {
26 | Intent sentIntent = new Intent(instrumentation.getTargetContext(),
27 | ReceiverTestActivity.class);
28 | startActivity(sentIntent, null, null);
29 | Intent receivedIntent = getActivity().getIntent();
30 | assertTrue(receivedIntent != null);
31 | assertTrue(receivedIntent.getPackage() == null);
32 | ComponentName receivedComponentName = receivedIntent.getComponent();
33 | assertTrue(receivedComponentName != null);
34 | String packageName = receivedComponentName.getPackageName();
35 | assertEquals(packageName, getActivity().getPackageName());
36 | }
37 |
38 | public void testSettingPackage() {
39 | Intent sentIntent = new Intent(Intent.ACTION_MAIN);
40 | String packageName = this.getClass().getPackage().getName();
41 | sentIntent.setPackage(packageName);
42 | startActivity(sentIntent, null, null);
43 | Intent receivedIntent = getActivity().getIntent();
44 | assertTrue(receivedIntent != null);
45 | assertTrue(receivedIntent.getPackage() != null);
46 | ComponentName receivedComponentName = receivedIntent.getComponent();
47 | assertTrue(receivedComponentName != null);
48 | assertFalse(TextUtils.isEmpty(receivedComponentName.getPackageName()));
49 | assertEquals(packageName, receivedComponentName.getPackageName());
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/trustedintents/src/info/guardianproject/trustedintents/ApkSignaturePin.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents;
3 |
4 | import android.content.pm.Signature;
5 |
6 | import java.math.BigInteger;
7 | import java.security.MessageDigest;
8 | import java.security.NoSuchAlgorithmException;
9 | import java.util.Arrays;
10 |
11 | public abstract class ApkSignaturePin {
12 |
13 | protected String[] fingerprints; // hex-encoded SHA-256 hashes of the certs
14 | protected byte[][] certificates; // array of DER-encoded X.509 certificates
15 | private Signature[] signatures;
16 |
17 | public Signature[] getSignatures() {
18 | if (signatures == null) {
19 | signatures = new Signature[certificates.length];
20 | for (int i = 0; i < certificates.length; i++)
21 | signatures[i] = new Signature(certificates[i]);
22 | }
23 | return signatures;
24 | }
25 |
26 | /**
27 | * Gets the fingerprint of the first certificate in the signature.
28 | *
29 | * @param algorithm - Which hash to use (e.g. MD5, SHA1, SHA-256)
30 | * @return the fingerprint as hex String
31 | */
32 | public String getFingerprint(String algorithm) {
33 | try {
34 | MessageDigest md = MessageDigest.getInstance(algorithm);
35 | byte[] hashBytes = md.digest(certificates[0]);
36 | BigInteger bi = new BigInteger(1, hashBytes);
37 | md.reset();
38 | return String.format("%0" + (hashBytes.length << 1) + "x", bi);
39 | } catch (NoSuchAlgorithmException e) {
40 | e.printStackTrace();
41 | }
42 | return null;
43 | }
44 |
45 | /**
46 | * Gets the MD5 fingerprint of the first certificate in the signature.
47 | *
48 | * @return the MD5 sum as hex String
49 | */
50 | public String getMD5Fingerprint() {
51 | return getFingerprint("MD5");
52 | }
53 |
54 | /**
55 | * Gets the SHA1 fingerprint of the first certificate in the signature.
56 | *
57 | * @return the SHA1 sum as hex String
58 | */
59 | public String getSHA1Fingerprint() {
60 | return getFingerprint("SHA1");
61 | }
62 |
63 | /**
64 | * Gets the SHA-256 fingerprint of the first certificate in the signature.
65 | *
66 | * @return the SHA-256 sum as hex String
67 | */
68 | public String getSHA256Fingerprint() {
69 | return getFingerprint("SHA-256");
70 | }
71 |
72 | /**
73 | * Compares the calculated SHA-256 cert fingerprint to the stored one.
74 | *
75 | * @return the result of the comparison
76 | */
77 | public boolean doFingerprintsMatchCertificates() {
78 | if (fingerprints == null || certificates == null)
79 | return false;
80 | String[] calcedFingerprints = new String[certificates.length];
81 | for (int i = 0; i < calcedFingerprints.length; i++)
82 | calcedFingerprints[i] = getSHA256Fingerprint();
83 | if (fingerprints.length == 0 || calcedFingerprints.length == 0)
84 | return false;
85 | return Arrays.equals(fingerprints, calcedFingerprints);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/info/guardianproject/trustedintents/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package info.guardianproject.trustedintents.example;
2 |
3 | import android.app.Activity;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.design.widget.FloatingActionButton;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.Toast;
14 |
15 | import java.security.cert.CertificateException;
16 |
17 | import info.guardianproject.GuardianProjectRSA1024;
18 | import info.guardianproject.trustedintents.TrustedIntents;
19 |
20 | public class MainActivity extends AppCompatActivity {
21 |
22 | private static TrustedIntents trustedIntents;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 |
28 | trustedIntents = TrustedIntents.get(this);
29 | trustedIntents.addTrustedSigner(GuardianProjectRSA1024.class);
30 |
31 | setContentView(R.layout.activity_main);
32 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
33 | setSupportActionBar(toolbar);
34 |
35 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
36 | fab.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View view) {
39 | final Activity activity = MainActivity.this;
40 | try {
41 | Intent intent = new Intent(Intent.ACTION_VIEW);
42 | intent.setClassName("info.guardianproject.gpg",
43 | "info.guardianproject.gpg.MainActivity");
44 | trustedIntents.startActivity(activity, intent);
45 | } catch (ActivityNotFoundException e) {
46 | e.printStackTrace();
47 | Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
48 | } catch (CertificateException e) {
49 | e.printStackTrace();
50 | Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
51 | }
52 | }
53 | });
54 | }
55 |
56 | @Override
57 | public boolean onCreateOptionsMenu(Menu menu) {
58 | // Inflate the menu; this adds items to the action bar if it is present.
59 | getMenuInflater().inflate(R.menu.menu_main, menu);
60 | return true;
61 | }
62 |
63 | @Override
64 | public boolean onOptionsItemSelected(MenuItem item) {
65 | // Handle action bar item clicks here. The action bar will
66 | // automatically handle clicks on the Home/Up button, so long
67 | // as you specify a parent activity in AndroidManifest.xml.
68 | int id = item.getItemId();
69 |
70 | //noinspection SimplifiableIfStatement
71 | if (id == R.id.action_settings) {
72 | return true;
73 | }
74 |
75 | return super.onOptionsItemSelected(item);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/trustedintents/src/org/torproject/TorProjectRSA1024.java:
--------------------------------------------------------------------------------
1 |
2 | package org.torproject;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | /**
7 | * This is the Tor Project APK signing key. It is used to sign these apps:
8 | *
11 | *
12 | * @author hans
13 | */
14 | public final class TorProjectRSA1024 extends ApkSignaturePin {
15 |
16 | public TorProjectRSA1024() {
17 | fingerprints = new String[] {
18 | "a454b87a1847a89ed7f5e70fba6bba96f3ef29c26e0981204fe347bf231dfd5b",
19 | };
20 | certificates = new byte[][] {
21 | {
22 | 48, -126, 2, 97, 48, -126, 1, -54, -96, 3, 2, 1, 2, 2, 4, 75, -125, 84, 0,
23 | 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, 117, 49, 11,
24 | 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 11, 48, 9, 6, 3, 85, 4, 8, 19, 2,
25 | 78, 89, 49, 17, 48, 15, 6, 3, 85, 4, 7, 19, 8, 78, 101, 119, 32, 89, 111,
26 | 114, 107, 49, 23, 48, 21, 6, 3, 85, 4, 10, 19, 14, 84, 111, 114, 80, 114,
27 | 111, 106, 101, 99, 116, 46, 111, 114, 103, 49, 23, 48, 21, 6, 3, 85, 4, 11,
28 | 19, 14, 84, 111, 114, 80, 114, 111, 106, 101, 99, 116, 46, 111, 114, 103,
29 | 49, 20, 48, 18, 6, 3, 85, 4, 3, 19, 11, 84, 111, 114, 32, 80, 114, 111,
30 | 106, 101, 99, 116, 48, 30, 23, 13, 49, 48, 48, 50, 50, 51, 48, 52, 48, 53,
31 | 50, 48, 90, 23, 13, 51, 55, 48, 55, 49, 49, 48, 52, 48, 53, 50, 48, 90, 48,
32 | 117, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 11, 48, 9, 6, 3, 85,
33 | 4, 8, 19, 2, 78, 89, 49, 17, 48, 15, 6, 3, 85, 4, 7, 19, 8, 78, 101, 119,
34 | 32, 89, 111, 114, 107, 49, 23, 48, 21, 6, 3, 85, 4, 10, 19, 14, 84, 111,
35 | 114, 80, 114, 111, 106, 101, 99, 116, 46, 111, 114, 103, 49, 23, 48, 21, 6,
36 | 3, 85, 4, 11, 19, 14, 84, 111, 114, 80, 114, 111, 106, 101, 99, 116, 46,
37 | 111, 114, 103, 49, 20, 48, 18, 6, 3, 85, 4, 3, 19, 11, 84, 111, 114, 32,
38 | 80, 114, 111, 106, 101, 99, 116, 48, -127, -97, 48, 13, 6, 9, 42, -122, 72,
39 | -122, -9, 13, 1, 1, 1, 5, 0, 3, -127, -115, 0, 48, -127, -119, 2, -127,
40 | -127, 0, -72, 51, -28, 71, -108, 15, -74, 108, -72, 2, 69, -127, -86, -38,
41 | 89, 110, -68, -105, 74, 3, 127, 13, -55, 60, -115, 104, 120, 31, -111, 44,
42 | 34, -46, -32, 21, 62, 40, -127, 51, -128, -57, 110, 89, 121, -100, 122, 96,
43 | -8, -35, -2, -128, 85, -79, 124, 74, -26, 121, -51, -14, 60, 61, 23, -102,
44 | 119, 25, 112, -109, 97, 51, 15, -67, -62, 108, -77, 42, 6, 12, -75, -66,
45 | 76, 99, 80, 27, 78, 17, -86, 31, 11, 126, -102, -113, -46, 95, -85, -91,
46 | -111, -118, -42, 83, -15, -62, 5, 97, 7, -102, 12, -34, 50, 28, 40, 93, 57,
47 | 111, 16, -39, -33, 14, 115, -78, 81, -13, 111, -33, -86, 127, 124, -60,
48 | -20, -31, 2, 3, 1, 0, 1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5,
49 | 5, 0, 3, -127, -127, 0, 11, -111, 99, 127, -23, -63, -88, -96, -91, -3, 5,
50 | -94, 100, 61, 1, -56, -98, -44, -121, -31, -45, 13, 110, 107, 126, -71, 58,
51 | 109, 122, 38, -75, 84, -37, 49, 5, 121, -99, 10, -12, -120, -111, 37, -49,
52 | 67, -74, 90, 100, 63, 125, -94, 21, 83, 70, 57, -14, -116, -69, 46, -27,
53 | 89, 49, 79, 6, 115, 76, -112, -4, 15, 61, 55, -102, 41, -78, -116, 13, 59,
54 | 93, -120, -119, -72, -45, -55, -66, -59, 52, 25, -68, 120, 36, 117, -111,
55 | 98, -55, -106, 37, 121, 123, 77, 28, 36, -111, 45, -94, -26, 121, -127,
56 | -26, 70, 67, 112, 116, 106, 0, -32, -27, 112, 90, 97, 42, -83, 27, -102,
57 | -118, 70, 58, -112, 22, -47
58 | },
59 | };
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/trustedintents/custom_rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
58 |
61 |
62 |
63 |
64 |
65 |
66 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/trustedintents/src/info/guardianproject/GuardianProjectRSA1024.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | /**
7 | * This is the original Guardian Project APK signing key. No new apps will be
8 | * signed by this key, it is considered deprecated since RSA 1024-bit keys are
9 | * deprecated. It is used to sign these apps:
10 | *
11 | * - CACertMan
12 | * - ChatSecure
13 | * - Gnu Privacy Guard
14 | * - Lil' Debi
15 | * - NoteCipher
16 | * - ObscuraCam
17 | * - Orweb
18 | * - PixelKnot
19 | * - StoryMaker
20 | *
21 | *
22 | * @author hans
23 | */
24 | public final class GuardianProjectRSA1024 extends ApkSignaturePin {
25 |
26 | public GuardianProjectRSA1024() {
27 | fingerprints = new String[] {
28 | "d71620711b04dfa13216116fbc8a9f3e3409846b16ff2bacf43e1c5ef5a3ed6b",
29 | };
30 | certificates = new byte[][] {
31 | {
32 | 48, -126, 2, -111, 48, -126, 1, -6, -96, 3, 2, 1, 2, 2, 4, 75, -107, -101,
33 | -63, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, -127,
34 | -116, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 17, 48, 15, 6, 3,
35 | 85, 4, 8, 19, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 17, 48, 15, 6, 3,
36 | 85, 4, 7, 19, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 29, 48, 27, 6, 3,
37 | 85, 4, 10, 19, 20, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114, 111,
38 | 106, 101, 99, 116, 46, 105, 110, 102, 111, 49, 29, 48, 27, 6, 3, 85, 4, 11,
39 | 19, 20, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99,
40 | 116, 46, 105, 110, 102, 111, 49, 25, 48, 23, 6, 3, 85, 4, 3, 19, 16, 71,
41 | 117, 97, 114, 100, 105, 97, 110, 32, 80, 114, 111, 106, 101, 99, 116, 48,
42 | 30, 23, 13, 49, 48, 48, 51, 48, 57, 48, 48, 53, 50, 49, 55, 90, 23, 13, 51,
43 | 55, 48, 55, 50, 53, 48, 48, 53, 50, 49, 55, 90, 48, -127, -116, 49, 11, 48,
44 | 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 17, 48, 15, 6, 3, 85, 4, 8, 19, 8,
45 | 78, 101, 119, 32, 89, 111, 114, 107, 49, 17, 48, 15, 6, 3, 85, 4, 7, 19, 8,
46 | 78, 101, 119, 32, 89, 111, 114, 107, 49, 29, 48, 27, 6, 3, 85, 4, 10, 19,
47 | 20, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116,
48 | 46, 105, 110, 102, 111, 49, 29, 48, 27, 6, 3, 85, 4, 11, 19, 20, 103, 117,
49 | 97, 114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116, 46, 105, 110,
50 | 102, 111, 49, 25, 48, 23, 6, 3, 85, 4, 3, 19, 16, 71, 117, 97, 114, 100,
51 | 105, 97, 110, 32, 80, 114, 111, 106, 101, 99, 116, 48, -127, -97, 48, 13,
52 | 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -127, -115, 0, 48,
53 | -127, -119, 2, -127, -127, 0, -101, -15, 20, 57, 18, -13, 105, 60, 19, 105,
54 | 110, 96, 27, 109, 64, 54, -18, -115, 109, -1, 48, 20, 86, 116, -29, 29,
55 | -120, 37, 1, -111, -52, -83, 3, -81, -83, -91, -55, -51, 4, -80, 14, 1, 92,
56 | -66, -93, 57, -9, 6, -72, -110, -109, -68, 124, 18, -92, 30, -83, -76, 65,
57 | 121, 0, -92, 82, -11, 98, 4, -73, -81, -50, 114, 82, -35, 17, 107, -19, -4,
58 | 16, -53, -62, -57, -121, -69, 85, -91, 51, 43, 17, -110, -65, -105, -54,
59 | -64, -110, -38, 108, 16, -50, 119, -114, 49, -20, 19, -32, 34, -76, -45,
60 | -76, 81, 70, 98, -22, -128, 84, 116, 92, 20, -106, -73, -5, 94, -12, 15,
61 | -86, -74, 47, 98, 121, -33, 2, 3, 1, 0, 1, 48, 13, 6, 9, 42, -122, 72,
62 | -122, -9, 13, 1, 1, 5, 5, 0, 3, -127, -127, 0, 38, 10, 32, 65, -93, 9, 34,
63 | 116, 16, -74, 100, -99, 44, -54, 65, -107, -54, 23, 118, 54, 33, 61, -124,
64 | -105, -27, 95, 18, -70, -61, -82, -20, 117, -28, -121, 71, -75, -118, -9,
65 | -53, 6, -127, 7, 75, -3, -48, 121, -37, 75, 97, 62, 86, -113, -83, -33,
66 | -98, -61, -6, -22, -11, 81, 48, -33, -83, -116, -12, -18, -128, 48, 29, 40,
67 | -17, -91, 119, 98, 40, -41, 48, -117, 31, -41, -33, -47, -18, 126, -26,
68 | -75, -75, 8, 22, 45, -27, -14, -58, 3, 23, -73, -100, 26, -58, 88, -122,
69 | -60, 35, -125, 33, 87, 7, 21, -54, 55, -123, 54, 91, 0, -89, -46, -9, 68,
70 | 121, 15, 69, 103, 22, -26, 126, 83, -22, -57
71 | },
72 | };
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/trustedintents/src/org/iilab/IilabEngineeringRSA2048Pin.java:
--------------------------------------------------------------------------------
1 |
2 | package org.iilab;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | public final class IilabEngineeringRSA2048Pin extends ApkSignaturePin {
7 |
8 | public IilabEngineeringRSA2048Pin() {
9 | fingerprints = new String[] {
10 | "0cac98293ad7814abe161c47dc674c83618e63bae08bd4191bf4927d83fd1ae2",
11 | };
12 | certificates = new byte[][] {
13 | {
14 | 48, -126, 3, 105, 48, -126, 2, 81, -96, 3, 2, 1, 2, 2, 4, 58, 60, 86, 4,
15 | 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 48, 101, 49, 11,
16 | 48, 9, 6, 3, 85, 4, 6, 19, 2, 68, 69, 49, 15, 48, 13, 6, 3, 85, 4, 8, 19,
17 | 6, 66, 101, 114, 108, 105, 110, 49, 15, 48, 13, 6, 3, 85, 4, 7, 19, 6, 66,
18 | 101, 114, 108, 105, 110, 49, 14, 48, 12, 6, 3, 85, 4, 10, 19, 5, 105, 105,
19 | 108, 97, 98, 49, 20, 48, 18, 6, 3, 85, 4, 11, 19, 11, 69, 110, 103, 105,
20 | 110, 101, 101, 114, 105, 110, 103, 49, 14, 48, 12, 6, 3, 85, 4, 3, 19, 5,
21 | 105, 105, 108, 97, 98, 48, 30, 23, 13, 49, 52, 48, 54, 49, 49, 48, 57, 49,
22 | 53, 49, 51, 90, 23, 13, 52, 49, 49, 48, 50, 55, 48, 57, 49, 53, 49, 51,
23 | 90, 48, 101, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 68, 69, 49, 15, 48, 13,
24 | 6, 3, 85, 4, 8, 19, 6, 66, 101, 114, 108, 105, 110, 49, 15, 48, 13, 6, 3,
25 | 85, 4, 7, 19, 6, 66, 101, 114, 108, 105, 110, 49, 14, 48, 12, 6, 3, 85, 4,
26 | 10, 19, 5, 105, 105, 108, 97, 98, 49, 20, 48, 18, 6, 3, 85, 4, 11, 19, 11,
27 | 69, 110, 103, 105, 110, 101, 101, 114, 105, 110, 103, 49, 14, 48, 12, 6,
28 | 3, 85, 4, 3, 19, 5, 105, 105, 108, 97, 98, 48, -126, 1, 34, 48, 13, 6, 9,
29 | 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 15, 0, 48, -126, 1,
30 | 10, 2, -126, 1, 1, 0, -83, -104, -37, 113, -104, 93, -125, -22, 99, -89,
31 | 97, 119, -113, -112, 112, -127, 63, 8, 77, -70, -58, 124, -33, -71, -82,
32 | -45, -72, 97, -18, -85, -122, 111, 22, -24, 95, -97, -42, 24, 121, -116,
33 | 23, -19, 115, 91, -67, 96, -117, 18, 48, -7, -92, -5, 97, -75, -64, 6, -71,
34 | 81, 7, -80, -51, 26, -47, 46, -19, 119, -51, 35, -120, -14, -1, -125, 2,
35 | -117, 66, 109, 19, -18, 61, 28, -65, 42, -116, 63, -81, 2, 56, -22, -91,
36 | 104, 45, -47, -20, 120, 64, -127, 10, -104, 46, -41, -43, 68, 27, -10,
37 | -110, -48, -3, 101, -66, -67, -58, 49, -27, 75, -69, 74, -32, 38, -4, -98,
38 | 58, 79, 94, -57, -121, -64, 53, -53, 22, -25, 97, 41, 105, 94, -119, 12, 1,
39 | 100, -94, -81, 103, 68, 42, -127, 117, 86, 52, -21, 58, -54, 93, 65, -18,
40 | -47, 30, -121, 109, -17, 2, 117, -106, 116, -98, -32, 39, 26, -96, 56, -16,
41 | -124, 6, 75, -101, -122, 126, -17, -21, 42, -53, 70, 57, 84, -111, 3, -34,
42 | 110, -99, -60, 31, 79, 67, -58, -89, -102, -7, -40, 62, 56, 102, 98, 112,
43 | 107, -1, 82, -127, 32, -125, 43, -78, -44, 4, 111, -112, -46, 67, -2, 106,
44 | -32, 118, 19, -93, -68, 50, -103, 111, -128, -1, 96, 30, 49, -97, -94, 88,
45 | 73, 117, -78, -89, 110, -90, 52, 69, 86, -1, 74, -57, 44, -78, 115, -34,
46 | -60, 86, -24, -114, 41, -118, 101, 2, 3, 1, 0, 1, -93, 33, 48, 31, 48, 29,
47 | 6, 3, 85, 29, 14, 4, 22, 4, 20, -23, 8, 8, -50, -119, 109, -22, -102, -122,
48 | -41, 65, -37, -126, 103, -85, 113, 113, 75, 28, -12, 48, 13, 6, 9, 42, -122,
49 | 72, -122, -9, 13, 1, 1, 11, 5, 0, 3, -126, 1, 1, 0, 94, -121, -98, 98, 99,
50 | -40, -99, -81, 63, -76, -74, 67, 4, 8, 69, -114, 113, -22, -44, 9, 44, 103,
51 | 79, 50, 36, -81, 26, -83, 90, -103, 16, 21, -93, 103, -37, -93, -72, -112,
52 | 85, 80, -39, -12, -75, 45, -102, 29, 63, 97, 108, -15, 13, -65, -127, 124,
53 | 89, -84, 84, -119, 119, -76, 126, 39, -4, 26, 41, 87, -32, -119, -94, -107,
54 | -25, 113, 106, -115, -80, 75, 71, -9, 28, 113, 21, 76, 17, -119, -103, -24,
55 | 18, 53, 78, -6, -72, -84, -103, 35, 24, -112, -19, -31, -4, -95, 76, -97,
56 | 55, -52, -93, 42, 77, -23, 99, 10, -70, 106, 72, -112, -93, 94, -44, 13,
57 | -117, 104, 99, 51, -92, 31, -117, -106, 109, 119, -39, 111, 105, -126, -9,
58 | -113, 88, 87, -37, -78, 7, -10, -110, -39, -43, 10, -108, 52, -109, 82, 34,
59 | -45, -28, 70, -29, -119, -28, -5, -121, 98, 124, -71, 65, 24, 33, -30, -111,
60 | -9, -68, -10, -18, 118, 80, -94, -104, -5, -88, 50, -97, 118, -54, 107, 125,
61 | -67, 95, -114, -11, -126, 98, -44, 21, 77, -43, 24, 109, -118, 64, 28, 6,
62 | 64, 39, -109, -28, -45, -86, 113, -49, 115, 23, -46, 4, 91, -58, 118, 75,
63 | 105, 47, 76, -70, -56, -111, 54, -121, 34, 29, 35, 86, -104, -31, 16, -20,
64 | -30, -99, -4, -84, 123, 98, 1, -48, 24, 91, -63, -47, -40, 5, 10, -67, 2,
65 | 126, -9, -126, -80, 77, -59, -103, 6, -43, 32
66 | },
67 | };
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/test/src/com/android/AndroidIncludedAppsPin.java:
--------------------------------------------------------------------------------
1 |
2 | package com.android;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | public final class AndroidIncludedAppsPin extends ApkSignaturePin {
7 |
8 | public AndroidIncludedAppsPin() {
9 | fingerprints = new String[] {
10 | "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc",
11 | };
12 | certificates = new byte[][] {
13 | {
14 | 48, -126, 4, -88, 48, -126, 3, -112, -96, 3, 2, 1, 2, 2, 9, 0, -109, 110,
15 | -84, -66, 7, -14, 1, -33, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,
16 | 5, 5, 0, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49,
17 | 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110,
18 | 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116,
19 | 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19,
20 | 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19,
21 | 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7,
22 | 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122,
23 | -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110,
24 | 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, 30, 23, 13, 48, 56, 48, 50,
25 | 50, 57, 48, 49, 51, 51, 52, 54, 90, 23, 13, 51, 53, 48, 55, 49, 55, 48, 49,
26 | 51, 51, 52, 54, 90, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2,
27 | 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111,
28 | 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117,
29 | 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4,
30 | 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4,
31 | 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4,
32 | 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122,
33 | 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64,
34 | 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, -126, 1, 32, 48,
35 | 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 13, 0, 48,
36 | -126, 1, 8, 2, -126, 1, 1, 0, -42, -109, 25, 4, -34, -58, 11, 36, -79, -19,
37 | -57, 98, -32, -39, -40, 37, 62, 62, -51, 108, -21, 29, -30, -1, 6, -116,
38 | -88, -24, -68, -88, -51, 107, -45, 120, 110, -89, 10, -89, 108, -26, 14,
39 | -69, 15, -103, 53, 89, -1, -39, 62, 119, -87, 67, -25, -24, 61, 75, 100,
40 | -72, -28, -2, -94, -45, -26, 86, -15, -30, 103, -88, 27, -65, -78, 48, -75,
41 | 120, -62, 4, 67, -66, 76, 114, 24, -72, 70, -11, 33, 21, -122, -16, 56,
42 | -95, 78, -119, -62, -66, 56, 127, -114, -66, -49, -113, -54, -61, -38, 30,
43 | -29, 48, -55, -22, -109, -48, -89, -61, -36, 74, -13, 80, 34, 13, 80, 8, 7,
44 | 50, -32, -128, -105, 23, -18, 106, 5, 51, 89, -26, -90, -108, -20, 44, -77,
45 | -14, -124, -96, -92, 102, -56, 122, -108, -40, 59, 49, 9, 58, 103, 55, 46,
46 | 47, 100, 18, -64, 110, 109, 66, -15, 88, 24, -33, -2, 3, -127, -52, 12,
47 | -44, 68, -38, 108, -35, -61, -72, 36, 88, 25, 72, 1, -77, 37, 100, 19, 79,
48 | -65, -34, -104, -55, 40, 119, 72, -37, -11, 103, 106, 84, 13, -127, 84,
49 | -56, -69, -54, 7, -71, -30, 71, 85, 51, 17, -60, 107, -102, -9, 111, -34,
50 | -20, -52, -114, 105, -25, -56, -94, -48, -114, 120, 38, 32, -108, 63, -103,
51 | 114, 125, 60, 4, -2, 114, -103, 29, -103, -33, -101, -82, 56, -96, -78, 23,
52 | 127, -93, 29, 91, 106, -2, -23, 31, 2, 1, 3, -93, -127, -4, 48, -127, -7,
53 | 48, 29, 6, 3, 85, 29, 14, 4, 22, 4, 20, 72, 89, 0, 86, 61, 39, 44, 70, -82,
54 | 17, -122, 5, -92, 116, 25, -84, 9, -54, -116, 17, 48, -127, -55, 6, 3, 85,
55 | 29, 35, 4, -127, -63, 48, -127, -66, -128, 20, 72, 89, 0, 86, 61, 39, 44,
56 | 70, -82, 17, -122, 5, -92, 116, 25, -84, 9, -54, -116, 17, -95, -127, -102,
57 | -92, -127, -105, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85,
58 | 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111,
59 | 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117,
60 | 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4,
61 | 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4,
62 | 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4,
63 | 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122,
64 | 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64,
65 | 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, -126, 9, 0, -109, 110,
66 | -84, -66, 7, -14, 1, -33, 48, 12, 6, 3, 85, 29, 19, 4, 5, 48, 3, 1, 1, -1,
67 | 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 3, -126, 1, 1, 0,
68 | 122, -81, -106, -116, -21, 80, -60, 65, 5, 81, 24, -48, -38, -85, -81, 1,
69 | 91, -118, 118, 90, 39, -89, 21, -94, -62, -76, 79, 34, 20, 21, -1, -38,
70 | -50, 3, 9, 90, -65, -92, 45, -9, 7, 8, 114, 108, 32, 105, -27, -61, 110,
71 | -35, -82, 4, 0, -66, 41, 69, 44, 8, 75, -62, 126, -74, -95, 126, -84, -99,
72 | -66, 24, 44, 32, 78, -79, 83, 17, -12, 85, -40, 36, -74, 86, -37, -28, -36,
73 | 34, 64, -111, 45, 117, -122, -2, -120, -107, 29, 1, -88, -2, -75, -82, 90,
74 | 66, 96, 83, 93, -8, 52, 49, 5, 36, 34, 70, -116, 54, -30, 44, 42, 94, -7,
75 | -108, -42, 29, -41, 48, 106, -28, -55, -10, -107, 27, -93, -63, 47, 29, 25,
76 | 20, -35, -58, 31, 26, 98, -38, 45, -8, 39, -10, 3, -2, -91, 96, 59, 44, 84,
77 | 13, -67, 124, 1, -100, 54, -70, -78, -102, 66, 113, -63, 23, -33, 82, 60,
78 | -37, -59, -13, -127, 122, 73, -32, -17, -90, 12, -67, 127, 116, 23, 126,
79 | 122, 79, 25, 61, 67, -12, 34, 7, 114, 102, 110, 76, 77, -125, -31, -67, 90,
80 | -122, 8, 124, -13, 79, 45, -20, 33, -30, 69, -54, 108, 43, -80, 22, -26,
81 | -125, 99, -128, 80, -46, -60, 48, -18, -89, -62, 106, 28, 73, -45, 118, 10,
82 | 88, -85, 127, 26, -126, -52, -109, -117, 72, 49, 56, 67, 36, -67, 4, 1, -6,
83 | 18, 22, 58, 80, 87, 14, 104, 77
84 | },
85 | };
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/test/src/com/android/AndroidSystemPin.java:
--------------------------------------------------------------------------------
1 |
2 | package com.android;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | public final class AndroidSystemPin extends ApkSignaturePin {
7 |
8 | public AndroidSystemPin() {
9 | fingerprints = new String[] {
10 | "c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8",
11 | };
12 | certificates = new byte[][] {
13 | {
14 | 48, -126, 4, -88, 48, -126, 3, -112, -96, 3, 2, 1, 2, 2, 9, 0, -77, -103,
15 | -128, -122, -48, 86, -49, -6, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1,
16 | 1, 4, 5, 0, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83,
17 | 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114,
18 | 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110,
19 | 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10,
20 | 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11,
21 | 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3,
22 | 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122,
23 | 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64,
24 | 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, 30, 23, 13, 48, 56,
25 | 48, 52, 49, 53, 50, 50, 52, 48, 53, 48, 90, 23, 13, 51, 53, 48, 57, 48, 49,
26 | 50, 50, 52, 48, 53, 48, 90, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6,
27 | 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105,
28 | 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77,
29 | 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6,
30 | 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6,
31 | 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6,
32 | 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9,
33 | 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105,
34 | 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, -126, 1,
35 | 32, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1,
36 | 13, 0, 48, -126, 1, 8, 2, -126, 1, 1, 0, -100, 120, 5, -110, -84, 13, 93,
37 | 56, 28, -34, -86, 101, -20, -56, -90, 0, 110, 54, 72, 12, 109, 114, 7, -79,
38 | 32, 17, -66, 80, -122, 58, -85, -30, -75, 93, 0, -102, -33, 113, 70, -42,
39 | -14, 32, 34, -128, -57, -51, 77, 123, -37, 38, 36, 59, -118, -128, 108, 38,
40 | -77, 75, 19, 117, 35, -92, -110, 104, 34, 73, 4, -36, 1, 73, 62, 124, 10,
41 | -49, 26, 5, -56, 116, -10, -101, 3, 123, 96, 48, -99, -112, 116, -46, 66,
42 | -128, -31, 107, -83, 42, -121, 52, 54, 25, 81, -22, -9, 42, 72, 45, 9, -78,
43 | 4, -79, -121, 94, 18, -84, -104, -63, -86, 119, 61, 104, 0, -71, -22, -3,
44 | -27, 109, 88, -66, -40, -24, -38, 22, -7, -93, 96, 9, -100, 55, -88, 52,
45 | -90, -33, -19, -73, -74, -76, 74, 4, -98, 7, -94, 105, -4, -49, 44, 84,
46 | -106, -14, -49, 54, -42, 77, -7, 10, 59, -115, -113, 52, -93, -70, -85, 76,
47 | -11, 51, 113, -85, 39, 113, -101, 59, -91, -121, 84, -83, 12, 83, -4, 20,
48 | -31, -37, 69, -43, 30, 35, 79, -69, -23, 60, -101, -92, -19, -7, -50, 84,
49 | 38, 19, 80, -20, 83, 86, 7, -65, 105, -94, -1, 74, -96, 125, -75, -9, -22,
50 | 32, 13, 9, -90, -63, -76, -98, 33, 64, 47, -119, -19, 17, -112, -119, 58,
51 | -85, 90, -111, -128, -15, 82, -24, 47, -123, -92, 87, 83, -49, 95, -63,
52 | -112, 113, -59, -18, -56, 39, 2, 1, 3, -93, -127, -4, 48, -127, -7, 48, 29,
53 | 6, 3, 85, 29, 14, 4, 22, 4, 20, 79, -28, -96, -77, -35, -100, -70, 41, -9,
54 | 29, 114, -121, -60, -25, -61, -113, 32, -122, -62, -103, 48, -127, -55, 6,
55 | 3, 85, 29, 35, 4, -127, -63, 48, -127, -66, -128, 20, 79, -28, -96, -77,
56 | -35, -100, -70, 41, -9, 29, 114, -121, -60, -25, -61, -113, 32, -122, -62,
57 | -103, -95, -127, -102, -92, -127, -105, 48, -127, -108, 49, 11, 48, 9, 6,
58 | 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97,
59 | 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19,
60 | 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16,
61 | 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16,
62 | 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16,
63 | 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34,
64 | 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100,
65 | 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109,
66 | -126, 9, 0, -77, -103, -128, -122, -48, 86, -49, -6, 48, 12, 6, 3, 85, 29,
67 | 19, 4, 5, 48, 3, 1, 1, -1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,
68 | 4, 5, 0, 3, -126, 1, 1, 0, 87, 37, 81, -72, -39, 58, 31, 115, -34, 15, 109,
69 | 70, -97, -122, -38, -42, 112, 20, 0, 41, 60, -120, -96, -51, 124, -41, 120,
70 | -73, 61, -81, -52, 25, 127, -85, 118, -26, 33, 46, 86, -63, -57, 97, -49,
71 | -60, 47, -41, 51, -34, 82, -59, 10, -32, -120, 20, -50, -4, 10, 59, 90, 26,
72 | 67, 70, 5, 77, -126, -97, 29, -126, -76, 43, 32, 72, -65, -120, -75, -47,
73 | 73, 41, -17, -123, -10, 14, -35, 18, -41, 45, 85, 101, 126, 34, -29, -24,
74 | 93, 4, -56, 49, -42, 19, -47, -103, 56, -69, -119, -126, 36, 127, -93, 33,
75 | 37, 107, -95, 45, 29, 106, -113, -110, -22, 29, -79, -61, 115, 49, 123,
76 | -96, -64, 55, -16, -47, -81, -10, 69, -82, -14, 36, -105, -97, -70, 110,
77 | 122, 20, -68, 2, 92, 113, -71, -127, 56, -50, -13, -35, -4, 5, -106, 23,
78 | -49, 36, -124, 92, -9, -76, 13, 99, -126, -9, 39, 94, -41, 56, 73, 90, -74,
79 | -27, -109, 27, -108, 33, 118, 92, 73, 27, 114, -5, 104, -32, -128, -37,
80 | -37, 88, -62, 2, -99, 52, 124, -117, 50, -116, -28, 62, -10, -88, -79, 85,
81 | 51, -19, -5, -23, -119, -67, 106, 72, -35, 75, 32, 46, -38, -108, -58, -85,
82 | -115, -43, -72, 57, -110, 3, -38, -82, 46, -44, 70, 35, 46, 79, -23, -67,
83 | -106, 19, -108, -58, 48, 14, 81, 56, -29, -49, -46, -123, -26, -28, -28,
84 | -125, 83, -116, -72, -79, -77, 87
85 | },
86 | };
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/trustedintents/src/info/guardianproject/GuardianProjectRSA4096.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject;
3 |
4 | import info.guardianproject.trustedintents.ApkSignaturePin;
5 |
6 | /**
7 | * This is the second Guardian Project APK signing key. It was generated since
8 | * RSA 1024-bit keys are deprecated. So any new Guardian Project app will be
9 | * signed by this key. It is used to sign these apps:
10 | *
11 | * - Checkey
12 | * - Courier
13 | *
14 | *
15 | * @author hans
16 | */
17 | public final class GuardianProjectRSA4096 extends ApkSignaturePin {
18 |
19 | public GuardianProjectRSA4096() {
20 | fingerprints = new String[] {
21 | "f006a20481c71a690de02e385ab0c9fa4ac1245240f68102682703ba0656867a",
22 | };
23 | certificates = new byte[][] {
24 | {
25 | 48, -126, 5, -84, 48, -126, 3, -108, 2, 9, 0, -126, -20, 93, -43, 112, 34,
26 | -87, 29, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, -127,
27 | -105, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 17, 48, 15, 6, 3,
28 | 85, 4, 8, 12, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 17, 48, 15, 6, 3,
29 | 85, 4, 7, 12, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 25, 48, 23, 6, 3,
30 | 85, 4, 10, 12, 16, 71, 117, 97, 114, 100, 105, 97, 110, 32, 80, 114, 111,
31 | 106, 101, 99, 116, 49, 29, 48, 27, 6, 3, 85, 4, 3, 12, 20, 103, 117, 97,
32 | 114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116, 46, 105, 110,
33 | 102, 111, 49, 40, 48, 38, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22,
34 | 25, 114, 111, 111, 116, 64, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114,
35 | 111, 106, 101, 99, 116, 46, 105, 110, 102, 111, 48, 30, 23, 13, 49, 52, 48,
36 | 53, 49, 52, 49, 55, 53, 55, 50, 57, 90, 23, 13, 52, 49, 48, 57, 50, 56, 49,
37 | 55, 53, 55, 50, 57, 90, 48, -127, -105, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19,
38 | 2, 85, 83, 49, 17, 48, 15, 6, 3, 85, 4, 8, 12, 8, 78, 101, 119, 32, 89,
39 | 111, 114, 107, 49, 17, 48, 15, 6, 3, 85, 4, 7, 12, 8, 78, 101, 119, 32, 89,
40 | 111, 114, 107, 49, 25, 48, 23, 6, 3, 85, 4, 10, 12, 16, 71, 117, 97, 114,
41 | 100, 105, 97, 110, 32, 80, 114, 111, 106, 101, 99, 116, 49, 29, 48, 27, 6,
42 | 3, 85, 4, 3, 12, 20, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114, 111,
43 | 106, 101, 99, 116, 46, 105, 110, 102, 111, 49, 40, 48, 38, 6, 9, 42, -122,
44 | 72, -122, -9, 13, 1, 9, 1, 22, 25, 114, 111, 111, 116, 64, 103, 117, 97,
45 | 114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116, 46, 105, 110,
46 | 102, 111, 48, -126, 2, 34, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,
47 | 1, 5, 0, 3, -126, 2, 15, 0, 48, -126, 2, 10, 2, -126, 2, 1, 0, -51, 108,
48 | 83, -44, 61, 81, 46, 61, 2, -61, 46, 60, 2, -30, 44, 38, -70, -63, -93,
49 | -66, -57, 1, 2, -32, -80, -82, 98, -26, -70, -34, 60, -65, -55, -43, 16,
50 | -63, -89, -104, 50, 108, -26, -2, -3, -55, -77, 47, 75, 89, 99, 12, -32,
51 | 32, 120, -26, -81, 54, 95, -57, -114, -100, -39, -110, -4, 120, 90, 90,
52 | -40, -89, -53, 63, -122, -45, -80, 32, -6, -12, -29, -107, 45, 10, -23, 76,
53 | 5, 112, -15, -63, 48, 35, -61, 0, -107, -110, 44, -46, -126, -30, -30, -33,
54 | 86, 22, 30, 8, -72, 29, 75, 121, 31, -120, 119, 59, -57, 19, -64, 31, 84,
55 | -94, -38, 91, 82, 92, -95, 66, 2, 120, -37, -113, 126, 54, -83, 83, -125,
56 | 122, 110, -106, 80, 59, -127, -72, -23, 64, 105, 20, 25, -41, -3, -61, -44,
57 | 51, -28, 17, 36, -90, -18, -25, 96, 37, -93, -48, 98, 47, 27, 49, 40, -31,
58 | -62, -102, -49, 28, -55, 50, -38, -70, -83, 101, 97, 96, -122, -114, 18,
59 | 47, 119, 117, -7, -55, -64, -1, 96, -120, 61, -89, -70, -7, -89, 113, -41,
60 | 88, 27, 26, 95, -52, 53, 59, 7, 11, 79, 86, 31, -109, -21, 120, -15, 38,
61 | 106, 33, -121, 82, 18, 45, 32, 49, 93, -26, -74, -104, 4, -122, 96, 39,
62 | 126, -24, 16, 119, -45, -119, 110, -31, 55, -109, 53, 53, -11, -58, -124,
63 | -84, 41, -42, 64, 17, -5, -78, -57, -100, 118, -105, -38, -94, 84, -16,
64 | -53, -106, -11, 76, 81, 70, -83, -56, 73, -96, -100, -18, 55, -3, -3, 34,
65 | -97, -62, 59, -17, -79, 91, -9, 122, 95, -108, -121, -76, -62, -72, 61,
66 | -82, 105, -99, -59, 10, 51, 52, 77, -105, -127, 37, 79, 88, -127, 27, 39,
67 | 44, 15, 123, -59, -118, -96, 61, -28, 23, -54, 124, 100, 57, 37, 123, -83,
68 | -124, 11, 123, 73, -53, 18, 119, -39, -13, 46, 123, -55, 4, -91, 114, 93,
69 | -116, -98, 21, 95, -30, -82, -108, 87, -65, -8, 30, 67, 14, 22, 79, -64,
70 | 86, -128, -83, 74, 69, -42, 9, -18, -120, -52, 7, 62, 78, 88, -53, -125,
71 | 41, -122, -91, -34, -110, 111, -118, -25, 25, -83, 90, -95, 84, -121, 95,
72 | 72, -53, -14, -14, -48, 65, 4, 23, 99, 56, 23, -20, 9, 46, 63, 83, -26,
73 | -86, 54, -104, 79, 9, 94, -91, -69, 10, -125, -17, -28, -32, -79, 5, -11,
74 | 37, 103, -46, -75, 71, -119, 39, 48, -53, -51, 118, 43, 28, 68, 14, -33,
75 | -82, -76, -98, 1, 41, 94, -128, -86, 51, -89, 17, -31, 38, -70, -2, -27,
76 | -105, -87, 103, 93, 19, 73, -106, -82, -76, 110, -48, -124, -51, 92, -91,
77 | -51, 22, 1, -48, 52, -127, -24, 26, -77, 4, 22, 33, 24, -128, -1, 9, -42,
78 | 23, -53, 78, 10, -39, -115, -95, 17, 100, 90, 16, -23, -127, -38, 10, -62,
79 | -64, 113, -115, -114, 78, -11, -124, 113, 113, -42, -66, 114, -98, -40,
80 | -41, 2, 3, 1, 0, 1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5,
81 | 0, 3, -126, 2, 1, 0, -54, 125, -113, -9, -45, 82, 2, -79, -87, 31, -17,
82 | -10, 117, 16, 1, 67, -63, 57, -49, -81, -90, 48, 7, -58, 89, -29, 120, 84,
83 | 116, 51, 54, -94, 74, -111, -11, 53, -13, 53, -125, -76, -64, 46, -35, 19,
84 | -19, 25, 36, -82, 66, 113, -14, -6, -63, 83, 15, 8, -77, -74, -94, -53,
85 | -35, -61, -75, 52, 13, -128, 9, 96, 66, 46, 46, -57, 24, -28, -39, -46, 96,
86 | -115, -63, 92, -70, 51, 49, -94, 96, 77, 16, 108, -59, -28, 112, -2, -3,
87 | -87, 27, 56, 118, 29, -95, -76, -70, 34, -105, -24, -104, 70, 24, -88, -29,
88 | -28, -101, -98, 24, -48, -32, -111, 97, 61, -70, -21, -111, 70, -55, 68,
89 | -76, 125, -61, 56, -122, 48, -118, 74, 61, -101, -46, -43, -12, -114, -116,
90 | -57, -108, 91, -109, -62, -117, -76, -48, 109, 81, -22, -113, -73, 64, -61,
91 | 102, 92, -117, -9, -100, 62, -90, 99, 102, -50, -41, -75, 31, 5, -76, -31,
92 | -85, 118, -57, -21, 102, 71, 41, -34, -45, -92, 88, 82, -95, 65, -100, -31,
93 | -28, -85, -37, 94, -52, 72, 39, 55, -42, 18, 29, 115, 23, -106, -2, -54,
94 | -45, 61, 53, 62, 107, 109, -65, 69, 4, -123, 124, -30, -54, -44, 38, 119,
95 | 49, -123, -27, -50, 77, -9, -40, -114, -50, -70, -123, 86, -115, 127, 45,
96 | 42, 23, -25, -83, -81, -38, -84, -3, 99, -36, 12, -67, -39, -110, 21, -40,
97 | -128, 6, -96, -24, -116, -62, 63, 127, 39, 57, -83, -63, 0, 127, -12, 73,
98 | 85, -41, -101, -70, -48, -94, -94, -73, -38, -115, -62, -34, 62, -92, 96,
99 | 16, 6, -19, -84, 38, -93, -117, -52, 32, 92, -21, 123, -117, 81, 50, -71,
100 | 103, 121, 127, 4, -3, -40, 62, 100, 22, -123, -68, -69, -54, -127, -67, 50,
101 | -114, 77, -30, 26, -102, 29, 106, 48, 83, 99, 73, 96, 124, -77, 51, 8, 15,
102 | 40, 72, -108, 105, 62, 119, -113, -90, 57, -62, 127, -57, -21, -40, -109,
103 | 96, 101, 71, -40, -101, 127, 69, 110, 43, 59, -102, -8, -42, -70, -24, 51,
104 | -51, 54, 42, -110, -119, 41, -101, 45, -101, -124, 56, -75, -26, 86, -65,
105 | 54, 21, -88, -30, 79, -26, -127, 121, -102, -48, -25, -62, 99, 76, -90,
106 | -48, -37, 123, 9, 67, 51, -41, -116, 29, 69, 88, 93, -42, 23, 73, -112, 24,
107 | -85, 60, 1, 3, -95, 12, -49, -55, 95, 109, -37, 10, -124, 119, -52, -31,
108 | 91, 55, -67, 99, 87, -55, 97, 25, -9, -119, -41, -98, 100, -14, 70, -44,
109 | -63, 60, -127, -99, 15, 49, 22, -118, -49, 66, -106, 36, -34, -5, 6, -48,
110 | 123, -79, 115, 57, 30, -3, -34, -67, 91, 34, 3, -52, -106, 79, -63, 125,
111 | 123, -16, -120, -53, -98, 34, 86, -60, 94, 78, -91, -34, 0, -8, 73, -119,
112 | -87, 12, -101, -112, -10, -79, 10, 105, -82, 120, -106, -9, 99, 57, -63,
113 | -26, 125, -80, 102, -106, -11, -91, -1, 37, 33
114 | },
115 | };
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/trustedintents/src/info/guardianproject/trustedintents/TrustedIntents.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents;
3 |
4 | import android.app.Activity;
5 | import android.content.ActivityNotFoundException;
6 | import android.content.ComponentName;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.pm.ActivityInfo;
10 | import android.content.pm.PackageInfo;
11 | import android.content.pm.PackageManager;
12 | import android.content.pm.PackageManager.NameNotFoundException;
13 | import android.content.pm.ResolveInfo;
14 | import android.content.pm.Signature;
15 | import android.text.TextUtils;
16 | import android.util.Log;
17 |
18 | import java.lang.reflect.Constructor;
19 | import java.security.cert.CertificateException;
20 | import java.util.LinkedHashSet;
21 |
22 | public class TrustedIntents {
23 |
24 | private static TrustedIntents instance;
25 |
26 | private static PackageManager pm;
27 |
28 | private final LinkedHashSet pinList;
29 |
30 | private TrustedIntents(Context context) {
31 | pm = context.getPackageManager();
32 | this.pinList = new LinkedHashSet();
33 | }
34 |
35 | public static TrustedIntents get(Context context) {
36 | if (instance == null)
37 | instance = new TrustedIntents(context);
38 | return instance;
39 | }
40 |
41 | /**
42 | * Check whether a resolved {@link Activity} is trusted.
43 | *
44 | * @param resolveInfo the one to check
45 | * @return whether the {@code Intent}'s receiver is trusted
46 | */
47 | public boolean isReceiverTrusted(ResolveInfo resolveInfo) {
48 | return isPackageNameTrusted(resolveInfo.activityInfo.packageName);
49 | }
50 |
51 | /**
52 | * Check whether a resolved {@link Activity} is trusted.
53 | *
54 | * @param activityInfo the one to check
55 | * @return whether the {@code Intent}'s receiver is trusted
56 | */
57 | public boolean isReceiverTrusted(ActivityInfo activityInfo) {
58 | return isPackageNameTrusted(activityInfo.packageName);
59 | }
60 |
61 | /**
62 | * Check an {@link Intent} is trusted based on the {@code packageName} set
63 | * by {@link Intent#setPackage(String)}
64 | *
65 | * @param intent the one to check
66 | * @return whether the {@code Intent}'s receiver is trusted
67 | */
68 | public boolean isReceiverTrusted(Intent intent) {
69 | if (!isIntentSane(intent))
70 | return false;
71 | String packageName = intent.getPackage();
72 | if (TextUtils.isEmpty(packageName)) {
73 | packageName = intent.getComponent().getPackageName();
74 | }
75 | return isPackageNameTrusted(packageName);
76 | }
77 |
78 | /**
79 | * Check whether a {@code packageName} is trusted.
80 | *
81 | * @param packageName the one to check
82 | * @return whether the {@code packageName} is trusted
83 | */
84 | public boolean isPackageNameTrusted(String packageName) {
85 | try {
86 | checkTrustedSigner(packageName);
87 | } catch (NameNotFoundException e) {
88 | e.printStackTrace();
89 | return false;
90 | } catch (CertificateException e) {
91 | return false;
92 | }
93 | return true;
94 | }
95 |
96 | /**
97 | * Returns an {@link Intent} if the sending app is signed by one of
98 | * the trusted signing keys as set in {@link #addTrustedSigner(Class)}.
99 | *
100 | * @returns {@code null} if there is no {@code Intent} or if the
101 | * sender is not trusted.
102 | * @see #addTrustedSigner(Class)
103 | */
104 | public Intent getIntentFromTrustedSender(Activity activity) {
105 | Intent intent = activity.getIntent();
106 | String packageName = getCallingPackageName(activity);
107 | if (TextUtils.isEmpty(packageName)) {
108 | return null;
109 | }
110 | if (isPackageNameTrusted(packageName)) {
111 | return intent;
112 | }
113 | return null;
114 | }
115 |
116 | /**
117 | * Get the package name of the {@link Activity} that sent the
118 | * {@link Intent} that started this {@code Activity}.
119 | *
120 | * WARNING: If the {@code Activity} has
121 | * {@code android:launchMode="singleInstance"} or {@code "singleTask"}, then
122 | * this method will not disconnect because it is not possible to get the
123 | * calling {@code Activity}, as set by
124 | * {@link Activity#startActivityForResult(Intent, int)}
125 | *
126 | * @param activity the {@code Activity} to check for the {@code Intent}
127 | * @return the package of the sending app or {@code null} if it was not a
128 | * {@code ACTION_CONNECT Intent} or the {@code Intent} was not sent
129 | * with {@link Activity#startActivityForResult(Intent, int)}
130 | */
131 | public static String getCallingPackageName(Activity activity) {
132 | // getCallingPackage() was unstable until android-18, use this
133 | ComponentName componentName = activity.getCallingActivity();
134 | if (componentName == null)
135 | return null;
136 | String packageName = componentName.getPackageName();
137 | if (TextUtils.isEmpty(packageName)) {
138 | Log.e(activity.getClass().getSimpleName(),
139 | "Received Intent without sender! The Intent must be sent using startActivityForResult() and received without launchMode singleTask or singleInstance!");
140 | }
141 | return packageName;
142 | }
143 |
144 | /**
145 | * This is used to check whether an {@link Intent} that will be sent is
146 | * complete. It should not be used with {@code Intent}s
147 | * that have been received already.
148 | */
149 | private boolean isIntentSane(Intent intent) {
150 | if (intent == null)
151 | return false;
152 | if (TextUtils.isEmpty(intent.getPackage())) {
153 | ComponentName componentName = intent.getComponent();
154 | if (componentName == null || TextUtils.isEmpty(componentName.getPackageName())) {
155 | return false;
156 | }
157 | }
158 | return true;
159 | }
160 |
161 | /**
162 | * Add an APK signature that is always trusted for any packageName.
163 | *
164 | * @param cls {@link Class} of the {@link ApkSignaturePin} to trust
165 | * @return boolean
166 | * @throws {@link IllegalArgumentException} the class cannot be instantiated
167 | */
168 | public boolean addTrustedSigner(Class extends ApkSignaturePin> cls) {
169 | try {
170 | Constructor extends ApkSignaturePin> constructor = cls.getConstructor();
171 | return pinList.add((ApkSignaturePin) constructor.newInstance((Object[]) null));
172 | } catch (Exception e) {
173 | e.printStackTrace();
174 | throw new IllegalArgumentException(e);
175 | }
176 | }
177 |
178 | /**
179 | * Remove an APK signature from the trusted set.
180 | *
181 | * @param cls {@link Class} of the {@link ApkSignaturePin} to remove
182 | */
183 | public boolean removeTrustedSigner(Class extends ApkSignaturePin> cls) {
184 | for (ApkSignaturePin pin : pinList) {
185 | if (pin.getClass().equals(cls)) {
186 | return pinList.remove(pin);
187 | }
188 | }
189 | return false;
190 | }
191 |
192 | /**
193 | * Remove all {@link ApkSignaturePin}s from the trusted set.
194 | */
195 | public boolean removeAllTrustedSigners() {
196 | pinList.clear();
197 | return pinList.isEmpty();
198 | }
199 |
200 | /**
201 | * Check if a {@link ApkSignaturePin} is trusted.
202 | *
203 | * @param cls {@link Class} of the {@link ApkSignaturePin} to check
204 | */
205 | public boolean isTrustedSigner(Class extends ApkSignaturePin> cls) {
206 | for (ApkSignaturePin pin : pinList) {
207 | if (pin.getClass().equals(cls)) {
208 | return true;
209 | }
210 | }
211 | return false;
212 | }
213 |
214 | public void checkTrustedSigner(String packageName)
215 | throws NameNotFoundException, CertificateException {
216 | PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
217 | checkTrustedSigner(packageInfo.signatures);
218 | }
219 |
220 | public void checkTrustedSigner(PackageInfo packageInfo)
221 | throws NameNotFoundException, CertificateException {
222 | checkTrustedSigner(packageInfo.signatures);
223 | }
224 |
225 | public void checkTrustedSigner(Signature[] signatures)
226 | throws NameNotFoundException, CertificateException {
227 | if (signatures == null || signatures.length == 0)
228 | throw new CertificateException("signatures cannot be null or empty!");
229 | for (int i = 0; i < signatures.length; i++)
230 | if (signatures[i] == null || signatures[i].toByteArray().length == 0)
231 | throw new CertificateException("Certificates cannot be null or empty!");
232 |
233 | // check whether the APK signer is trusted for all apps
234 | for (ApkSignaturePin pin : pinList)
235 | if (areSignaturesEqual(signatures, pin.getSignatures()))
236 | return; // found a matching trusted APK signer
237 |
238 | throw new CertificateException("APK signatures did not match!");
239 | }
240 |
241 | public boolean areSignaturesEqual(Signature[] sigs0, Signature[] sigs1) {
242 | // TODO where is Android's implementation of this that I can just call?
243 | if (sigs0 == null || sigs1 == null)
244 | return false;
245 | if (sigs0.length == 0 || sigs1.length == 0)
246 | return false;
247 | if (sigs0.length != sigs1.length)
248 | return false;
249 | for (int i = 0; i < sigs0.length; i++)
250 | if (!sigs0[i].equals(sigs1[i]))
251 | return false;
252 | return true;
253 | }
254 |
255 | public void startActivity(Context context, Intent intent) throws CertificateException {
256 | if (!isIntentSane(intent))
257 | throw new ActivityNotFoundException("The intent was null or empty!");
258 | String packageName = intent.getPackage();
259 | if (TextUtils.isEmpty(packageName)) {
260 | packageName = intent.getComponent().getPackageName();
261 | intent.setPackage(packageName);
262 | }
263 | try {
264 | checkTrustedSigner(packageName);
265 | } catch (NameNotFoundException e) {
266 | e.printStackTrace();
267 | throw new ActivityNotFoundException(e.getLocalizedMessage());
268 | }
269 | context.startActivity(intent);
270 | }
271 | }
272 |
--------------------------------------------------------------------------------
/test/src/info/guardianproject/trustedintents/test/TrustedIntentsTests.java:
--------------------------------------------------------------------------------
1 |
2 | package info.guardianproject.trustedintents.test;
3 |
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.pm.ActivityInfo;
8 | import android.content.pm.PackageInfo;
9 | import android.content.pm.PackageManager;
10 | import android.content.pm.PackageManager.NameNotFoundException;
11 | import android.content.pm.ResolveInfo;
12 | import android.content.pm.Signature;
13 | import android.test.AndroidTestCase;
14 | import android.text.TextUtils;
15 | import android.util.Log;
16 |
17 | import com.android.AndroidIncludedAppsPin;
18 | import com.android.AndroidSystemPin;
19 |
20 | import info.guardianproject.trustedintents.ApkSignaturePin;
21 | import info.guardianproject.trustedintents.TrustedIntents;
22 |
23 | import java.util.ArrayList;
24 |
25 | public class TrustedIntentsTests extends AndroidTestCase {
26 | private static final String TAG = "TrustedIntentsTests";
27 |
28 | Context context;
29 | PackageManager pm;
30 | TrustedIntents ti;
31 | String[] packagesSignedByAndroidIncludedApps;
32 | String[] packagesSignedByAndroidSystem;
33 |
34 | private static String[] getInstalledApps(PackageManager pm, String[] packages) {
35 | ArrayList installedPackages = new ArrayList(packages.length);
36 | for (String packageName : packages) {
37 | try {
38 | pm.getPackageInfo(packageName, 0);
39 | installedPackages.add(packageName);
40 | } catch (NameNotFoundException e) {
41 | Log.w(TAG, packageName + " not installed on this device");
42 | }
43 | }
44 | return installedPackages.toArray(new String[0]);
45 | }
46 |
47 | static String[] getAndroidIncludedApps(PackageManager pm) {
48 | String[] androidIncludedApps = {
49 | "com.android.browser", "com.android.calculator2", "com.android.calendar",
50 | "com.android.dreams.basic", "com.android.providers.calendar",
51 | "com.android.camera", "com.android.deskclock", "com.android.gesture.builder",
52 | "com.android.smoketest", "com.android.smoketest.tests",
53 | "com.android.emulator.connectivity.test", "com.android.development_settings",
54 | "com.android.email", "com.example.android.livecubes", "com.android.exchange"
55 | };
56 | return getInstalledApps(pm, androidIncludedApps);
57 | }
58 |
59 | static String[] getAndroidSystem(PackageManager pm) {
60 | String[] androidSystem = {
61 | "android", "com.android.certinstaller", "com.android.backupconfirm",
62 | "com.android.keyguard", "com.android.sdksetup", "com.android.sharedstoragebackup",
63 | "com.android.customlocale2", "com.android.development", "com.android.documentsui",
64 | "com.android.externalstorage", "com.android.location.fused",
65 | "com.android.inputdevices"
66 | };
67 | return getInstalledApps(pm, androidSystem);
68 | }
69 |
70 | @Override
71 | public void setUp() {
72 | context = getContext();
73 | pm = context.getPackageManager();
74 | ti = TrustedIntents.get(context);
75 | ti.removeAllTrustedSigners();
76 |
77 | packagesSignedByAndroidIncludedApps = getAndroidIncludedApps(pm);
78 | packagesSignedByAndroidSystem = getAndroidSystem(pm);
79 | }
80 |
81 | private void checkAreSignaturesEqual(String[] packages) {
82 | Signature[] first = null;
83 | Signature[] second = null;
84 | for (int i = 0; i < packages.length; i++) {
85 | try {
86 | PackageInfo pkgInfo = pm.getPackageInfo(packages[i], PackageManager.GET_SIGNATURES);
87 | first = pkgInfo.signatures;
88 | } catch (NameNotFoundException e) {
89 | Log.w(TAG, "NameNotFoundException on " + packages[i] + ": " + e.getMessage());
90 | continue;
91 | }
92 | for (int j = 0; j < packages.length; j++) {
93 | if (i == j)
94 | continue;
95 | try {
96 | PackageInfo pkgInfo = pm.getPackageInfo(packages[j],
97 | PackageManager.GET_SIGNATURES);
98 | second = pkgInfo.signatures;
99 | } catch (NameNotFoundException e) {
100 | Log.w(TAG, "NameNotFoundException: " + e.getMessage());
101 | continue;
102 | }
103 | assertTrue(TrustedIntents.get(context).areSignaturesEqual(first, second));
104 | }
105 | }
106 | }
107 |
108 | /**
109 | * Intent stores this info internally using {@link CompenentName}, so we're
110 | * using that as the method for setting it. It can also be set using
111 | * {@link Intent#setClassName(String, String) setClassName()}, and it is
112 | * then translated to a {@link ComponentName}.
113 | *
114 | * @param packageName
115 | * @return
116 | */
117 | private Intent getLauncherIntent(String packageName) {
118 | Intent i = new Intent(Intent.ACTION_MAIN);
119 | i.setPackage(packageName);
120 | i.addCategory(Intent.CATEGORY_LAUNCHER);
121 | ResolveInfo resolveInfo = pm.resolveActivity(i, PackageManager.MATCH_DEFAULT_ONLY);
122 | if (TextUtils.isEmpty(packageName) || resolveInfo == null)
123 | return i;
124 | ActivityInfo activityInfo = resolveInfo.activityInfo;
125 | assertEquals(activityInfo.packageName, packageName);
126 | return new Intent(Intent.ACTION_MAIN)
127 | .setComponent(new ComponentName(packageName, activityInfo.name));
128 | }
129 |
130 | public void testCheckAreSignaturesEqual() {
131 | checkAreSignaturesEqual(packagesSignedByAndroidIncludedApps);
132 | checkAreSignaturesEqual(packagesSignedByAndroidSystem);
133 | }
134 |
135 | public void testCheckAreSignaturesNotEqual() {
136 | assertFalse(TrustedIntents.get(context).areSignaturesEqual(
137 | new AndroidIncludedAppsPin().getSignatures(),
138 | new AndroidSystemPin().getSignatures()));
139 | PackageInfo pkgInfo;
140 | Signature[] first = null;
141 | Signature[] second = null;
142 | int length = packagesSignedByAndroidSystem.length;
143 | if (length > packagesSignedByAndroidIncludedApps.length)
144 | length = packagesSignedByAndroidIncludedApps.length;
145 | for (int i = 0; i < length; i++) {
146 | try {
147 | pkgInfo = pm.getPackageInfo(
148 | packagesSignedByAndroidSystem[i],
149 | PackageManager.GET_SIGNATURES);
150 | first = pkgInfo.signatures;
151 | pkgInfo = pm.getPackageInfo(
152 | packagesSignedByAndroidIncludedApps[i],
153 | PackageManager.GET_SIGNATURES);
154 | second = pkgInfo.signatures;
155 | } catch (NameNotFoundException e) {
156 | Log.w(TAG, "NameNotFoundException: " + e.getMessage());
157 | continue;
158 | }
159 | assertFalse(TrustedIntents.get(context).areSignaturesEqual(first, second));
160 | }
161 | }
162 |
163 | public void testSetPinWithAbstractClass() {
164 | try {
165 | ti.addTrustedSigner(ApkSignaturePin.class);
166 | } catch (IllegalArgumentException e) {
167 | assertEquals(e.getClass(), IllegalArgumentException.class);
168 | }
169 | assert false;
170 | }
171 |
172 | public void testIsTrustedSigner() {
173 | assertFalse(ti.isTrustedSigner(AndroidSystemPin.class));
174 | assertFalse(ti.isTrustedSigner(AndroidIncludedAppsPin.class));
175 | /* add one pin as trusted */
176 | assertTrue(ti.addTrustedSigner(AndroidSystemPin.class));
177 | assertTrue(ti.isTrustedSigner(AndroidSystemPin.class));
178 | assertFalse(ti.isTrustedSigner(AndroidIncludedAppsPin.class));
179 | /* add the other pin as trusted */
180 | assertTrue(ti.addTrustedSigner(AndroidIncludedAppsPin.class));
181 | assertTrue(ti.isTrustedSigner(AndroidSystemPin.class));
182 | assertTrue(ti.isTrustedSigner(AndroidIncludedAppsPin.class));
183 | }
184 |
185 | public void testCheckPin() {
186 | Intent intent;
187 |
188 | assertFalse(ti.isReceiverTrusted(new Intent()));
189 | intent = new Intent();
190 | intent.setPackage("");
191 | assertFalse(ti.isReceiverTrusted(intent));
192 | assertFalse(ti.isReceiverTrusted(getLauncherIntent("")));
193 |
194 | for (String packageName : packagesSignedByAndroidSystem) {
195 | assertFalse(ti.isReceiverTrusted(getLauncherIntent(packageName)));
196 | intent = new Intent();
197 | intent.setPackage(packageName);
198 | assertFalse(ti.isReceiverTrusted(intent));
199 | }
200 |
201 | /* packages signed by AndroidSystem should be trusted, others not */
202 | assertTrue(ti.addTrustedSigner(AndroidSystemPin.class));
203 | for (String packageName : packagesSignedByAndroidSystem) {
204 | assertTrue(ti.isReceiverTrusted(getLauncherIntent(packageName)));
205 | intent = new Intent();
206 | intent.setPackage(packageName);
207 | assertTrue(ti.isReceiverTrusted(intent));
208 | }
209 | for (String packageName : packagesSignedByAndroidIncludedApps) {
210 | assertFalse(ti.isReceiverTrusted(getLauncherIntent(packageName)));
211 | intent = new Intent();
212 | intent.setPackage(packageName);
213 | assertFalse(ti.isReceiverTrusted(intent));
214 | }
215 |
216 | /* all should be trusted now */
217 | assertTrue(ti.addTrustedSigner(AndroidIncludedAppsPin.class));
218 | for (String packageName : packagesSignedByAndroidSystem) {
219 | assertTrue(ti.isReceiverTrusted(getLauncherIntent(packageName)));
220 | intent = new Intent();
221 | intent.setPackage(packageName);
222 | assertTrue(ti.isReceiverTrusted(intent));
223 | }
224 | for (String packageName : packagesSignedByAndroidIncludedApps) {
225 | assertTrue(ti.isReceiverTrusted(getLauncherIntent(packageName)));
226 | intent = new Intent();
227 | intent.setPackage(packageName);
228 | assertTrue(ti.isReceiverTrusted(intent));
229 | }
230 | }
231 |
232 | public void testRemovePin() {
233 | Intent intent;
234 |
235 | assertFalse(ti.isReceiverTrusted(new Intent()));
236 | intent = new Intent();
237 | intent.setPackage("");
238 | assertFalse(ti.isReceiverTrusted(intent));
239 |
240 | /* trust everything first */
241 | assertTrue(ti.addTrustedSigner(AndroidSystemPin.class));
242 | assertTrue(ti.addTrustedSigner(AndroidIncludedAppsPin.class));
243 | for (String packageName : packagesSignedByAndroidSystem) {
244 | intent = new Intent();
245 | intent.setPackage(packageName);
246 | assertTrue(ti.isReceiverTrusted(intent));
247 | }
248 | for (String packageName : packagesSignedByAndroidIncludedApps) {
249 | intent = new Intent();
250 | intent.setPackage(packageName);
251 | assertTrue(ti.isReceiverTrusted(intent));
252 | }
253 |
254 | /* remove one key, now not everything should be trusted */
255 | assertTrue(ti.removeTrustedSigner(AndroidIncludedAppsPin.class));
256 | for (String packageName : packagesSignedByAndroidSystem) {
257 | intent = new Intent();
258 | intent.setPackage(packageName);
259 | assertTrue(ti.isReceiverTrusted(intent));
260 | }
261 | for (String packageName : packagesSignedByAndroidIncludedApps) {
262 | intent = new Intent();
263 | intent.setPackage(packageName);
264 | assertFalse(ti.isReceiverTrusted(intent));
265 | }
266 |
267 | /* remove the second pin, nothing should be trusted */
268 | assertTrue(ti.removeTrustedSigner(AndroidSystemPin.class));
269 | for (String packageName : packagesSignedByAndroidSystem) {
270 | intent = new Intent();
271 | intent.setPackage(packageName);
272 | assertFalse(ti.isReceiverTrusted(intent));
273 | }
274 | for (String packageName : packagesSignedByAndroidIncludedApps) {
275 | intent = new Intent();
276 | intent.setPackage(packageName);
277 | assertFalse(ti.isReceiverTrusted(intent));
278 | }
279 | }
280 | }
281 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489 |
490 | Also add information on how to contact you by electronic and paper mail.
491 |
492 | You should also get your employer (if you work as a programmer) or your
493 | school, if any, to sign a "copyright disclaimer" for the library, if
494 | necessary. Here is a sample; alter the names:
495 |
496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498 |
499 | , 1 April 1990
500 | Ty Coon, President of Vice
501 |
502 | That's all there is to it!
503 |
--------------------------------------------------------------------------------