RsaPssPublicKey class abstract

RSASSA-PSS public key for verifying signatures.

An RsaPssPublicKey instance holds a public RSA key for verification of signatures using the RSASSA-PSS scheme as specified in RFC 3447.

An RsaPssPublicKey can be imported from:

A public-private KeyPair consisting of a RsaPssPublicKey and a RsaPssPrivateKey can be generated using RsaPssPrivateKey.generateKey.

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 saltLength 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');
}
Annotations
  • @sealed

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

exportJsonWebKey() Future<Map<String, dynamic>>
Export RSASSA-PSS public key in JSON Web Key format.
exportSpkiKey() Future<Uint8List>
Export RSASSA-PSS public key in SPKI format.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
verifyBytes(List<int> signature, List<int> data, int saltLength) Future<bool>
Verify signature of data using this RSASSA-PSS public key.
verifyStream(List<int> signature, Stream<List<int>> data, int saltLength) Future<bool>
Verify signature of data using this RSASSA-PSS public key.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

importJsonWebKey(Map<String, dynamic> jwk, Hash hash) Future<RsaPssPublicKey>
Import RSASSA-PSS public key in JSON Web Key format.
importSpkiKey(List<int> keyData, Hash hash) Future<RsaPssPublicKey>
Import RSASSA-PSS public key in SPKI format.