Implemented new authentication scheme from doc/SECURITY2.