Multiple masters with signatures

This is the re-submission of PR #13570 with enhancements to crypt.py to make it more readable and maintainable. The previous versions code-flow in crypt.py was a little too complicated too follow. The rest is the same as in #13570.