wstrange / asn1lib

Dart ASN1 Encoder / Decoder
BSD 2-Clause "Simplified" License
30 stars 31 forks source link

support for RSA Private key pem file #1

Closed amaurel closed 10 years ago

amaurel commented 10 years ago

Hello,

I am writing a library to generate Json Web Token (here for the context https://developers.google.com/accounts/docs/OAuth2ServiceAccount). The token has to be signed using RSA and SHA-256 digest, cipher library is used to do this (https://github.com/izaera/cipher/issues/71). Now and last step, I need to read a RSA private key from a PEM file, and here asn1lib get involved. I was glad to find your library, thanks for your work.

I've made some modifications to asn1lib to support RSA Private key pem file format. You will find those changes here https://github.com/amaurel/asn1lib

Changes to support RSA Private key : PEM file Add import "package:bignum/bignum.dart"; in asn1lib.dart Add ASN1ObjectIdentifier class Add OBJECT_IDENTIFIER in asn1constants.dart Modify ASN1Parser._doPrimitive to take OBJECT_IDENTIFIER and NULL_TYPE into account Modify ASN1Null add contructor ASN1Null.fromBytes Modify ASN1Integer to support BigInteger Modify asn1element_test.dart to test BigInteger case, and rsa private key test Add test/resource folder to store rsa key for testing

Please tell what you think, if you are interested by those changes I will send a pull request.

Regards, Alex

amaurel commented 10 years ago

I've just added support for RSA public key

amaurel commented 10 years ago

Changes to support RSA public key : PEM file

Add ASN1BitString class : not sure how to handle bitstring when unused bits is not zero

Add BIT_STRING_TYPE in asn1constants.dart

Modify ASN1Parser._doPrimitive to take BIT_STRING_TYPE into account

Modify asn1element_test.dart to test rsa public key

amaurel commented 10 years ago

https://github.com/amaurel/rsa_pkcs PKCS#1,PKCS#8 PKCS#8 encrypted not yet implemented

More test cases will come ...

An interesting link that describes DER format : https://polarssl.org/kb/cryptography/asn1-key-structures-in-der-and-pem

wstrange commented 10 years ago

Hi Alex

Please do send a pull request! I would be happy to incorporate your changes.

On Wed, Mar 12, 2014 at 4:51 AM, Alex notifications@github.com wrote:

https://github.com/amaurel/rsa_pkcs PKCS#1,PKCS#8 PKCS#8 encrypted not yet implemented

More test cases will come ...

An interesting link that describes DER format : https://polarssl.org/kb/cryptography/asn1-key-structures-in-der-and-pem

Reply to this email directly or view it on GitHubhttps://github.com/wstrange/asn1lib/issues/1#issuecomment-37395571 .