As pertains to Latvia specifically (I apologise if my Github <-> HN username assumption is inaccurate), then the relevant laws are implemented under "Copyright Law, Chapter XI, Section 68".
We also still have laws in Australia that permit reverse engineering for the purpose of interoperability. This is what I meant above where I wrote:
> To clarify, none of the reverse engineering stuff is the issue.
The problem is these laws are superseded when circumvention of technological measures pertaining to copy protection is involved.