1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func init() {
addTestCases(hmacNewTests, hmacnew)
}
var hmacNewTests = []testCase{
{
Name: "hmacnew.0",
In: `package main
import "crypto/hmac"
var f = hmac.NewSHA1([]byte("some key"))
`,
Out: `package main
import (
"crypto/hmac"
"crypto/sha1"
)
var f = hmac.New(sha1.New, []byte("some key"))
`,
},
{
Name: "hmacnew.1",
In: `package main
import "crypto/hmac"
var key = make([]byte, 8)
var f = hmac.NewSHA1(key)
`,
Out: `package main
import (
"crypto/hmac"
"crypto/sha1"
)
var key = make([]byte, 8)
var f = hmac.New(sha1.New, key)
`,
},
{
Name: "hmacnew.2",
In: `package main
import "crypto/hmac"
var f = hmac.NewMD5([]byte("some key"))
`,
Out: `package main
import (
"crypto/hmac"
"crypto/md5"
)
var f = hmac.New(md5.New, []byte("some key"))
`,
},
{
Name: "hmacnew.3",
In: `package main
import "crypto/hmac"
var f = hmac.NewSHA256([]byte("some key"))
`,
Out: `package main
import (
"crypto/hmac"
"crypto/sha256"
)
var f = hmac.New(sha256.New, []byte("some key"))
`,
},
{
Name: "hmacnew.4",
In: `package main
import (
"crypto/hmac"
"crypto/sha1"
)
var f = hmac.New(sha1.New, []byte("some key"))
`,
Out: `package main
import (
"crypto/hmac"
"crypto/sha1"
)
var f = hmac.New(sha1.New, []byte("some key"))
`,
},
}
|