konstantinullrich / crypton

A simple Dart library for asymmetric encryption and digital signatures
https://pub.dev/packages/crypton
MIT License
33 stars 12 forks source link

Support to load a pkcs12 certificate file #37

Open reinies opened 1 year ago

reinies commented 1 year ago

Hello Konstantin,

I would like to use your library and am currently stuck on loading an existing certificate (with private and public key). I would like to make a signature with the private key based on SHA256withECDSA. Unfortunately, I have not found a way to load an existing file with password.

Code example of what I am thinking of:

// Load the PKCS12 file
  File pkcs12File = File('path/to/your/pkcs12/file.p12');
  Uint8List pkcs12Data = await pkcs12File.readAsBytes();

  // Decrypt the PKCS12 file using the password
  String pkcs12Password = 'your_password_here';
  ECKeypair p12EccKeyPair =  ECKeypair.fromPKCS12(pkcs12Data, pkcs12Password);

  // Get the private key for signature
  ECPrivateKey privateKey = p12EccKeyPair.privateKey;
  ...

I only saw that you support "fromPEM for RSA Keys.

Is there a other way to load a pkcs12?

Best regards, Reinhard

konstantinullrich commented 1 year ago

Hey Reinhard,

currently, there is no support for pkcs12. I'll have a look if/how the underlying library supports pkcs12 and get back to you as soon as possible

Best regards, Konsti