IIRC rsa.py already has this. Move it to utils?