crosspki 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

crosspki #

A new Flutter plugin.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.1.0 #

  • Add full Android and iOS commands support
  • Change sign methods to use directly DigestAlgorithm objects

0.0.2 #

  • Fix importCertificate missing parameter

0.0.1 #

Initial version

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:crosspki/crosspki.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    runCrossPkiApis();
  }

  Future<void> runCrossPkiApis() async {
    try {
      print('LISTING CERTIFICATES');
      var certs = await CrossPki.listCertificatesWithKey();
      print('Certs count: ${certs.length}');

      print('IMPORTING PKCS#12');
      final p12Content = base64Decode('MIACAQMwgAYJKoZIhvcNAQcBoIAkgASCA+gwgDCABgkqhkiG9w0BBwGggCSABIID6DCCBW8wggVrBgsqhkiG9w0BDAoBAqCCBPowggT2MCgGCiqGSIb3DQEMAQMwGgQUSRKNXrxw7DWmYm7v2lWpTGMct4wCAgQABIIEyOJLkFDlyhRki9N2vfd9BrBemKPr5OP6b1eQadDxwt/SKXzwpKv9DDmHYq904EeBFXKjIdCliRq6F14uht63EiYZYlGQp7wNNe8JS547q3jJqYTTZ4GMQ3a5L1tJqfZrU+mJrDpphXDAeQOPpSUtyUlYKLcn8IBc5hO/7ZpsPDFkjEYTalw4xDyyZyariUhtY3POVGSNBrVTsjZVK4iOD8NLaMyVSGI45waCA/VXuffwzBxEkgEiMw5N4uHq/WkLsKueDf8D5+yQRhDAgEENnXk4FQGPDcLiL7OpBakn9Hc0iTkO+7C0ow1P1KdfcEZfjfJN2xF/jCqH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0P+QWhQuQ/vBBtM1Jgkl1wX45K95RIEjRfpVq3mh6iDfdIfsGwWMeRTFihatbG/eAtbv3eylD7XaKAxYoJMvCzAi6jSc+8F+JLa+M+CdUbHZ3RK2dMD237CCr0S40shxWu50KAp7KQTjiZz9/vxoYsrb5vjiiLKK6sBB/1yPb5//yvMgF9JSfcUZmqLb0Gskc15JKUYgyfxAVqCKpO2oVmcGc/8yvMGdZTigTNS9hmVrsvsA5KuUVTlS87WS9DktpGtzHFbs2wnSE6IbWAdNRPjLHv8Gr9ZdQyDJCnzX3m2YEcvmPXQ5Uxzo7Quk84CgQCuEWoEjRpsdkrn2rUTB8QSCAYWfQJdFd1WoOCBCc6VtNVxRDr4Kl0aAcO4nphwPn9adL59K1wGUYo2Of3MGqZ79VJyEHhx7v620MS5H/en+nL64FcTkOUp4IauZtXDw38BGV+4IEd3vPbkv8fy1Fqh9H6aRDaWYDLqzZcJ6fzPFI2bk1YNxBun5Gx2y7vIa+YQRhLtaBiAAiPa8wNfG9lzKK1g89c0C2cawV6bwHt5dRGcI+q79jlakh0+nHFOlfXcxqws8ku6JH0atP/kpMlKjCBNBGf4srEd9xOgxjSc8sMpdgOL+rivIv1McflR+Y+xbUTKRX41XZZaO/Kkz8IdnVyIE6eCOW2bFdqkTaYBnaM0+qRa5Ebk8CXvTVjRnphIFvnRLifjoyTh8qUmRYNdGSztM+irzmxRywnA1hL09fhWY+afaJazSryYq1D/DP0OHqhjiq/ej0S2sQ0GUoe9l/3aQz8lCie6tFvmN8L4NwRyOv+sptxGa8QxW281ybElJo+WF2lPDxQw6JAAAAAAAAAAAAAAAAAAAAAAAADA9MCEwCQYFKw4DAhoFAAQUc/Z37zPydcC06MSdcloqHZaZSAwEFGZA4R1dD6lwzAVQRNIvoney9tWKAgIEAAAA');
      await CrossPki.importPkcs12(p12Content, "1234");
      certs = await CrossPki.listCertificatesWithKey();
      print('Certs count: ${certs.length}');
      final userCertificate = certs.first;
      print('Imported: ${userCertificate.subjectName}');

      print('SIGN DATA TEST');
      var sig = await CrossPki.signData(userCertificate.thumbprint, 'SHA-256', base64Decode('SGVsbG8sIFdvcmxkIQ=='));
      print('Signature: ${base64Encode(sig.toList())}');

      print('SIGN HASH TEST');
      sig = await CrossPki.signHash(userCertificate.thumbprint, 'SHA-256', base64Decode('3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8='));
      print('Signature: ${base64Encode(sig.toList())}');

      await CrossPki.removeCertificate(certs[0].thumbprint);
      print('Removed');
      certs = await CrossPki.listCertificatesWithKey();
      print('Certs count: ${certs.length}');

      print('GENERATING RSA KEY PAIR...');
      var keyPair = await CrossPki.generateRsaKeyPair(2048);
      print('keyId: ${keyPair.keyId}');
      print('publicKey ${keyPair.algorithm}: ${base64Encode(keyPair.publicKeyEncoded.toList())}');

      print('GENERATING CSR...');
      var csr = await CrossPki.generateCsr(keyPair);
      print('CSR: ${base64Encode(csr.toList())}');

      print('DONE');
      
    } on CrossPkiException catch (ex) {
      print('ERROR: $ex');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Cross PKI Plugin example app'),
        ),
        body: Center(
          child: Text('Running Cross PKI API'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  crosspki: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:crosspki/crosspki.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:crosspki/crosspki.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:crosspki/crosspki.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:crosspki/crosspki.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:crosspki/crosspki.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [crosspki] that is in a package requiring null.

Health suggestions

Format lib/crosspki.dart.

Run flutter format to format lib/crosspki.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
asn1lib ^0.6.4 0.6.5
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test