ueman / passkit

Various Dart & Flutter packages to work with Apple's PassKit
14 stars 1 forks source link

Write signature #74

Open ueman opened 1 month ago

ueman commented 1 month ago
ueman commented 1 month ago

There's some code at which may help with it: https://github.com/tomasmcguinness/dotnet-passbook/blob/master/Passbook.Generator/PassGenerator.cs

// Pseudo Code

// This requires the user to pass a certificate with the private key included to the code as keyData

// using https://pub.dev/packages/pem
final pem = PemCodec(PemLabel.privateKey).decode(keyData);

// using pointycastle

final modulus = ASN1Object.fromBytes(pem[1]) as ASN1Integer
final exponent = ASN1Object.fromBytes(pem[3]) as ASN1Integer
final p = ASN1Object.fromBytes(pem[4]) as ASN1Integer
final q = ASN1Object.fromBytes(pem[5]) as ASN1Integer

final privateKey = RSAPrivateKey(modulus, exponent, p, q);
ueman commented 2 weeks ago

As a temporary solution, we could provide a callback for writing the signature. There are multiple examples for signing PKPass files with OpenSSL, and there are also OpenSSL bindings for Dart/Flutter. I however intend this library (and it's dependencies) to be Dart only.

Pseudo code example:

final pass = PkPass(...);
final pkPassFile = pass.create(signatureWriter: (contentHashes) {
  // create signature here based on the contentHashes
  return signature;
});