Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
changes v1.5 to v1.6 (#10) (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Christopher van der Beets <87814389+cbeets@users.noreply.github.com>
  • Loading branch information
sweidenbach and cbeets authored Sep 23, 2021
1 parent 3a0e17b commit 2ae475d
Show file tree
Hide file tree
Showing 226 changed files with 11,827 additions and 1,718 deletions.
2 changes: 1 addition & 1 deletion src/IDWallet.Android/AusweisSDK/AusweisSDK_Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public bool SendCall(string command)

return ausweisSdk.Send(ausweisSdkCallback.SessionID, command);
}
catch (System.Exception e)
catch (System.Exception)
{
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions src/IDWallet.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,19 @@ public static bool IsPlayServiceAvailable()
}
return true;
}

public override Android.Content.Res.Resources Resources
{
get
{
Android.Content.Res.Configuration config = base.Resources.Configuration;
config.FontScale = 1f;
if (config == null)
{
config = new Android.Content.Res.Configuration();
}
return CreateConfigurationContext(config).Resources;
}
}
}
}
2 changes: 1 addition & 1 deletion src/IDWallet.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="10503" android:versionName="1.5" package="com.digitalenabling.idw" android:installLocation="preferExternal">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="10617" android:versionName="1.6" package="com.digitalenabling.idw" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 30 additions & 16 deletions src/IDWallet.Android/SecurityChecks/HardwareKeyServiceAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,45 @@
using Android.Security.Keystore;
using IDWallet.Droid.SecurityChecks;
using IDWallet.Interfaces;
using Java.Lang;
using Java.Security;
using Java.Security.Cert;
using Java.Security.Spec;
using Java.Util;
using Newtonsoft.Json;
using System.Diagnostics;
using Xamarin.Essentials;

