SHA-384/PSS Signature verification using PointyCastle in Dart

712 Views Asked by At

I have a public key, a message and a signature. I want to verify that the signature is correct using SHA-384/PSS signer from PointyCastle.

I managed to build something but the signature verification fails and I suppose it is because of salt parameter which I don't know how to build/create it.

  var rsaPublicKey = RSAPublicKey.fromPEM(publicKey);

  final signer = Signer('SHA-384/PSS');
  AsymmetricKeyParameter<RSAAsymmetricKey> keyParams =
      PublicKeyParameter<RSAPublicKey>(rsaPublicKey.asPointyCastle);
  signer.init(
    false,
    ParametersWithSalt(keyParams, Uint8List()), // THIS is the salt 
  );
  final sig = PSSSignature(base64Decode(signature));

  final verified = signer.verifySignature(
    Uint8List.fromList(message.codeUnits),
    sig,
  );

I'm not sure what to pass to the second parameter of ParametersWithSalt(keyParams, Uint8List() needed to initialise the signer.

Any hint is highly appreciated.

0

There are 0 best solutions below