CryptoUtils class

Constructors

CryptoUtils()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

legacySecretFilesUnresolved → bool
True while a legacy secret file sits on disk unresolved, unreadable or naming another master key (see migrateLegacySecretFiles). The key in use may then not be the one every safe was encrypted with: a failed decryption is reported as a SecureStorageException rather than a wrong PIN, and no key is generated. The host app tells the user which state they are in.
no setter

Static Methods

clearMasterKey() → void
Forgets the cached master key; the next call reads the store again.
clearSecureStorage() → Future<void>
Removes the master key from the secret store and forgets the cached one. Every safe encrypted with it becomes undecryptable: the caller removes the safes in the same breath.
decrypt(EncryptedMnemonic enc, String pin) → Future<String>
decryptWithKey(String encryptedData, Uint8List key, Uint8List iv) → Future<String>
Decrypt data with a specific key using AES-GCM
encrypt(String mnemonic, String pin) → Future<EncryptedMnemonic>
encryptWithIV(String data, String pin, Uint8List iv) → Future<EncryptedMnemonic>
Encrypt data with a specific IV (for legacy wallets where salt and password need same IV)
encryptWithKey(String data, Uint8List key, Uint8List iv) → Future<String>
Encrypt data with a specific key using AES-GCM
generateRandom(int len) → Uint8List
guardMasterKeyWith(bool encryptedDataExists()) → void
Tells masterKey how to know whether a safe already depends on the key. With one, a store that answers "no master key" is failing, not empty: a key generated then would lock every safe for good.
hashData(Uint8List data) → Uint8List
Hash data using SHA-256
masterKey() → Future<Uint8List>
The 32-byte master key that peppers every PIN derivation, generated on the first call and kept in the secret store ever after.
migrateLegacySecretFiles(List<String> paths) → Future<LegacySecretFileReport>
Moves the pre-1.8.0 macOS clear-text secret files at paths (most recent location first, .tmp siblings included) into the Keychain and destroys them: every entry is written, read back, and only then are the files overwritten and deleted. Call once at startup on macOS, after useMacosKeychainService and before anything asks for a secret.
secureContainsKey({required String key}) → Future<bool>
Whether the store holds key; see secureRead for failures.
secureDelete({required String key}) → Future<void>
Removes key; see secureRead for failures.
secureRead({required String key}) → Future<String?>
The value stored under key in the secret store shared by every durt2 service, null when there is none. A store failure throws SecureStorageException; it is never read as an absence.
secureReadAll() → Future<Map<String, String>>
Every entry of the store; see secureRead for failures.
secureWrite({required String key, required String value}) → Future<void>
Stores value under key; see secureRead for failures.
useMacosKeychainService(String service) → void
Names the macOS Keychain service durt2 stores its secrets under, before any secret is read or written: the host app's bundle identifier, so two durt2 apps on one Mac never share an entry. Defaults to durt2.