This is my attempt of a (kind of) minimal (kind of) reproducible example:
Longer explanation
The restic test repository was encrypted with the password "abc".
As a test snapshot I backed up a single empty directory named "a" with restic.
What my script currently does is, it gets the snapshot data:
{'time': '2023-12-20T21:05:01.168872983+01:00',
'tree': '2a2d34b656d01f27573b2978fd592b07cf65fdbf2a6c48897bd2a9d5a8f7f20e',
'paths': ['/.../test'],
'hostname': '...',
'username': '...',
'uid': 1000,
'gid': 1000}
then reads the blob specified in the “tree” field of snapshot data and builds a tree object from it:
TreeData(
nodes=[
NodeData(
name='a',
type='dir',
...
subtree='ac08ce34ba4f8123618661bef2425f7028ffb9ac740578a3ee88684d2523fee8',
...
)
]
)
In order to read the above subtree (ac08…) I check the index and find the following information for ac08…:
{
"packs":[
{
"id":"96e29d9f2abfc229087e8e2c2baf39eb17bb85b13d8630d0c0c6550626aedecf",
"blobs":[
{
"id":"ac08ce34ba4f8123618661bef2425f7028ffb9ac740578a3ee88684d2523fee8",
"type":"tree",
"offset":0,
"length":54,
"uncompressed_length":13
},
...
]
}
]
}
(To verify I also use restic cat index and get the same result)
I see that the subtree is contained in the pack 96e29d9f2abfc229087e8e2c2baf39eb17bb85b13d8630d0c0c6550626aedecf with offset 0 and length 54.
The encrypted tree blob looks like this (in base64):
WIKi5myToDDC/nLhW8G3l3Mld8uppLNnD2hpLsZWFldYuSQmmhmfyJVayJWaWnaYXdtnX+fC
I decrypt it using the following master key:
{
"mac": {
"k": "2w1lKAZ7BnBJPE7OiWmTeg==",
"r": "jvqsBGjynwHk0kIBdBltAQ=="
},
"encrypt": "Sjwm07HzbUqo+UqBapT5TzGbBnaWyzhZi5zgzsDUmdw="
}
After successful decryption and MAC authentication (in Python) I get the following raw data for the subtree:
b'(\xb5/\xfd\x00\x00i\x00\x00{"nodes":[]}\n'
Loading this with json results in a UnicodeDecodeError:
import json
data = b'(\xb5/\xfd\x00\x00i\x00\x00{"nodes":[]}\n'
json.loads(data)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 1: invalid start byte
I hope this makes thing clearer.