11package ecdsa
22
33import (
4+ "encoding/asn1"
45 "crypto/ecdsa"
56 "crypto/elliptic"
67
78 "github.com/deatil/go-cryptobin/tool/hash"
9+ pubkey_ecdsa "github.com/deatil/go-cryptobin/pubkey/ecdsa"
810)
911
10- // 设置 PrivateKey
12+ // Add Named Curve
13+ func (this ECDSA ) AddNamedCurve (curve elliptic.Curve , oid asn1.ObjectIdentifier ) ECDSA {
14+ pubkey_ecdsa .AddNamedCurve (curve , oid )
15+ return this
16+ }
17+
18+ // Add Named Curve
19+ func AddNamedCurve (curve elliptic.Curve , oid asn1.ObjectIdentifier ) ECDSA {
20+ return defaultECDSA .AddNamedCurve (curve , oid )
21+ }
22+
23+ // With PrivateKey
1124func (this ECDSA ) WithPrivateKey (data * ecdsa.PrivateKey ) ECDSA {
1225 this .privateKey = data
1326
1427 return this
1528}
1629
17- // 设置 PublicKey
30+ // With PublicKey
1831func (this ECDSA ) WithPublicKey (data * ecdsa.PublicKey ) ECDSA {
1932 this .publicKey = data
2033
2134 return this
2235}
2336
24- // 设置曲线类型
37+ // With curve
2538func (this ECDSA ) WithCurve (curve elliptic.Curve ) ECDSA {
2639 this .curve = curve
2740
2841 return this
2942}
3043
31- // 设置曲线类型
32- // 可选参数 [P521 | P384 | P256 | P224]
44+ // set curve
45+ // params [P521 | P384 | P256 | P224]
3346func (this ECDSA ) SetCurve (curve string ) ECDSA {
3447 switch curve {
3548 case "P521" :
@@ -45,14 +58,14 @@ func (this ECDSA) SetCurve(curve string) ECDSA {
4558 return this
4659}
4760
48- // 设置 hash 类型
61+ // With hash type
4962func (this ECDSA ) WithSignHash (hash HashFunc ) ECDSA {
5063 this .signHash = hash
5164
5265 return this
5366}
5467
55- // 设置 hash 类型
68+ // With hash type
5669func (this ECDSA ) SetSignHash (name string ) ECDSA {
5770 h , err := hash .GetHash (name )
5871 if err != nil {
@@ -64,45 +77,45 @@ func (this ECDSA) SetSignHash(name string) ECDSA {
6477 return this
6578}
6679
67- // 设置 data
80+ // With data
6881func (this ECDSA ) WithData (data []byte ) ECDSA {
6982 this .data = data
7083
7184 return this
7285}
7386
74- // 设置 parsedData
87+ // With parsedData
7588func (this ECDSA ) WithParsedData (data []byte ) ECDSA {
7689 this .parsedData = data
7790
7891 return this
7992}
8093
81- // 设置编码方式
94+ // With encoding
8295func (this ECDSA ) WithEncoding (encoding EncodingType ) ECDSA {
8396 this .encoding = encoding
8497
8598 return this
8699}
87100
88- // 设置 ASN1 编码方式
101+ // encoding ASN1 encoding type
89102func (this ECDSA ) WithEncodingASN1 () ECDSA {
90103 return this .WithEncoding (EncodingASN1 )
91104}
92105
93- // 设置明文编码方式
106+ // encoding Bytes encoding type
94107func (this ECDSA ) WithEncodingBytes () ECDSA {
95108 return this .WithEncoding (EncodingBytes )
96109}
97110
98- // 设置验证结果
111+ // WithVerify
99112func (this ECDSA ) WithVerify (data bool ) ECDSA {
100113 this .verify = data
101114
102115 return this
103116}
104117
105- // 设置错误
118+ // WithErrors
106119func (this ECDSA ) WithErrors (errs []error ) ECDSA {
107120 this .Errors = errs
108121
0 commit comments