diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..5c002c0 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,5 @@ +# Optional: GOPATH and ANDROID_HOME need to be passed to the bazel build command. +# To avoid typing them in the command line, please edit and uncomment the following lines. +# build --action_env=ANDROID_HOME=/Your/Android/Home/Path # example:/Users/YourUserName/Library/Android/sdk +# build --action_env=GOPATH=/Your/Go/Path/ # example: /Users/YourUserName/go + diff --git a/.gitignore b/.gitignore index 6143e53..a4beaae 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,17 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# AndroidStudio files +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild + +# Bazel output files +bazel-* diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4f093a2..409f59a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -9,3 +9,4 @@ # Names should be added to this file as: # Name +Antonio Marcedone diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..5803f09 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,6 @@ +android_sdk_repository( + name = "androidsdk", + path = "/Users/antonio.marcedone/Library/Android/sdk", + api_level = 25, + build_tools_version = "25.0.0" +) diff --git a/exampleapp/BUILD b/exampleapp/BUILD new file mode 100644 index 0000000..ec87268 --- /dev/null +++ b/exampleapp/BUILD @@ -0,0 +1,13 @@ +android_binary( + name = "exampleapp", + srcs = ["src/main/java/com/google/keytransparency/exampleapp/KeyTransparencyExample.java"], + custom_package = "com.google.keytransparency.exampleapp", + manifest = "src/main/AndroidManifest.xml", + resource_files = glob(["src/main/res/**"]), + deps = [ + "//keytransparency:keytransparency", + "@androidsdk//com.android.support:appcompat-v7-25.0.0", + "@androidsdk//com.android.support.constraint:constraint-layout-1.0.2", + "@androidsdk//com.android.support:design-25.0.0", + ], +) diff --git a/exampleapp/src/main/AndroidManifest.xml b/exampleapp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e329103 --- /dev/null +++ b/exampleapp/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/exampleapp/src/main/java/com/google/keytransparency/exampleapp/KeyTransparencyExample.java b/exampleapp/src/main/java/com/google/keytransparency/exampleapp/KeyTransparencyExample.java new file mode 100644 index 0000000..39c5f38 --- /dev/null +++ b/exampleapp/src/main/java/com/google/keytransparency/exampleapp/KeyTransparencyExample.java @@ -0,0 +1,68 @@ +package com.google.keytransparency.exampleapp; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.method.ScrollingMovementMethod; +import android.widget.TextView; + +import com.google.keytransparency.KTClient; +import com.google.keytransparency.KeyTransparencyException; + +import java.io.IOException; + +public class KeyTransparencyExample extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_key_transparency_example); + TextView tv = (TextView) findViewById(R.id.textView); + + tv.setText(""); + tv.setMovementMethod(new ScrollingMovementMethod()); + + try{ + tv.append("\n\n --- GetEntry test --- \n"); + + KTClient client = KTClient.getClient(1000); + client.setTextViewForLogs(tv); + String ktUrl = "35.184.134.53:8080"; + client.addKtServer(ktUrl, true, null, null); + + try { + String username = "gary.belvin@gmail.com"; + + tv.append("\nTrying to get public key for " + username + " from server " + ktUrl +"\n"); + byte[] entry = client.getEntry(ktUrl, username,"app1"); + if (entry==null){ + tv.append("Received key is null: entry does not exists"); + } else { + tv.append("Received key: " + new String(entry, "UTF-8")); + } + + username = "NOT_A_USER@gmail.com"; + tv.append("\n\nTrying to get public key for " + username + " from server " + ktUrl +"\n"); + entry = client.getEntry(ktUrl, username,"app1"); + if (entry==null){ + tv.append("Received key is null: entry does not exists"); + } else { + tv.append("Received key: " + new String(entry, "UTF-8")); + } + + + } catch (KeyTransparencyException e) { + tv.append("Exception was raised: " + e); + } + + } catch (IOException e) { + e.printStackTrace(); + tv.append("\nError reading one of the public keys: "+e.getMessage()); + throw new RuntimeException("Error reading one of the public keys: "+e.getMessage(),e ); + } catch (KeyTransparencyException e) { + e.printStackTrace(); + tv.append("\nError creating the client: "+e.getMessage()); + throw new RuntimeException("Error creating the client: "+e.getMessage(),e ); + } + } + +} diff --git a/exampleapp/src/main/res/layout/activity_key_transparency_example.xml b/exampleapp/src/main/res/layout/activity_key_transparency_example.xml new file mode 100644 index 0000000..01af359 --- /dev/null +++ b/exampleapp/src/main/res/layout/activity_key_transparency_example.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/exampleapp/src/main/res/mipmap-hdpi/ic_launcher.png b/exampleapp/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/exampleapp/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/exampleapp/src/main/res/mipmap-hdpi/ic_launcher_round.png b/exampleapp/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..9a078e3 Binary files /dev/null and b/exampleapp/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/exampleapp/src/main/res/mipmap-mdpi/ic_launcher.png b/exampleapp/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/exampleapp/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/exampleapp/src/main/res/mipmap-mdpi/ic_launcher_round.png b/exampleapp/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..efc028a Binary files /dev/null and b/exampleapp/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png b/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..3af2608 Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png b/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9bec2e6 Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..34947cd Binary files /dev/null and b/exampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/exampleapp/src/main/res/raw/p256_pubkey.pem b/exampleapp/src/main/res/raw/p256_pubkey.pem new file mode 100644 index 0000000..f10fbe0 --- /dev/null +++ b/exampleapp/src/main/res/raw/p256_pubkey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKv9XdfRJkfSF16zbMfr1hCKQsFcF +rZtX5urHF9ZDuOaR5xrCwd4Ji6dGxV2xNT87mi8kVAGQ/4q68QGt8rZ9Fw== +-----END PUBLIC KEY----- diff --git a/exampleapp/src/main/res/raw/server.crt b/exampleapp/src/main/res/raw/server.crt new file mode 100644 index 0000000..f4532d6 --- /d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CERTIFICATE----- diff --git a/exampleapp/src/main/res/raw/trillian_log.pem b/exampleapp/src/main/res/raw/trillian_log.pem new file mode 100644 index 0000000..cd23fc3 --- /dev/null +++ b/exampleapp/src/main/res/raw/trillian_log.pem @@ -0,0 +1,3 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfzsONlxOpdPmNMtxsAahUGLgrwX+OSJDjTkLTgl3JaztUQnTpVh10DjYoaDhiJNiZqmKOPkxveVoPJ5Jr/Ex0Q== +-----END PUBLIC KEY----- diff --git a/exampleapp/src/main/res/raw/vrf_pubkey.pem b/exampleapp/src/main/res/raw/vrf_pubkey.pem new file mode 100644 index 0000000..1f55470 --- /dev/null +++ b/exampleapp/src/main/res/raw/vrf_pubkey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAENZuDzGYmrJuoG7EkD0O2OEasXxoO +JA4HLQexWcF8MDgmlh27xS/Zwv20DNha8iBT26h2xNDo7exwVzL6+IBB2Q== +-----END PUBLIC KEY----- diff --git a/exampleapp/src/main/res/values/colors.xml b/exampleapp/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/exampleapp/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/exampleapp/src/main/res/values/dimens.xml b/exampleapp/src/main/res/values/dimens.xml new file mode 100644 index 0000000..7abc06d --- /dev/null +++ b/exampleapp/src/main/res/values/dimens.xml @@ -0,0 +1 @@ + diff --git a/exampleapp/src/main/res/values/strings.xml b/exampleapp/src/main/res/values/strings.xml new file mode 100644 index 0000000..24c4baf --- /dev/null +++ b/exampleapp/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + KeyTransparencyAndroid + diff --git a/exampleapp/src/main/res/values/styles.xml b/exampleapp/src/main/res/values/styles.xml new file mode 100644 index 0000000..545b9c6 --- /dev/null +++ b/exampleapp/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + +