rsa_pkcs 0.1.2

  • README.md
  • Installing
  • Versions
  • 0

rsa_pkcs

RSA,PKCS#1,PKCS#8

openssl genrsa -out rsa_private_key.pem

openssl rsa -in rsa_private_key.pem -text -noout -out rsa_private_key.txt

openssl pkcs8 -in rsa_private_key.pem -topk8 -v2 aes-256-cbc -out rsa_enc_private_key.pem

openssl pkcs8 -in rsa_private_key.pem -topk8 -v2 aes-256-cbc -v2prf hmacWithSHA256 -out rsa_enc_private_key.pem

test("rsa private key", () {
    //openssl genrsa -out rsa_private_key.pem
    File rsa_private_key_file = new File("./resource/rsa_private_key.pem");
    String pem = rsa_private_key_file.readAsStringSync();
    RSAPKCSParser parser = new RSAPKCSParser();
    RSAKeyPair pair = parser.parsePEM(pem);
    var privateKey = pair.private;
    
    expect(pair.public , equals(null));
    expect(privateKey != null , equals(true));
    
    expect(privateKey.version, equals(0));
    expect(privateKey.modulus , equals(new BigInteger ([0x00,0xd8,0x3c,0x3c,0xac,0xb3,0xb7,0x67,0xa1,0x02,0x0f,0x94,0x7c,0xa2,0x01,0x20,0x10,0xba,0x49,0x4d,0x86,0xbd,0xa1,0xef,0xd4,0x37,0x35,0x7b,0x91,0xd5,0xc1,0xe6,0x1b,0x12,0x38,0x4c,0xd3,0xc0,0x1f,0x62,0x83,0x12,0xa5,0xef,0x15,0xcf,0x00,0x3f,0x62,0xc4,0xf6,0xb8,0x35,0xbb,0xb3,0xea,0x99,0x40,0x9f,0x87,0xe5,0x83,0xfa,0x69,0x91])));
    expect(privateKey.publicExponent, equals(65537));
    expect(privateKey.privateExponent , equals(new BigInteger ([0x00,0xa0,0xc2,0x2f,0xcd,0xa9,0x92,0xb9,0xcd,0x5e,0xed,0xdc,0x53,0xc8,0x51,0x93,0xd8,0x3b,0xd6,0x91,0x77,0x91,0xf6,0x19,0x8a,0x29,0x3d,0x6e,0xcf,0xde,0x1e,0x58,0x85,0xfb,0xc0,0xa7,0x66,0xaa,0xca,0x38,0x5d,0xd8,0xb3,0xb1,0x6a,0x58,0x20,0x1b,0xae,0xc3,0x90,0x0b,0x5c,0x16,0x36,0x32,0x1a,0x01,0x67,0xe9,0x56,0xd5,0xfb,0xe0,0x01])));
    expect(privateKey.prime1 , equals(new BigInteger ([0x00,0xf3,0x10,0x3a,0x1b,0xb1,0x4f,0x88,0xf0,0x96,0x98,0x3e,0xcd,0x86,0xcb,0x51,0xf9,0xe0,0xe9,0x32,0x50,0x30,0x03,0x9b,0xe4,0xfb,0xb4,0x17,0x6d,0xe1,0xb7,0x3f,0x91])));
    expect(privateKey.prime2 , equals(new BigInteger ([0x00,0xe3,0xbe,0x79,0x3b,0x59,0x3e,0x4e,0xd5,0xbc,0xe5,0xdb,0x1f,0xf5,0x63,0x46,0x8e,0xeb,0x5c,0xc7,0x15,0xb1,0x2b,0xad,0xf2,0x23,0xd1,0x97,0x0c,0xd8,0x8f,0x8a,0x01])));
    expect(privateKey.exponent1 , equals(new BigInteger ([0x7e,0x4e,0x88,0x63,0xab,0x98,0x31,0x09,0x14,0xb8,0xb8,0xaa,0x04,0xc9,0xd3,0x27,0x8e,0x80,0x9f,0xec,0x9b,0x86,0xc4,0x94,0x11,0x58,0x5c,0x74,0x75,0x3e,0xcc,0x81])));
    expect(privateKey.exponent2, equals(new BigInteger ([0x68,0x7f,0x82,0x72,0xf7,0xec,0xfe,0x11,0x56,0x9e,0x85,0x5f,0xf1,0xa1,0x7e,0xc3,0x9f,0x3d,0x2f,0xe0,0x45,0x2e,0x0c,0x9f,0x79,0x4d,0xf7,0x28,0x1e,0xca,0x26,0x01])));
    expect(privateKey.coefficient , equals(new BigInteger ([0x00,0x92,0xe8,0x95,0xc1,0xa9,0xb7,0xb7,0x05,0xfb,0x69,0x4b,0xba,0x2d,0x52,0xcb,0x99,0x01,0xd4,0x62,0x8d,0xb7,0x94,0xeb,0x43,0x86,0x1b,0x08,0x6c,0x55,0x7d,0x29,0x13])));
  });
  
  test("rsa public key", () {
    //openssl genrsa -out rsa_private_key.pem
    //openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
    File rsa_private_key_file = new File("./resource/rsa_public_key.pem");
    String pem = rsa_private_key_file.readAsStringSync();
    RSAPKCSParser parser = new RSAPKCSParser();
    RSAKeyPair pair = parser.parsePEM(pem);
    var privateKey = pair.private;
    var publicKey = pair.public;
    
    expect(privateKey , equals(null));
    expect(publicKey != null , equals(true));

    expect(publicKey.modulus , equals(new BigInteger ([0x00,0xd8,0x3c,0x3c,0xac,0xb3,0xb7,0x67,0xa1,0x02,0x0f,0x94,0x7c,0xa2,0x01,0x20,0x10,0xba,0x49,0x4d,0x86,0xbd,0xa1,0xef,0xd4,0x37,0x35,0x7b,0x91,0xd5,0xc1,0xe6,0x1b,0x12,0x38,0x4c,0xd3,0xc0,0x1f,0x62,0x83,0x12,0xa5,0xef,0x15,0xcf,0x00,0x3f,0x62,0xc4,0xf6,0xb8,0x35,0xbb,0xb3,0xea,0x99,0x40,0x9f,0x87,0xe5,0x83,0xfa,0x69,0x91])));
    expect(publicKey.publicExponent, equals(65537));
  });

Use this package as a library

1. Depend on it

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


dependencies:
  rsa_pkcs: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:rsa_pkcs/rsa_pkcs.dart';
  
Version Uploaded Documentation Archive
0.1.2 Jun 23, 2016 Go to the documentation of rsa_pkcs 0.1.2 Download rsa_pkcs 0.1.2 archive
0.1.1 Apr 12, 2014 Go to the documentation of rsa_pkcs 0.1.1 Download rsa_pkcs 0.1.1 archive
0.1.0 Mar 15, 2014 Go to the documentation of rsa_pkcs 0.1.0 Download rsa_pkcs 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.1.0.
 
 Because rsa_pkcs depends on asn1lib >=0.1.1 <0.5.2 which requires SDK version >=0.8.10+6 <2.0.0, version solving failed.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Package is too old. (-100 points)

The package was released more than two years ago.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use rsa_pkcs.dart.