donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 973736d72bb05fd9e52bf04e9d5839628711b838
parent a2647abcd5c56635580a0d0b3b4624ed8aea3d90
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Thu, 13 Jun 2024 15:18:53 +0200

update verification-app

Diffstat:
Mverification-app/app/build.gradle | 2+-
Mverification-app/app/src/main/java/taler/donau/verification/MainActivity.java | 18++++++++++++++++++
Mverification-app/app/src/main/java/taler/donau/verification/Results.java | 55+++++++++++++++++++++++++++++++++++++++++++------------
Averification-app/app/src/main/res/drawable/ngi_taler_logo.png | 0
Mverification-app/app/src/main/res/layout/fragment_results.xml | 38++++++++++++++++++++++++++------------
Mverification-app/app/src/main/res/values/strings.xml | 6++++++
6 files changed, 94 insertions(+), 25 deletions(-)

diff --git a/verification-app/app/build.gradle b/verification-app/app/build.gradle @@ -62,7 +62,7 @@ dependencies { implementation 'androidx.navigation:navigation-ui:2.7.5' implementation 'com.github.yuriy-budiyev:code-scanner:2.3.2' // https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk18on - implementation group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: '1.78.1' + implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.70' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/verification-app/app/src/main/java/taler/donau/verification/MainActivity.java b/verification-app/app/src/main/java/taler/donau/verification/MainActivity.java @@ -1,3 +1,19 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ + package taler.donau.verification; import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED; @@ -53,6 +69,8 @@ public class MainActivity extends AppCompatActivity { }); } }); + //temporary for debugging should be a valid cleartext message for signing and the public key + //sendRequestDialog("AAAAZAAABdwAAAAAAAAADwAAAABFVVIAAAAAAAAAAACoq+wLL6w/nI0IwLKwbnXlkbZ6XLpHzA8MZkaPHba13bdUYbV+oeF/HrkLYubKnhzSSR5DgpcJKI4fH1kryuGhAAAH6A==:Y/YreQExHCGHv83mME0YMxd0DbMUMsEztJ5UHypm+bA="); } @Override diff --git a/verification-app/app/src/main/java/taler/donau/verification/Results.java b/verification-app/app/src/main/java/taler/donau/verification/Results.java @@ -1,26 +1,54 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ + package taler.donau.verification; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TextView; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.Security; +import java.security.Signature; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; + import androidx.appcompat.app.AppCompatActivity; import java.nio.charset.StandardCharsets; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; import java.util.Base64; import org.bouncycastle.crypto.Signer; import org.bouncycastle.crypto.params.AsymmetricKeyParameter; import org.bouncycastle.crypto.signers.Ed25519Signer; import org.bouncycastle.crypto.util.OpenSSHPublicKeyUtil; +import org.bouncycastle.jce.provider.BouncyCastleProvider; public class Results extends AppCompatActivity { - // QR-string: YEAR:AMOUNT:FRACTION:TAXID:TAXIDSALT:EDD25519SIGNATURE:PUBLICKEY + // QR-string: YEAR:AMOUNT:FRACTION:TAXID:TAXIDSALT:EDD25519SIGNATURE // Base64 encoded: SALT,TAXID,SIGNATURE, PUBLICKEY (public key only temporary for testing) + // The public key should be requested directly from the Donau over HTTPS - private final int NUMBER_OF_ARGUMENTS = 7; + private final int NUMBER_OF_ARGUMENTS = 6; // hard coded (only temporary for testing) private final int SIGNATURECODE = 1500; // uint64_t @@ -28,7 +56,7 @@ public class Results extends AppCompatActivity { // uint32_t private int fraction; // uint64_t - private long year; + private Long year; private byte[] taxid; private byte[] salt; private byte[] eddsaSignature; @@ -51,7 +79,7 @@ public class Results extends AppCompatActivity { Intent intent = getIntent(); textView.setText(intent.getStringExtra("QR-String")); - String[] parts = intent.getStringExtra("QR-String").split("/"); + String[] parts = intent.getStringExtra("QR-String").split(":"); if (parts == null || parts.length != NUMBER_OF_ARGUMENTS) { statusHandling(SignatureStatus.INVALID_NUMBER_OF_ARGUMENTS); return; @@ -70,11 +98,16 @@ public class Results extends AppCompatActivity { return; } - checkSignature(); + try { + checkSignature(); + } catch (Exception e) { + throw new RuntimeException(e); + } } - private void checkSignature() { + // FIXME: Maybe simpler with java native?! + private void checkSignature() throws Exception{ AsymmetricKeyParameter publicKeyParameters = OpenSSHPublicKeyUtil.parsePublicKey(publicKey); Signer verifier = new Ed25519Signer(); verifier.init(false, publicKeyParameters); @@ -90,27 +123,25 @@ public class Results extends AppCompatActivity { } else { statusHandling(SignatureStatus.SIGNATURE_INVALID); } - } - // TODO: move strings to res/values/strings private void statusHandling(SignatureStatus es) { View rootView = findViewById(R.id.root_view); switch (es) { case INVALID_NUMBER_OF_ARGUMENTS: - textView.setText("Invalid number of arguments!"); + textView.setText(R.string.invalid_number_of_arguments); rootView.setBackgroundResource(R.color.red); break; case MALFORMED_ARGUMENT: - textView.setText("Malformed argument!"); + textView.setText(R.string.malformed_argument); rootView.setBackgroundResource(R.color.red); break; case SIGNATURE_INVALID: - textView.setText("Donation Statment signature is invalid!"); + textView.setText(R.string.invalid_signature); rootView.setBackgroundResource(R.color.red); break; case SIGNATURE_VALID: - textView.setText("Donation Statment signature is valid!"); + textView.setText(R.string.valid_signature); rootView.setBackgroundResource(R.color.green); break; } diff --git a/verification-app/app/src/main/res/drawable/ngi_taler_logo.png b/verification-app/app/src/main/res/drawable/ngi_taler_logo.png Binary files differ. diff --git a/verification-app/app/src/main/res/layout/fragment_results.xml b/verification-app/app/src/main/res/layout/fragment_results.xml @@ -1,12 +1,27 @@ -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/root_view" - android:layout_width="match_parent" - android:layout_height="match_parent"> +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +android:id="@+id/root_view" +xmlns:tools="http://schemas.android.com/tools" +android:layout_width="match_parent" +android:layout_height="match_parent" +android:paddingStart="10dp" +android:paddingEnd="10dp" +android:orientation="vertical" +tools:context=".MainActivity"> +<ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxWidth="200dp" + android:adjustViewBounds="true" + android:paddingBottom="30dp" + android:src="@drawable/ngi_taler_logo" + android:contentDescription="@string/NGI_TALER_logo" /> - <TextView - android:id="@+id/textView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="20sp" - android:layout_centerInParent="true"/> -</RelativeLayout> -\ No newline at end of file +<TextView + android:id="@+id/textView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="20sp" + android:layout_centerInParent="true"/> + +</LinearLayout> diff --git a/verification-app/app/src/main/res/values/strings.xml b/verification-app/app/src/main/res/values/strings.xml @@ -1,3 +1,9 @@ <resources> <string name="app_name">Donau Verify</string> + <string name="NGI_TALER_logo" >NGI Taler Logo</string> + <string name="with_adapter">List</string> + <string name="invalid_number_of_arguments">Invalid number of arguments!</string> + <string name="malformed_argument">Malformed argument!</string> + <string name="invalid_signature">Donation Statment signature is invalid!</string> + <string name="valid_signature">Donation Statment signature is valid!</string> </resources> \ No newline at end of file