ParallelMasterKeyComputation mixin
A mixin on PassphraseBasedKeyManager to allow key derivation in an isolate.
This mixin can be used to let the key manager derive the master key from the passphrase on a separate isolate to prevent the application (typically UI) from freezing.
This mixin still has abstract methods, as this package does not depend on flutter and thus leaves it up to the implementer to actually execute the code on the separate isolate. However, in case you are using flutter, you can simply copy the following snippted:
import 'package:flutter/foundation.dart' as ff;
import 'package:sodium_libs/sodium_libs.dart';
class MyKeyManager extends PassphraseBasedKeyManager
with ParallelMasterKeyComputation {
MyKeyManager(Sodium sodium) : super(sodium: sodium);
@override
CreateSodiumFn get sodiumFactory => SodiumInit.init;
@override
Future<R> compute<Q, R>(ComputeCallback<Q, R> callback, Q message) =>
ff.compute(
callback,
message,
debugLabel: '$MyKeyManager.compute',
);
@override
FutureOr<MasterKeyComponents> loadMasterKeyComponents() {
// TODO: implement loadMasterKeyComponents
throw UnimplementedError();
}
}
- Superclass Constraints
Properties
- sodiumFactory → CreateSodiumFn
-
A getter that must return a static or top level function that
asynchronously returns a sodium instance.
no setter
- sodium → Sodium
-
The sodium instance used by the key manager.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
compute<
Q, R> (ComputeCallback< Q, R> callback, Q message) → Future<R> - The compute method which actually runs the parallel computation.
-
deriveKey(
MasterKeyComponents masterKeyComponents, int keyLength) → Future< SecureKey> - @nodoc
-
dispose(
) → void -
Disposes the key manager.
inherited
-
initialize(
) → Future< void> -
Initializes the key manager.
inherited
-
loadMasterKeyComponents(
int saltLength) → FutureOr< MasterKeyComponents> -
Asynchronously loads the master key components to derive the key from.
inherited
-
loadRemoteMasterKey(
int keyLength) → Future< SecureKey> -
Asynchronously loads the master key for the key manager.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remoteKeyForType(
String type, int keyLength) → KeyInfo -
Generates a
SecureKey
ofkeyLength
bytes for the giventype
.inherited -
remoteKeyForTypeAndId(
String type, int keyId, int keyLength) → SecureKey -
Generates a
SecureKey
ofkeyLength
bytes for the giventype
andkeyId
.inherited -
subkeyIdForType(
String type) → int -
Derives a key id from a given repository
type
.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited