If someone is asked to decrypt their drive for a murder case, could they then invoke the Fifth Amendment on the basis that they might have child pornography? Can the Fifth Amendment protect you on an unrelated crime that you mention without either admitting to it?
In short, a judge will grant a person legal immunity from prosecution. This removes the fifth amendment argument, as you cannot be prosecuted for the child porn, and you can be compelled to testify.
For example, an accomplice to a crime might be offered immunity -- after which the accomplice cannot refuse to testify under the fifth amendment. Remember, the fifth only guarantees that you will not be compelled to serve as a witness against yourself -- it does NOT grant you the right to remain silent at all times, contrary to popular belief.