This is taken verbatim from openssh 6.8p1, which appears to have lightly tweaked it from the openbsd version.