RsaSsaPkcs1v15 class abstract

RSA-SSA-PKCS1v15 SignatureAlgorithm.

In browsers, the default implementation will use Web Cryptography API. On other platforms, DartRsaSsaPkcs1v15 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 = RsaSsaPkcs1v15(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

RsaSsaPkcs1v15(HashAlgorithm hashAlgorithm)
factory
RsaSsaPkcs1v15.constructor()
Constructor for subclasses.
const
RsaSsaPkcs1v15.sha256()
A shorthand for RSA-SSA-PKCS1v15-SHA256.
factory
RsaSsaPkcs1v15.sha512()
A shorthand for RSA-SSA-PKCS1v15-SHA512.
factory

Properties

hashAlgorithm HashAlgorithm
Hashing algorithm.
no setter
hashCode int
The hash code for this object.
no setteroverride
keyPairType KeyPairType<KeyPairData, PublicKey>
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

newKeyPair({int modulusLength = RsaSsaPkcs1v15.defaultModulusLength, List<int> publicExponent = RsaSsaPkcs1v15.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
defaultPublicExponent → const List<int>