verifyBytes abstract method

Future<bool> verifyBytes(
  1. List<int> signature,
  2. List<int> data,
  3. int saltLength
)

Verify signature of data using this RSASSA-PSS public key.

Returns true if the signature was made the private key matching this public key. This uses the Hash specified when the key was generated or imported. The length of the salt is specified in bytes using saltLength.

For limitations on saltLength see RsaPssPrivateKey.signBytes.

Example

import 'dart:convert' show utf8;
import 'package:webcrypto/webcrypto.dart';

// Generate a key-pair.
final keyPair = await RsaPssPrivateKey.generateKey(
  4096,
  BigInt.from(65537),
  Hash.sha256,
);

// Use the same salt for signing and verifying.
const saltLength = 256 / 8;

// Using privateKey Bob can sign a message for Alice.
final message = 'Hi Alice';
final signature = await keyPair.privateKey.signBytes(
  utf8.encode(message),
  saltLength,
);

// Given publicKey and signature Alice can verify the message from Bob.
final isValid = await keypair.publicKey.verifyBytes(
  signature,
  utf8.encode(message),
  saltLength,
);
if (isValid) {
  print('Authentic message from Bob: $message');
}

Implementation

Future<bool> verifyBytes(
  List<int> signature,
  List<int> data,
  int saltLength,
);