Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Chralu committed Mar 16, 2023
1 parent 29f0114 commit 607714f
Show file tree
Hide file tree
Showing 21 changed files with 271 additions and 155 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.archethic.yubikit_android.methods

import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

class Connect : MethodHandler {
override fun handle(call: MethodCall, result: MethodChannel.Result) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.archethic.yubikit_android.methods

import androidx.annotation.NonNull
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

interface MethodHandler {
fun handle(@NonNull call: MethodCall, @NonNull result: MethodChannel.Result);
}
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.12.0
16 changes: 12 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -205,6 +205,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -241,6 +242,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -361,8 +363,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = T3ZV8MV4P2;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -371,6 +374,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = net.archethic.example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -491,8 +495,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = T3ZV8MV4P2;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -501,6 +506,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = net.archethic.example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -515,8 +521,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerRelease.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = T3ZV8MV4P2;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -525,6 +532,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = net.archethic.example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
2 changes: 1 addition & 1 deletion example/lib/components/capabilities_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CapabilitiesText extends StatelessWidget {

Future<String> capabilitiesString() async {
try {
final capabilities = await yubikitPlugin.general.deviceCapabilities;
final capabilities = await yubikitPlugin.connection.deviceCapabilities;
return 'nfc : ${capabilities.nfc}, wired : ${capabilities.wired}';
} on PlatformException {
return 'Failed to get device capabilities';
Expand Down
14 changes: 11 additions & 3 deletions example/lib/components/generate_key_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ class GenerateKeyButton extends StatelessWidget {
Widget build(BuildContext context) => ActionButton(
text: 'Generate key',
onPressed: () async {
final publicKey = await yubikitPlugin.piv.generateKey(
pin: "123456",
managementKey: PivManagementKey.fromString(
final connection = await yubikitPlugin.connection.connect(
timeout: const Duration(seconds: 15),
);
final piv = await connection.pivSession;

await piv.verifyPin("123456");
await piv.authenticate(
PivManagementKey.fromString(
"010203040506070801020304050607080102030405060708",
keyType: PivManagementKeyType.tripleDES,
),
);

final publicKey = await piv.generateKey(
pinPolicy: PivPinPolicy.defaultPolicy,
type: PivKeyType.eccp256,
touchPolicy: PivTouchPolicy.defaultPolicy,
Expand Down
8 changes: 6 additions & 2 deletions example/lib/components/piv_calculate_secret_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ class PivCalculateSecretButton extends StatelessWidget {
Widget build(BuildContext context) => ActionButton(
text: 'Calculate secret',
onPressed: () async {
final secret = await yubikitPlugin.piv.calculateSecret(
final connection = await yubikitPlugin.connection.connect();
final piv = await connection.pivSession;

piv.verifyPin("123456");

final secret = await piv.calculateSecret(
slot: PivSlot.authentication,
pin: "123456",
peerPublicKey: """
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElqeFrBCjtonol5ksKYCuXf+alUTI
Expand Down
6 changes: 4 additions & 2 deletions example/lib/components/piv_read_cert_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class PivReadCertButton extends StatelessWidget {
Widget build(BuildContext context) => ActionButton(
text: 'Read certificate',
onPressed: () async {
final publicKey = await yubikitPlugin.piv.getCertificate(
pin: "123456",
final connection = await yubikitPlugin.connection.connect();
final piv = await connection.pivSession;
await piv.verifyPin("123456");
final publicKey = await piv.getCertificate(
slot: PivSlot.signature,
);
return publicKey.toString();
Expand Down
Loading

0 comments on commit 607714f

Please sign in to comment.