Policy-based cryptography and applications