key_enclave 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new71

key_enclave #

For more secure when you want to communicate to ... and you want to make sure this message came from real user.

Using Keystore and Secure Enclave for stored private key

use ECDSA512 for sign message

NOTE THAT you can't retreve private key from mobile, I can't even do it too.

NOT SUPPORTED background process because i'm not allowed to access private key when mobile turn off or locked

for more information

Usage #

To use this plugin, add key_enclave as a dependency in your pubspec.yaml file.

Features #

  • generate key pair (EC Algorithm) and return public key back private key store in secure enclave(ios) and tte|keystore(android)

  • delete private key

  • sign message by using private key

Example #

import 'package:key_enclave/key_enclave.dart';


class _MyAppState extends State<MyApp> {
  String publicKey = '';
  String signMessage = "";
  String TAG = "KEY_TAG";

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              onPressed: () async {
                final pub = await KeyEnclave().generateKeyPair(TAG);
                setState(() {
                  this.publicKey = pub;
                });
              },
              child: Text("GENERATE KEY PAIR"),
            ),
            Text("PUBLIC KEY " + this.publicKey),
             RaisedButton(
              onPressed: () async {
                try {
                  // change message that you want to sign
                final signed = await KeyEnclave().signMessage(TAG,"SECURE MESSAGE");
                setState(() {
                  this.signMessage = signed;
                });
                  
                } catch (e) {
                  setState(() {
                    this.signMessage = e.toString();
                  });
                }
              },
              child: Text("SIGN MESSAGE"),
            ),
            Text("SIGN MESSAGE " + this.signMessage)
          ],
        ),
      ),
    );
  }
}

Upcomming Features #

  • verify message
  • encrpyt message
  • decrypt message
  • add option generate key (RSA OR EC) now supported only EC
  • add option user must authen when need to use private key first

0.1.1 #

  • fix iphone5 generate key failed

0.1.0+1 #

  • add documents and detail of this package

0.1.0 #

  • ready for production ??

0.0.5+2 #

  • fixed ios bug
  • add example

0.0.5 #

  • remove bug delete private key

0.0.4 #

  • remove break line bug

0.0.3 #

  • replace necessary break line

0.0.1 #

  • TODO: intialize

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> {
  String publicKey = '';
  String signMessage = "";
  String TAG = "KEY_TAG";

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              onPressed: () async {
                final pub = await KeyEnclave().generateKeyPair(TAG);
                setState(() {
                  this.publicKey = pub;
                });
              },
              child: Text("GENERATE KEY PAIR"),
            ),
            Text("PUBLIC KEY " + this.publicKey),
             RaisedButton(
              onPressed: () async {
                try {
                  // change message that you want to sign
                final signed = await KeyEnclave().signMessage(TAG,"SECURE MESSAGE");
                setState(() {
                  this.signMessage = signed;
                });
                  
                } catch (e) {
                  setState(() {
                    this.signMessage = e.toString();
                  });
                }
              },
              child: Text("SIGN MESSAGE"),
            ),
            Text("SIGN MESSAGE " + this.signMessage)
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  key_enclave: ^0.1.3

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:key_enclave/key_enclave.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:key_enclave/key_enclave.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:key_enclave/key_enclave.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:key_enclave/key_enclave.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:key_enclave/key_enclave.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • key_enclave that is a package requiring null.

Health suggestions

Fix lib/key_enclave.dart. (-1 points)

Analysis of lib/key_enclave.dart reported 2 hints:

line 24 col 16: This function has a return type of 'Future

line 25 col 18: The value of the local variable 'deletCode' isn't used.

Dependencies

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