@@ -154,9 +154,12 @@ func TestKnownKeyHash(t *testing.T) {
154154 hostkey git2go.HostkeyCertificate
155155 wantMatches bool
156156 }{
157- {"good sha256 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ("nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8" )}, true },
158- {"bad sha256 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ("ROQFvPThGrW4RuWLoL9tq9I9zJ42fK4XywyRtbOz/EQ" )}, false },
159- {"good sha1 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 , HashSHA1 : sha1Fingerprint ("v2toJdKXfFEaR1u++4iq1UqSrHM" )}, true },
157+ {"good sha256 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 | git2go .HostkeySHA1 | git2go .HostkeyMD5 , HashSHA256 : sha256Fingerprint ("nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8" )}, true },
158+ {"bad sha256 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 | git2go .HostkeySHA1 | git2go .HostkeyMD5 , HashSHA256 : sha256Fingerprint ("ROQFvPThGrW4RuWLoL9tq9I9zJ42fK4XywyRtbOz/EQ" )}, false },
159+ {"good sha1 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 | git2go .HostkeyMD5 , HashSHA1 : sha1Fingerprint ("v2toJdKXfFEaR1u++4iq1UqSrHM" )}, true },
160+ {"bad sha1 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 | git2go .HostkeyMD5 , HashSHA1 : sha1Fingerprint ("tfpLlQhDDFP3yGdewTvHNxWmAdk" )}, false },
161+ {"good md5 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeyMD5 , HashMD5 : md5Fingerprint ("\x16 \x27 \xac \xa5 \x76 \x28 \x2d \x36 \x63 \x1b \x56 \x4d \xeb \xdf \xa6 \x48 " )}, true },
162+ {"bad md5 hostkey" , git2go.HostkeyCertificate {Kind : git2go .HostkeyMD5 , HashMD5 : md5Fingerprint ("\xb6 \x03 \x0e \x39 \x97 \x9e \xd0 \xe7 \x24 \xce \xa3 \x77 \x3e \x01 \x42 \x09 " )}, false },
160163 {"invalid hostkey" , git2go.HostkeyCertificate {}, false },
161164 }
162165 for _ , tt := range tests {
@@ -176,6 +179,12 @@ func TestKnownKeyHash(t *testing.T) {
176179 }
177180}
178181
182+ func md5Fingerprint (in string ) [16 ]byte {
183+ var out [16 ]byte
184+ copy (out [:], []byte (in ))
185+ return out
186+ }
187+
179188func sha1Fingerprint (in string ) [20 ]byte {
180189 d , err := base64 .RawStdEncoding .DecodeString (in )
181190 if err != nil {
0 commit comments