RsassaPkcs1V15PublicKey class abstract

RSASSA-PKCS1-v1_5 public key for signing messages.

An RsassaPkcs1V15PublicKey instance hold a public RSA key for verification of signatures following the RSASSA-PKCS1-v1_5 scheme as specified in RFC 3447.

An RsassaPkcs1V15PublicKey can be imported from:

A public-private KeyPair consisting of a RsassaPkcs1V15PublicKey and a RsassaPkcs1V15PrivateKey can be generated using RsassaPkcs1V15PrivateKey.generateKey.

Example

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

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

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

// Given publicKey and signature Alice can verify the message from Bob.
final isValid = await keypair.publicKey.verifyBytes(
  signature,
  utf8.encode(message),
);
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-PKCS1-v1_5 public key in JSON Web Key format.
exportSpkiKey() Future<Uint8List>
Export RSASSA-PKCS1-v1_5 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) Future<bool>
Verify signature of data using this RSASSA-PKCS1-v1_5 public key.
verifyStream(List<int> signature, Stream<List<int>> data) Future<bool>
Verify signature of data using this RSASSA-PKCS1-v1_5 public key.

Operators

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

Static Methods

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