As far as I know there is no legal precedence (and I'm not a lawyer), but I think that figuring out data formats and protocols counts as "ideas and principles" -- which is okay. It's hard to say, really, courts aren't famous for showing any understanding of computer science.
In Norway, we have an un-waverable right by law to reverse engineer computer systems for learning purposes.
They are described in Åndsverkloven §§ 39h and 39i.
Roughly translated excerpts:
§ 39h Whoever has the right to use a computer program, can copy, change and work on the program to the extent necessary in order to utilize the program in accordance with its purpose, including in order to correct errors in the program.
Whoever has the right to use a copy of a computer program can, during such reading, screen display, running, transfer or storage of the program that the user has the right to do, monitor, examine or probe the working of the program in order to determine the ideas and principles on which the individual parts of the program is based. [This right is un-waverable]
§ 39i You are allowed to produce a copy of a computer program's code and translate the form of the code, when this is a prerequisite in order to produce the information necessary to achieve functional interaction between a self-developed program and other programs, if
a) the actions are performed by a person who has the right to use a copy of a computer program, or acting on behalf of someone who do,
b) the information is not already easily accessible, and
c) the actions are limited to the parts of the original program necessary to achieve functional interaction.
[A few limitations on utilization of the information]