[assembly: Xamarin.Forms.Dependency(typeof(HardwareKeyServiceAndroid))]
namespace IDWallet.Droid.SecurityChecks
{
public class HardwareKeyServiceAndroid : IHardwareKeyService
{
private const string ALIAS = "BaseIdHWKey";
private const string TRANSFORMATION = "SHA256withECDSA";
private const string KEYALGORITHM = KeyProperties.KeyAlgorithmEc;
private const string KEYSTORE_TYPE = "AndroidKeyStore";
private const int AUTHENTICATION_LEVEL = 32768;

public string GetPublicKeyAsBase64(byte[] nonce)
public string GetPublicKeyAsBase64(byte[] nonce, string alias)
{
// Check if PPK pair is allready generated
bool strongBoxBacked = StrongBoxFeatureAvailable();
bool isPhysicalDevice = IsPhysicalDevice();

GenerateNewKeyPair(nonce, strongBoxBacked);
GenerateNewKeyPair(nonce, strongBoxBacked, alias);

KeyStore keyStore = KeyStore.GetInstance(KEYSTORE_TYPE);
keyStore.Load(null);
Certificate[] certificates = keyStore.GetCertificateChain(ALIAS);
Certificate[] certificates = keyStore.GetCertificateChain(alias);
string[] certArr = CreateCertificateChainArray(certificates);

return JsonConvert.SerializeObject(certArr);
}

public string Sign(byte[] nonce)
public string Sign(byte[] nonce, string alias)
{
KeyStore.PrivateKeyEntry entry = null;
bool exists = TryGetPrivateKey(out entry);
bool exists = TryGetPrivateKey(out entry, alias);
if (exists)
{
IPrivateKey privateKey = entry.PrivateKey;
Expand All @@ -64,11 +65,11 @@ public string Sign(byte[] nonce)
return null;
}

private bool TryGetPrivateKey(out KeyStore.PrivateKeyEntry entry)
private bool TryGetPrivateKey(out KeyStore.PrivateKeyEntry entry, string alias)
{
KeyStore keyStore = KeyStore.GetInstance(KEYSTORE_TYPE);
keyStore.Load(null);
entry = (KeyStore.PrivateKeyEntry)keyStore.GetEntry(ALIAS, null);
entry = (KeyStore.PrivateKeyEntry)keyStore.GetEntry(alias, null);

// Check if PPK pair is allready generated
if (entry == null)
Expand Down Expand Up @@ -99,17 +100,30 @@ private static string EncodeToString(byte[] bytesToEncde)
return encoder.EncodeToString(bytesToEncde);
}

private static void GenerateNewKeyPair(byte[] nonce, bool strongBoxBacked)
private static void GenerateNewKeyPair(byte[] nonce, bool strongBoxBacked, string alias)
{
KeyPairGenerator kpGenerator = KeyPairGenerator.GetInstance(KEYALGORITHM, KEYSTORE_TYPE);
// This failes, when the user does not have a biometric enrollment
KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(ALIAS, KeyStorePurpose.Sign)
.SetDigests(KeyProperties.DigestSha256)
.SetAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1"))
.SetRandomizedEncryptionRequired(false)
.SetAttestationChallenge(nonce)
.SetIsStrongBoxBacked(strongBoxBacked)
.Build();
KeyGenParameterSpec spec = null;
try
{
spec = new KeyGenParameterSpec.Builder(alias, KeyStorePurpose.Sign)
.SetDigests(KeyProperties.DigestSha256)
.SetAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1"))
.SetRandomizedEncryptionRequired(false)
.SetAttestationChallenge(nonce)
.SetIsStrongBoxBacked(strongBoxBacked)
.Build();
}
catch (NoSuchMethodError)
{
spec = new KeyGenParameterSpec.Builder(alias, KeyStorePurpose.Sign)
.SetDigests(KeyProperties.DigestSha256)
.SetAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1"))
.SetRandomizedEncryptionRequired(false)
.SetAttestationChallenge(nonce)
.Build();
}

kpGenerator.Initialize(spec);
kpGenerator.GenerateKeyPair();
Expand Down
4 changes: 2 additions & 2 deletions src/IDWallet.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleDisplayName</key>
<string>ID Wallet</string>
<key>CFBundleVersion</key>
<string>10503</string>
<string>10617</string>
<key>CFBundleName</key>
<string>ID Wallet</string>
<key>UIAppFonts</key>
Expand Down Expand Up @@ -77,7 +77,7 @@
<key>CFBundleIdentifier</key>
<string>com.digitalenabling.idw</string>
<key>CFBundleShortVersionString</key>
<string>1.5</string>
<string>1.6</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcons.appiconset</string>
<key>UILaunchStoryboardName</key>
Expand Down
Binary file added src/IDWallet.iOS/Resources/BaseIdStartInfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/IDWallet.iOS/Resources/Checkmark.png
Binary file added src/IDWallet.iOS/Resources/DDL_Eagle.png
Binary file added src/IDWallet.iOS/Resources/DDL_EuroFlag.png
Binary file added src/IDWallet.iOS/Resources/Onboarding01.png
Binary file added src/IDWallet.iOS/Resources/Onboarding02.png
Binary file added src/IDWallet.iOS/Resources/Onboarding02_new.png
Binary file added src/IDWallet.iOS/Resources/Onboarding03.png
Binary file added src/IDWallet.iOS/Resources/addBaseId.png
Binary file added src/IDWallet.iOS/Resources/addCard.png
Binary file added src/IDWallet.iOS/Resources/addDdl.png
Binary file added src/IDWallet.iOS/Resources/addOther.png
Binary file added src/IDWallet.iOS/Resources/addVacCert.png
Binary file added src/IDWallet.iOS/Resources/ddl_deactivated.png
Binary file added src/IDWallet.iOS/Resources/idCard_deactivated.png
Binary file added src/IDWallet.iOS/Resources/isAddedBaseId.png
Binary file added src/IDWallet.iOS/Resources/isAddedDdl.png
Binary file added src/IDWallet.iOS/Resources/isAddedVacCert.png
Binary file added src/IDWallet.iOS/Resources/qr_placeholder.png
32 changes: 15 additions & 17 deletions src/IDWallet.iOS/SecurityChecks/HardwareKeyServiceIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,34 @@ namespace IDWallet.iOS.SecurityChecks
{
public class HardwareKeyServiceIOS : IHardwareKeyService
{
private const string ALIAS = "BaseIdHWKey";

public string GetPublicKeyAsBase64(byte[] nonce)
public string GetPublicKeyAsBase64(byte[] nonce, string alias)
{
SecKey privKey = GetPrivateKey();
SecKey privKey = GetPrivateKey(alias);
while (privKey != null)
{
Debug.WriteLine("Key found");
var deleted = SecKeyChain.Remove(new SecRecord(SecKind.Key)
{
ApplicationTag = NSData.FromString(ALIAS),
ApplicationTag = NSData.FromString(alias),
KeyType = SecKeyType.ECSecPrimeRandom,
});

Debug.WriteLine($"Key deleted: {deleted}");

privKey = GetPrivateKey();
privKey = GetPrivateKey(alias);
}

CreateKey(nonce);
CreateKey(nonce, alias);

privKey = GetPrivateKey();
privKey = GetPrivateKey(alias);

SecKey publKey = privKey.GetPublicKey();
return publKey.GetExternalRepresentation().GetBase64EncodedString(NSDataBase64EncodingOptions.None);
}

public string Sign(byte[] nonce)
public string Sign(byte[] nonce, string alias)
{
SecKey key = GetPrivateKey();
SecKey key = GetPrivateKey(alias);
if (key != null)
{
NSError nSError;
Expand All @@ -51,21 +49,21 @@ public string Sign(byte[] nonce)
return null;
}

public void CreateKey(byte[] nonce)
public void CreateKey(byte[] nonce, string alias)
{
using (SecAccessControl access = new SecAccessControl(SecAccessible.WhenUnlockedThisDeviceOnly, SecAccessControlCreateFlags.PrivateKeyUsage))
{
SecKeyGenerationParameters keyParameters = new SecKeyGenerationParameters
{
KeyType = SecKeyType.ECSecPrimeRandom,
KeySizeInBits = 256,
Label = ALIAS,
ApplicationTag = NSData.FromString(ALIAS),
Label = alias,
ApplicationTag = NSData.FromString(alias),
// CanSign = true,
PrivateKeyAttrs = new SecKeyParameters
{
//IsPermanent = true,
ApplicationTag = NSData.FromString(ALIAS),
ApplicationTag = NSData.FromString(alias),
AccessControl = access
},
PublicKeyAttrs = new SecKeyParameters
Expand All @@ -83,7 +81,7 @@ public void CreateKey(byte[] nonce)

SecRecord sr = new SecRecord(SecKind.Key)
{
ApplicationTag = NSData.FromString(ALIAS),
ApplicationTag = NSData.FromString(alias),
KeyType = SecKeyType.ECSecPrimeRandom,
};
sr.SetKey(genKey);
Expand All @@ -92,12 +90,12 @@ public void CreateKey(byte[] nonce)
}
}

private SecKey GetPrivateKey()
private SecKey GetPrivateKey(string alias)
{
object privateKey = SecKeyChain.QueryAsConcreteType(
new SecRecord(SecKind.Key)
{
ApplicationTag = NSData.FromString(ALIAS),
ApplicationTag = NSData.FromString(alias),
KeyType = SecKeyType.ECSecPrimeRandom,
},
out SecStatusCode code);
Expand Down
67 changes: 49 additions & 18 deletions src/IDWallet/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<Color x:Key="SecondaryTextColor">#545455</Color>
<Color x:Key="BackgroundColor">#f2f2f9</Color>
<Color x:Key="PrimaryButtonColor">#e6e5f3</Color>
<Color x:Key="newPrimaryButtonColor">#0A008E</Color>
<Color x:Key="AddVacButtonColor">#0A008E</Color>
<Color x:Key="SecondaryButtonColor">#F2F2F9</Color>
<Color x:Key="AttributeValueColor">#242424</Color>
<Color x:Key="AttributeNameColor">#8C8C8C</Color>
<Color x:Key="FontBlackColor">#000000</Color>
Expand Down Expand Up @@ -47,6 +50,20 @@
<Color x:Key="DeactivatedButtonPrimaryColor">#F8F8F8</Color>
<Color x:Key="DeactivatedButtonSecondaryColor">#E0E0E0</Color>
<Color x:Key="ProofRequestGroupingColor">#C9C9C9</Color>
<Color x:Key="DDLBlue">#1F61CD</Color>
<Color x:Key="DDLBlack">#000000</Color>

<Color x:Key="EmptyWalletPrimaryTextColor">#000051</Color>
<Color x:Key="InfoBoxBackgroundColor">#ECEBFC</Color>
<Color x:Key="InfoBoxTextColor">#744dff</Color>



<Color x:Key="OnboardingPrimaryColor">#0A008E</Color>
<Color x:Key="OnboardingSecondaryColor">#F2F2F9</Color>
<Color x:Key="OnboardingTextColor">#252525</Color>
<Color x:Key="OnboardingIndicatorSelectedColor">#7365ff</Color>
<Color x:Key="OnboardingIndicatorDefaultColor">#d8d8d8</Color>

<CornerRadius x:Key="DefaultCornerRadius">5</CornerRadius>

Expand Down Expand Up @@ -87,7 +104,7 @@
<Style TargetType="Button">
<Setter Property="Padding" Value="{x:OnPlatform Android=5, iOS=10}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="TextTransform" Value="None"/>
</Style>

<Style TargetType="Frame">
Expand Down Expand Up @@ -140,7 +157,7 @@
<Setter Property="LineBreakMode" Value="WordWrap"/>
<Setter Property="Margin" Value="0"/>
</Style>

<Style TargetType="Label" x:Key="BaseIDBodyLabel">
<Setter Property="FontSize" Value="14"/>
<Setter Property="TextColor" Value="{StaticResource SecondaryTextColor}"/>
Expand Down Expand Up @@ -183,30 +200,34 @@
</Style>

<Style x:Key="CancelButton" TargetType="Button">
<Setter Property="Text" Value="Cancel" />
<Setter Property="TextColor" Value="{StaticResource SecondaryTextColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource CancelSecondaryColor}" />
<Setter Property="BorderColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BorderWidth" Value="1"/>
<Setter Property="TextColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BackgroundColor" Value="Transparent" />
</Style>

<Style x:Key="AcceptButton" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource PrimaryTextColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryButtonColor}" />
<Setter Property="TextColor" Value="{StaticResource SecondaryButtonColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource newPrimaryButtonColor}" />
</Style>

<Style x:Key="DeactivatedButton" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource DeactivatedButtonPrimaryColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource DeactivatedButtonSecondaryColor}" />
<Style x:Key="DeleteButton" TargetType="Button">
<Setter Property="BorderColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BorderWidth" Value="1"/>
<Setter Property="TextColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BackgroundColor" Value="Transparent" />
</Style>

<Style x:Key="DeleteButton" TargetType="Button">
<Setter Property="Text" Value="Delete" />
<Setter Property="TextColor" Value="{StaticResource DeletePrimaryColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource DeleteSecondaryColor}" />
<Style x:Key="PrimaryButton" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource SecondaryButtonColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource newPrimaryButtonColor}" />
</Style>

<Style x:Key="PrimaryButtonStyle" TargetType="Button">
<Setter Property="TextColor" Value="{StaticResource PrimaryTextColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource TertiaryTextColor}" />
<Style x:Key="SecondaryButton" TargetType="Button">
<Setter Property="BorderColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BorderWidth" Value="1"/>
<Setter Property="TextColor" Value="{StaticResource newPrimaryButtonColor}" />
<Setter Property="BackgroundColor" Value="Transparent" />
</Style>

<Style x:Key="PopUpFrame" TargetType="Frame">
Expand Down Expand Up @@ -254,6 +275,15 @@
<Setter Property="HorizontalOptions" Value="End" />
</Style>

<Style x:Key="DDL_Table_Label" TargetType="Label">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="Margin" Value="0,-1,0,2" />
<Setter Property="VerticalOptions" Value="CenterAndExpand" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="VerticalTextAlignment" Value="Start" />
<Setter Property="CharacterSpacing" Value="-1"/>
</Style>

<Thickness x:Key="DefaultEdgeMargin">21, 0</Thickness>
<Thickness x:Key="DefaultEdgeMarginTop">21, 11, 21, 0</Thickness>
<Thickness x:Key="DefaultEdgeMarginTopDown">21, 11</Thickness>
Expand All @@ -276,7 +306,8 @@
<utils:LabelTextConverter x:Key="LabelTextConverter" />
<utils:ValueVisibilityConverter x:Key="ValueVisibilityConverter" />
<utils:HardwareKeyVisibleConverter x:Key="HardwareKeyVisibleConverter" />
<utils:ProgressBarColorConverter x:Key="ProgressBarColorConverter" />
<utils:ProgressBarColorConverter x:Key="ProgressBarColorConverter" />
<utils:OnboardingProgressBarConverter x:Key="OnboardingProgressBarConverter" />
<utils:HistoryElementConverter x:Key="HistoryElementConverter" />
<utils:AttributeValueConverter x:Key="AttributeValueConverter"/>
<utils:MultiLabelTextConverter x:Key="MultiLabelTextConverter"/>
Expand Down
Loading

0 comments on commit 2ae475d

Please sign in to comment.