RsaPssPrivateKey class abstract

RSASSA-PSS private key for signing messages.

An RsaPssPrivateKey instance holds a private RSA key for computing signatures using the RSASSA-PSS scheme as specified in RFC 3447.

An RsaPssPrivateKey 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 private key in JSON Web Key format.
exportPkcs8Key() Future<Uint8List>
Export this RSASSA-PSS private key in PKCS #8 format.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
signBytes(List<int> data, int saltLength) Future<Uint8List>
Sign data with this RSASSA-PSS private key.
signStream(Stream<List<int>> data, int saltLength) Future<Uint8List>
Sign data with this RSASSA-PSS private key.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

generateKey(int modulusLength, BigInt publicExponent, Hash hash) Future<KeyPair<RsaPssPrivateKey, RsaPssPublicKey>>
Generate an RSASSA-PSS public/private key-pair.
importJsonWebKey(Map<String, dynamic> jwk, Hash hash) Future<RsaPssPrivateKey>
Import RSASSA-PSS private key in JSON Web Key format.
importPkcs8Key(List<int> keyData, Hash hash) Future<RsaPssPrivateKey>
Import RSASSA-PSS private key in PKCS #8 format.