asset_pack_crypto
library
Functions
-
buildPack(Map<String, Uint8List> files, PackKeys keys, {required List<int> compress(List<int>), required Uint8List randomBytes(int)})
→ Uint8List
-
Builds a pack.
files maps logical path -> original bytes.
compress is zlib deflate (dart:io's zlib in the packer).
randomBytes supplies nonces (Random.secure in the packer).
-
chacha20(List<int> key, List<int> nonce, List<int> data, {int counter = 0})
→ Uint8List
-
Returns
data XORed with the ChaCha20 keystream. data is not modified.
-
decryptEntry(Uint8List pack, int dataStart, PackEntry e, PackKeys keys)
→ Uint8List
-
Checks and decrypts one entry. Returns the stored bytes, which still need
inflating with zlib when PackEntry.compressed is true.
-
entryMac(Uint8List macKey, String path, List<int> nonce, List<int> cipher)
→ Uint8List
-
MAC for a single file. The path is included so entries can't be swapped.
-
hmacSha256(List<int> key, List<int> data)
→ Uint8List
-
-
hmacSha256Parts(List<int> key, List<List<int>> parts)
→ Uint8List
-
HMAC over several byte chunks without first joining them into one list.
-
indexMac(Uint8List macKey, List<int> nonce, int length, List<int> cipher)
→ Uint8List
-
-
macEquals(List<int> a, List<int> b)
→ bool
-
Compares two MACs in constant time.
-
readPackIndex(Uint8List pack, PackKeys keys)
→ PackIndex
-
Reads and checks the header and index of a pack.
Exceptions / Errors
-
AssetPackException
-
Thrown when a pack is damaged, tampered with or opened with the wrong key.