@@ -110,20 +110,20 @@ class CryptoStore {
110110
111111 /// Creates a [CryptoStoreWithPasswordSignature] from the given [password] .
112112 CryptoStore .fromPassword (String password, Salt salt) : this ._(
113- key: _deriveKey (password, salt),
113+ key: _deriveKey (password, salt).bytes ,
114114 salt: salt,
115115 );
116116
117117 /// Generates a derived key from the given [password] and save it to the device secure storage.
118118 /// Also returns the salt that has been used.
119- static Uint8List _deriveKey (String password, Salt salt) {
119+ static Argon2HashDigest _deriveKey (String password, Salt salt) {
120120 Argon2 argon2 = Argon2 (
121121 iterations: Argon2Parameters .iterations,
122122 memorySizeKB: Argon2Parameters .memorySize,
123123 parallelism: Argon2Parameters .parallelism,
124124 salt: salt.value,
125125 );
126- return argon2.convert (utf8.encode (password)).bytes ;
126+ return argon2.convert (utf8.encode (password));
127127 }
128128
129129 /// Encrypts the given text.
@@ -151,10 +151,7 @@ class CryptoStore {
151151 }
152152
153153 /// Checks if the given password is valid.
154- bool checkPasswordValidity (String password) {
155- Uint8List derivedKey = _deriveKey (password, salt);
156- return memEquals (derivedKey, key);
157- }
154+ bool checkPasswordValidity (String password) => _deriveKey (password, salt).isEqual (key);
158155
159156 /// Checks if the given [encryptedData] could be decrypted using [decrypt] .
160157 /// There seems to be no better way of doing this.
@@ -164,7 +161,7 @@ class CryptoStore {
164161 bool canDecrypt (Uint8List encryptedData) => decrypt (encryptedData) != null ;
165162
166163 /// Returns the HMAC secret key corresponding to the [key] .
167- MACHashBase createHmacKey () => sha256.hmac.by (key);
164+ MACHashBase get hmacSecretKey => sha256.hmac.by (key);
168165}
169166
170167/// Represents a decoded salt.
0 commit comments