Skip to content

Plugin to digitally sign data with PKCS12 certificates

License

Notifications You must be signed in to change notification settings

shaxxx/flutter_pkcs12

Repository files navigation

flutter_pkcs12

Flutter plugin that allows you to use PKCS12 (p12) keystore for digital signing. Result of signing is RSA signature with PKCS1 padding.

Source code

Project was forked from flutter_p12 plugin. I decided to move it to new plugin because

  • i expect same signature result on Android & iOS using same input parameters which is not the case in the original plugin
  • i need a way to specify hash algorithm to be used during signing
  • i don't want to polute plugin with unsupported APIs or only partially supported (Android only)

Features

All features are implemented on Android,iOS,Linux,Windows & MacOS.

Only 2 methods are provided signDataWithP12 and readPublicKey

signDataWithP12 expects p12 keystore file as bytes (ie. from filesystem or from assets), password used to decrypt the key, data bytes to be signed and hash method to be used.

Data bytes are usually encoded string (ie. utf8.encode("Some data"); if you're using utf8 encoding) BEFORE hashing. Do not hash your data before using it as signing parameter. Native plugin will take care of that. You'll have to choose what hash algorithm to use. Curently supported are

  • SHA1
  • SHA256
  • SHA512

While there are other possible hash algorithms I decided to use only these since they are most used and implemented on both platforms. MD5 is considered insecure and unsupported as of iOS 5.0.

For more details check Android,iOS, Linux,Windows,MacOS documentation.

readPublicKey reads public key from p12 file and returns it as Base64 string.

For more details check out example

About

Plugin to digitally sign data with PKCS12 certificates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published