Check out http://dev.mysql.com/doc/internals/en/connection-phase.html#packet-Protocol::AuthSwitchResponse and http://dev.mysql.com/doc/internals/en/connection-phase.htm#packet-Protocol::OldAuthSwitchRequest