Skip to content

Commit

Permalink
wip: import cert
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed May 13, 2024
1 parent 192df09 commit 710ce10
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 65 deletions.
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PODS:
- ccid (0.1.1):
- Flutter
- cryptography_flutter (0.2.0):
- Flutter
- device_info_plus (0.0.1):
- Flutter
- DKImagePickerController/Core (4.3.8):
Expand Down Expand Up @@ -37,6 +39,8 @@ PODS:
- file_picker (0.0.1):
- DKImagePickerController/PhotoGallery
- Flutter
- file_saver (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_nfc_kit (2.0.0):
- Flutter
Expand Down Expand Up @@ -112,8 +116,10 @@ PODS:

DEPENDENCIES:
- ccid (from `.symlinks/plugins/ccid/ios`)
- cryptography_flutter (from `.symlinks/plugins/cryptography_flutter/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- file_saver (from `.symlinks/plugins/file_saver/ios`)
- Flutter (from `Flutter`)
- flutter_nfc_kit (from `.symlinks/plugins/flutter_nfc_kit/ios`)
- flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`)
Expand Down Expand Up @@ -145,10 +151,14 @@ SPEC REPOS:
EXTERNAL SOURCES:
ccid:
:path: ".symlinks/plugins/ccid/ios"
cryptography_flutter:
:path: ".symlinks/plugins/cryptography_flutter/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
file_saver:
:path: ".symlinks/plugins/file_saver/ios"
Flutter:
:path: Flutter
flutter_nfc_kit:
Expand All @@ -166,10 +176,12 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
ccid: f196fb7dc141fa1ee3497ee6e5486a483f1ef9d1
cryptography_flutter: 381bdacc984abcfbe3ca45ef7c76566ff061614c
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
DKImagePickerController: a7836546cfdfe014171694f643a7d575bc8ace7f
DKPhotoGallery: acbd8a3bab19cf6e5fe64a853fc07bfbd247a8f6
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
file_saver: 503e386464dbe118f630e17b4c2e1190fa0cf808
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_nfc_kit: 965c98c3fa68f5609f1cc89abb968fe1b8ffdbaa
flutter_webrtc: 9bc044b0b5bcaabd0fb7d52c90421fb540f8c35e
Expand Down
14 changes: 4 additions & 10 deletions lib/controller/applets/piv.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:typed_data';

import 'package:asn1lib/asn1lib.dart';
import 'package:basic_utils/basic_utils.dart';
import 'package:canokey_console/controller/base_controller.dart';
import 'package:canokey_console/generated/l10n.dart';
import 'package:canokey_console/helper/theme/admin_theme.dart';
Expand All @@ -13,7 +12,7 @@ import 'package:dart_des/dart_des.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:logging/logging.dart';
import 'package:x509/x509.dart';
import 'package:pem/pem.dart';

final log = Logger('Console:PIV:Controller');

Expand Down Expand Up @@ -44,13 +43,8 @@ class PivController extends Controller {
if (_certDO.containsKey(slot)) {
resp = await _transceive('00CB3FFF055C035FC1${hex.encode([_certDO[slot]!])}00');
if (SmartCard.isOK(resp)) {
var bytes = hex.decode(resp.substring(16, resp.length - 4));
var p = ASN1Parser(bytes as Uint8List);
var o = p.nextObject();
if (o is! ASN1Sequence) {
throw FormatException('Expected SEQUENCE, got ${o.runtimeType}');
}
var cert = X509Certificate.fromAsn1(o);
final bytes = hex.decode(resp.substring(16, resp.length - 4));
final cert = X509Utils.x509CertificateFromPem(PemCodec(PemLabel.certificate).encode(bytes));
slotInfo.cert = cert;
slotInfo.certBytes = bytes;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/models/piv.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:basic_utils/basic_utils.dart';
import 'package:canokey_console/helper/tlv.dart';
import 'package:x509/src/x509_base.dart';

enum AlgorithmType {
pin(0xFF),
Expand Down Expand Up @@ -137,7 +137,7 @@ class SlotInfo {
final int retriesCount;
final int remainingCount;
List<int>? certBytes;
X509Certificate? cert;
X509CertificateData? cert;

SlotInfo(this.number, this.algorithm, this.pinPolicy, this.touchPolicy, this.origin, this.public, this.defaultValue, this.retriesCount, this.remainingCount);

Expand Down
2 changes: 1 addition & 1 deletion lib/views/applets/oath.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'package:canokey_console/helper/utils/prompts.dart';
import 'package:canokey_console/helper/utils/shadow.dart';
import 'package:canokey_console/helper/utils/smartcard.dart';
import 'package:canokey_console/helper/utils/ui_mixins.dart';
import 'package:canokey_console/helper/widgets/customized_text.dart';
import 'package:canokey_console/helper/widgets/customized_button.dart';
import 'package:canokey_console/helper/widgets/customized_card.dart';
import 'package:canokey_console/helper/widgets/customized_container.dart';
import 'package:canokey_console/helper/widgets/customized_text.dart';
import 'package:canokey_console/helper/widgets/form_validator.dart';
import 'package:canokey_console/helper/widgets/responsive.dart';
import 'package:canokey_console/helper/widgets/spacing.dart';
Expand Down
Loading

0 comments on commit 710ce10

Please sign in to comment.