|
|
@ -258,19 +258,19 @@ class KdbxBody extends KdbxNode { |
|
|
|
Uint8List _encryptV4( |
|
|
|
Uint8List _encryptV4( |
|
|
|
KdbxFile kdbxFile, Uint8List compressedBytes, Uint8List cipherKey) { |
|
|
|
KdbxFile kdbxFile, Uint8List compressedBytes, Uint8List cipherKey) { |
|
|
|
final header = kdbxFile.header; |
|
|
|
final header = kdbxFile.header; |
|
|
|
final cipherId = base64.encode(header.fields[HeaderFields.CipherID].bytes); |
|
|
|
final cipher = header.cipher; |
|
|
|
if (cipherId == CryptoConsts.CIPHER_IDS[Cipher.aes].uuid) { |
|
|
|
if (cipher == Cipher.aes) { |
|
|
|
_logger.fine('We need AES'); |
|
|
|
_logger.fine('We need AES'); |
|
|
|
final result = kdbxFile.kdbxFormat |
|
|
|
final result = kdbxFile.kdbxFormat |
|
|
|
._encryptContentV4Aes(header, cipherKey, compressedBytes); |
|
|
|
._encryptContentV4Aes(header, cipherKey, compressedBytes); |
|
|
|
// _logger.fine('Result: ${ByteUtils.toHexList(result)}'); |
|
|
|
// _logger.fine('Result: ${ByteUtils.toHexList(result)}'); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} else if (cipherId == CryptoConsts.CIPHER_IDS[Cipher.chaCha20].uuid) { |
|
|
|
} else if (cipher == Cipher.chaCha20) { |
|
|
|
_logger.fine('We need chacha20'); |
|
|
|
_logger.fine('We need chacha20'); |
|
|
|
return kdbxFile.kdbxFormat |
|
|
|
return kdbxFile.kdbxFormat |
|
|
|
.transformContentV4ChaCha20(header, compressedBytes, cipherKey); |
|
|
|
.transformContentV4ChaCha20(header, compressedBytes, cipherKey); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw UnsupportedError('Unsupported cipherId $cipherId'); |
|
|
|
throw UnsupportedError('Unsupported cipherId $cipher'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -308,7 +308,7 @@ class KdbxBody extends KdbxNode { |
|
|
|
// final doc = xml.XmlDocument(); |
|
|
|
// final doc = xml.XmlDocument(); |
|
|
|
// doc.children.add(xml.XmlProcessing( |
|
|
|
// doc.children.add(xml.XmlProcessing( |
|
|
|
// 'xml', 'version="1.0" encoding="utf-8" standalone="yes"')); |
|
|
|
// 'xml', 'version="1.0" encoding="utf-8" standalone="yes"')); |
|
|
|
final node = builder.build() as xml.XmlDocument; |
|
|
|
final node = builder.buildDocument(); |
|
|
|
|
|
|
|
|
|
|
|
return node; |
|
|
|
return node; |
|
|
|
} |
|
|
|
} |
|
|
@ -533,17 +533,17 @@ class KdbxFormat { |
|
|
|
|
|
|
|
|
|
|
|
Uint8List decrypt( |
|
|
|
Uint8List decrypt( |
|
|
|
KdbxHeader header, Uint8List encrypted, Uint8List cipherKey) { |
|
|
|
KdbxHeader header, Uint8List encrypted, Uint8List cipherKey) { |
|
|
|
final cipherId = base64.encode(header.fields[HeaderFields.CipherID].bytes); |
|
|
|
final cipher = header.cipher; |
|
|
|
if (cipherId == CryptoConsts.CIPHER_IDS[Cipher.aes].uuid) { |
|
|
|
if (cipher == Cipher.aes) { |
|
|
|
_logger.fine('We need AES'); |
|
|
|
_logger.fine('We need AES'); |
|
|
|
final result = _decryptContentV4(header, cipherKey, encrypted); |
|
|
|
final result = _decryptContentV4(header, cipherKey, encrypted); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} else if (cipherId == CryptoConsts.CIPHER_IDS[Cipher.chaCha20].uuid) { |
|
|
|
} else if (cipher == Cipher.chaCha20) { |
|
|
|
_logger.fine('We need chacha20'); |
|
|
|
_logger.fine('We need chacha20'); |
|
|
|
// throw UnsupportedError('chacha20 not yet supported $cipherId'); |
|
|
|
// throw UnsupportedError('chacha20 not yet supported $cipherId'); |
|
|
|
return transformContentV4ChaCha20(header, encrypted, cipherKey); |
|
|
|
return transformContentV4ChaCha20(header, encrypted, cipherKey); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw UnsupportedError('Unsupported cipherId $cipherId'); |
|
|
|
throw UnsupportedError('Unsupported cipherId $cipher'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|