DW port (copy) of https://github.com/kjur/jsrsasign