@@ -29,31 +29,31 @@ func TestKnownHostsCallback(t *testing.T) {
29
29
name : "Match" ,
30
30
host : "github.com" ,
31
31
knownHosts : []byte (knownHostsFixture ),
32
- hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 | git2go . HostkeyMD5 , HashSHA1 : sha1Fingerprint ( "v2toJdKXfFEaR1u++4iq1UqSrHM " )},
32
+ hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ( "nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 " )},
33
33
expectedHost : "github.com" ,
34
34
want : nil ,
35
35
},
36
36
{
37
37
name : "Match with port" ,
38
38
host : "github.com" ,
39
39
knownHosts : []byte (knownHostsFixture ),
40
- hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 | git2go . HostkeyMD5 , HashSHA1 : sha1Fingerprint ( "v2toJdKXfFEaR1u++4iq1UqSrHM " )},
40
+ hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ( "nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 " )},
41
41
expectedHost : "github.com:22" ,
42
42
want : nil ,
43
43
},
44
44
{
45
45
name : "Hostname mismatch" ,
46
46
host : "github.com" ,
47
47
knownHosts : []byte (knownHostsFixture ),
48
- hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA1 | git2go . HostkeyMD5 , HashSHA1 : sha1Fingerprint ( "v2toJdKXfFEaR1u++4iq1UqSrHM " )},
48
+ hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ( "nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 " )},
49
49
expectedHost : "example.com" ,
50
50
want : fmt .Errorf ("host mismatch: %q %q" , "example.com" , "github.com" ),
51
51
},
52
52
{
53
53
name : "Hostkey mismatch" ,
54
54
host : "github.com" ,
55
55
knownHosts : []byte (knownHostsFixture ),
56
- hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeyMD5 , HashMD5 : md5Fingerprint ( " \xb6 \x03 \x0e \x39 \x97 \x9e \xd0 \xe7 \x24 \xce \xa3 \x77 \x3e \x01 \x42 \x09 " )},
56
+ hostkey : git2go.HostkeyCertificate {Kind : git2go .HostkeySHA256 , HashSHA256 : sha256Fingerprint ( "ROQFvPThGrW4RuWLoL9tq9I9zJ42fK4XywyRtbOz/EQ " )},
57
57
expectedHost : "github.com" ,
58
58
want : fmt .Errorf ("hostkey could not be verified" ),
59
59
},
@@ -73,21 +73,6 @@ func TestKnownHostsCallback(t *testing.T) {
73
73
})
74
74
}
75
75
}
76
- func md5Fingerprint (in string ) [16 ]byte {
77
- var out [16 ]byte
78
- copy (out [:], in )
79
- return out
80
- }
81
-
82
- func sha1Fingerprint (in string ) [20 ]byte {
83
- d , err := base64 .RawStdEncoding .DecodeString (in )
84
- if err != nil {
85
- panic (err )
86
- }
87
- var out [20 ]byte
88
- copy (out [:], d )
89
- return out
90
- }
91
76
92
77
func sha256Fingerprint (in string ) [32 ]byte {
93
78
d , err := base64 .RawStdEncoding .DecodeString (in )
0 commit comments