netbsd 版本的 openssh 支持 "diffie-hellman-group-exchange-sha256" 但不支持 mac 的 SHA256

netbsd version of openssh has support for "diffie-hellman-group-exchange-sha256" but not for SHA256 for macs

我使用的是旧版本的 netbsd。我想将 openssh 配置为使用强密码和 macs,但是当看到可用的 macs 时,它不支持 SHA256 及更高版本。 mac支持的是

macs[] = {
    { "hmac-sha1",          SSH_EVP, EVP_sha1, 0, -1, -1 },
    { "hmac-sha1-96",       SSH_EVP, EVP_sha1, 96, -1, -1 },
    { "hmac-md5",           SSH_EVP, EVP_md5, 0, -1, -1 },
    { "hmac-md5-96",        SSH_EVP, EVP_md5, 96, -1, -1 },
    { "hmac-ripemd160",     SSH_EVP, EVP_ripemd160, 0, -1, -1 },
    { "hmac-ripemd160@openssh.com", SSH_EVP, EVP_ripemd160, 0, -1, -1 },
#ifdef UMAC_HAS_BEEN_UNBROKEN
    { "umac-64@openssh.com",    SSH_UMAC, NULL, 0, 128, 64 },
#endif
    { NULL,             0, NULL, 0, -1, -1 }
};

但是当我检查支持的密钥交换密码时,我发现可以使用 SHA256

#define KEX_DH1         "diffie-hellman-group1-sha1"
#define KEX_DH14        "diffie-hellman-group14-sha1"
#define KEX_DHGEX_SHA1      "diffie-hellman-group-exchange-sha1"
#define KEX_DHGEX_SHA256    "diffie-hellman-group-exchange-sha256"

怎么样。如果我的 netbsd openssh 中有 SHA256 的实现,为什么它不能作为 mac 密码使用?

OpenSSH 5.0 支持 SHA-256 密钥交换算法,但不支持具有 SHA-256 哈希的 MACs。供参考,有源码:

https://github.com/openssh/openssh-portable/blob/V_5_0_P1/myproposal.h

MAC密钥交换 中的 SHA256 用法完全不同,两者互不影响。是否在其中任何一个中使用 SHA256 取决于此哈希在底层 OpenSSL 中的可用性,而且还取决于 OpenSSH 是否实现了此类算法。 10 年前(2007 年),它仅作为密钥交换算法实现(MAC 后来被标准化)。

RFC4253 does not list any SHA256 algorithms. The DH key exchange method was standardized in RFC4419 (2006), but the HMACS using SHA2 were standardized as late as in 2012 in RFC6668.

你的版本介于两者之间,没有这方面的标准,所以没有实现。