RsaPss class abstract

RSA-PSS SignatureAlgorithm.

In browsers, the default implementation will use Web Cryptography API. On other platforms, DartRsaPss will be used.

Private keys must be instances of RsaKeyPair. Public keys must be instances of RsaPublicKey.

You can use package:jwk to encode/decode JSON Web Key (JWK) data.

Example

import 'package:cryptography/cryptography.dart';

Future<void> main() async {
  final algorithm = RsaPss(Sha256());

  // Generate a key pair
  final keyPair = await algorithm.newKeyPair();

  // Sign a message
  final message = <int>[1,2,3];
  final signature = await algorithm.sign(
    message,
    keyPair: keyPair,
  );
  print('Signature bytes: ${signature.bytes}');
  print('Public key: ${signature.publicKey.bytes}');

  // Anyone can verify the signature
  final isSignatureCorrect = await algorithm.verify(
    message,
    signature: signature,
  );
}
Inheritance
Implementers

Constructors

RsaPss(HashAlgorithm hashAlgorithm, {int nonceLengthInBytes = defaultNonceLengthInBytes})
Constructs RSA-PSS with the given hash algorithm.
factory
RsaPss.constructor()
Constructor for subclasses.
const
RsaPss.sha256({int nonceLengthInBytes = defaultNonceLengthInBytes})
A shorthand for constructing RSA-PSS-SHA256.
factory
RsaPss.sha512({int nonceLengthInBytes = defaultNonceLengthInBytes})
A shorthand for constructing RSA-PSS-SHA512.
factory

Properties

hashAlgorithm HashAlgorithm
Hash algorithm used by the RSA-PSS.
no setter
hashCode int
The hash code for this object.
no setteroverride
keyPairType KeyPairType<KeyPairData, PublicKey>
no setteroverride
nonceLengthInBytes int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

newKeyPair({int modulusLength = defaultModulusLength, List<int> publicExponent = defaultPublicExponent}) Future<RsaKeyPair>
Generates a new KeyPair for this algorithm.
override
newKeyPairFromSeed(List<int> seed) Future<KeyPair>
Generates a new KeyPair that uses the seed bytes.
inherited
newSignatureWand() Future<SignatureWand>
Generates a new SignatureWand that has a random KeyPair.
inherited
newSignatureWandFromKeyPair(KeyPair keyPair) Future<SignatureWand>
Generates a new SignatureWand that uses the given KeyPair.
inherited
newSignatureWandFromSeed(List<int> seed) Future<SignatureWand>
Generates a new SignatureWand that uses the given seed bytes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sign(List<int> message, {required KeyPair keyPair}) Future<Signature>
Signs bytes.
inherited
signString(String message, {required KeyPair keyPair}) Future<Signature>
Signs a string.
inherited
toString() String
A string representation of this object.
override
verify(List<int> message, {required Signature signature}) Future<bool>
Verifies whether bytes was signed with signature.
inherited
verifyString(String message, {required Signature signature}) Future<bool>
Verifies whether a string was signed with signature.
inherited

Operators

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

Constants

defaultModulusLength → const int
Default modulus length (in bits).
defaultNonceLengthInBytes → const int
Default nonce length (in bytes).
defaultPublicExponent → const List<int>
Default public exponent.