Skip to content

Commit a4f5149

Browse files
committed
fixed s256
1 parent 69c5d98 commit a4f5149

File tree

192 files changed

+4430
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+4430
-851
lines changed

cryptobin/bign/create.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (this Bign) CreatePrivateKeyWithPassword(password string, opts ...string) B
4646
// 生成私钥 pem 数据
4747
func (this Bign) CreatePKCS1PrivateKey() Bign {
4848
if this.privateKey == nil {
49-
err := errors.New("privateKey empty.")
49+
err := errors.New("go-cryptobin/bign: privateKey empty.")
5050
return this.AppendError(err)
5151
}
5252

@@ -68,7 +68,7 @@ func (this Bign) CreatePKCS1PrivateKey() Bign {
6868
// 生成私钥带密码 pem 数据
6969
func (this Bign) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) Bign {
7070
if this.privateKey == nil {
71-
err := errors.New("privateKey empty.")
71+
err := errors.New("go-cryptobin/bign: privateKey empty.")
7272
return this.AppendError(err)
7373
}
7474

@@ -80,7 +80,7 @@ func (this Bign) CreatePKCS1PrivateKeyWithPassword(password string, opts ...stri
8080
// 加密方式
8181
cipher := pkcs1.GetPEMCipher(opt)
8282
if cipher == nil {
83-
err := errors.New("PEMCipher not exists.")
83+
err := errors.New("go-cryptobin/bign: PEMCipher not exists.")
8484
return this.AppendError(err)
8585
}
8686

@@ -112,7 +112,7 @@ func (this Bign) CreatePKCS1PrivateKeyWithPassword(password string, opts ...stri
112112
// 生成 PKCS8 私钥 pem 数据
113113
func (this Bign) CreatePKCS8PrivateKey() Bign {
114114
if this.privateKey == nil {
115-
err := errors.New("privateKey empty.")
115+
err := errors.New("go-cryptobin/bign: privateKey empty.")
116116
return this.AppendError(err)
117117
}
118118

@@ -135,7 +135,7 @@ func (this Bign) CreatePKCS8PrivateKey() Bign {
135135
// CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
136136
func (this Bign) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) Bign {
137137
if this.privateKey == nil {
138-
err := errors.New("privateKey empty.")
138+
err := errors.New("go-cryptobin/bign: privateKey empty.")
139139
return this.AppendError(err)
140140
}
141141

@@ -172,7 +172,7 @@ func (this Bign) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any)
172172
// 生成公钥 pem 数据
173173
func (this Bign) CreatePublicKey() Bign {
174174
if this.publicKey == nil {
175-
err := errors.New("publicKey empty.")
175+
err := errors.New("go-cryptobin/bign: publicKey empty.")
176176
return this.AppendError(err)
177177
}
178178

cryptobin/bign/from.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (this Bign) FromPublicKeyUncompressString(key string) Bign {
269269

270270
x, y := elliptic.Unmarshal(this.curve, k)
271271
if x == nil || y == nil {
272-
err := errors.New("publicKey uncompress string error")
272+
err := errors.New("go-cryptobin/bign: publicKey uncompress string error")
273273

274274
return this.AppendError(err)
275275
}
@@ -291,7 +291,7 @@ func (this Bign) FromPublicKeyCompressString(key string) Bign {
291291

292292
x, y := elliptic.UnmarshalCompressed(this.curve, k)
293293
if x == nil || y == nil {
294-
err := errors.New("publicKey compress string error")
294+
err := errors.New("go-cryptobin/bign: publicKey compress string error")
295295

296296
return this.AppendError(err)
297297
}

cryptobin/bign/make.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (this Bign) MakePublicKey() Bign {
1010
this.publicKey = nil
1111

1212
if this.privateKey == nil {
13-
err := errors.New("privateKey empty.")
13+
err := errors.New("go-cryptobin/bign: privateKey empty.")
1414
return this.AppendError(err)
1515
}
1616

@@ -23,7 +23,7 @@ func (this Bign) MakePublicKey() Bign {
2323
func (this Bign) MakeKeyDer() Bign {
2424
var block *pem.Block
2525
if block, _ = pem.Decode(this.keyData); block == nil {
26-
err := errors.New("keyData error.")
26+
err := errors.New("go-cryptobin/bign: keyData error.")
2727
return this.AppendError(err)
2828
}
2929

cryptobin/bign/parse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
var (
14-
ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
15-
ErrNotECPublicKey = errors.New("key is not a valid Bign public key")
14+
ErrKeyMustBePEMEncoded = errors.New("go-cryptobin/bign: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
15+
ErrNotECPublicKey = errors.New("go-cryptobin/bign: key is not a valid Bign public key")
1616
)
1717

1818
// 解析私钥

cryptobin/bign/sign.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func (this Bign) Verify(data []byte) Bign {
3737
// 私钥签名 ASN1
3838
func (this Bign) SignASN1() Bign {
3939
if this.privateKey == nil {
40-
err := errors.New("privateKey empty.")
40+
err := errors.New("go-cryptobin/bign: privateKey empty.")
4141
return this.AppendError(err)
4242
}
4343

4444
if this.signHash == nil {
45-
err := errors.New("Hash func not set.")
45+
err := errors.New("go-cryptobin/bign: Hash func not set.")
4646
return this.AppendError(err)
4747
}
4848

@@ -61,12 +61,12 @@ func (this Bign) SignASN1() Bign {
6161
// 使用原始数据[data]对比签名后数据
6262
func (this Bign) VerifyASN1(data []byte) Bign {
6363
if this.publicKey == nil {
64-
err := errors.New("publicKey empty.")
64+
err := errors.New("go-cryptobin/bign: publicKey empty.")
6565
return this.AppendError(err)
6666
}
6767

6868
if this.signHash == nil {
69-
err := errors.New("Hash func not set.")
69+
err := errors.New("go-cryptobin/bign: Hash func not set.")
7070
return this.AppendError(err)
7171
}
7272

@@ -81,12 +81,12 @@ func (this Bign) VerifyASN1(data []byte) Bign {
8181
// 私钥签名 Bytes
8282
func (this Bign) SignBytes() Bign {
8383
if this.privateKey == nil {
84-
err := errors.New("privateKey empty.")
84+
err := errors.New("go-cryptobin/bign: privateKey empty.")
8585
return this.AppendError(err)
8686
}
8787

8888
if this.signHash == nil {
89-
err := errors.New("Hash func not set.")
89+
err := errors.New("go-cryptobin/bign: Hash func not set.")
9090
return this.AppendError(err)
9191
}
9292

@@ -104,12 +104,12 @@ func (this Bign) SignBytes() Bign {
104104
// 使用原始数据[data]对比签名后数据
105105
func (this Bign) VerifyBytes(data []byte) Bign {
106106
if this.publicKey == nil {
107-
err := errors.New("publicKey empty.")
107+
err := errors.New("go-cryptobin/bign: publicKey empty.")
108108
return this.AppendError(err)
109109
}
110110

111111
if this.signHash == nil {
112-
err := errors.New("Hash func not set.")
112+
err := errors.New("go-cryptobin/bign: Hash func not set.")
113113
return this.AppendError(err)
114114
}
115115

cryptobin/bip0340/create.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (this BIP0340) CreatePrivateKeyWithPassword(password string, opts ...string
4646
// 生成私钥 pem 数据
4747
func (this BIP0340) CreatePKCS1PrivateKey() BIP0340 {
4848
if this.privateKey == nil {
49-
err := errors.New("privateKey empty.")
49+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
5050
return this.AppendError(err)
5151
}
5252

@@ -68,7 +68,7 @@ func (this BIP0340) CreatePKCS1PrivateKey() BIP0340 {
6868
// 生成私钥带密码 pem 数据
6969
func (this BIP0340) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) BIP0340 {
7070
if this.privateKey == nil {
71-
err := errors.New("privateKey empty.")
71+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
7272
return this.AppendError(err)
7373
}
7474

@@ -80,7 +80,7 @@ func (this BIP0340) CreatePKCS1PrivateKeyWithPassword(password string, opts ...s
8080
// 加密方式
8181
cipher := pkcs1.GetPEMCipher(opt)
8282
if cipher == nil {
83-
err := errors.New("PEMCipher not exists.")
83+
err := errors.New("go-cryptobin/bip0340: PEMCipher not exists.")
8484
return this.AppendError(err)
8585
}
8686

@@ -112,7 +112,7 @@ func (this BIP0340) CreatePKCS1PrivateKeyWithPassword(password string, opts ...s
112112
// 生成 PKCS8 私钥 pem 数据
113113
func (this BIP0340) CreatePKCS8PrivateKey() BIP0340 {
114114
if this.privateKey == nil {
115-
err := errors.New("privateKey empty.")
115+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
116116
return this.AppendError(err)
117117
}
118118

@@ -135,7 +135,7 @@ func (this BIP0340) CreatePKCS8PrivateKey() BIP0340 {
135135
// CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
136136
func (this BIP0340) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) BIP0340 {
137137
if this.privateKey == nil {
138-
err := errors.New("privateKey empty.")
138+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
139139
return this.AppendError(err)
140140
}
141141

@@ -172,7 +172,7 @@ func (this BIP0340) CreatePKCS8PrivateKeyWithPassword(password string, opts ...a
172172
// 生成公钥 pem 数据
173173
func (this BIP0340) CreatePublicKey() BIP0340 {
174174
if this.publicKey == nil {
175-
err := errors.New("publicKey empty.")
175+
err := errors.New("go-cryptobin/bip0340: publicKey empty.")
176176
return this.AppendError(err)
177177
}
178178

cryptobin/bip0340/from.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (this BIP0340) FromPublicKeyUncompressString(key string) BIP0340 {
269269

270270
x, y := elliptic.Unmarshal(this.curve, k)
271271
if x == nil || y == nil {
272-
err := errors.New("publicKey uncompress string error")
272+
err := errors.New("go-cryptobin/bip0340: publicKey uncompress string error")
273273

274274
return this.AppendError(err)
275275
}
@@ -291,7 +291,7 @@ func (this BIP0340) FromPublicKeyCompressString(key string) BIP0340 {
291291

292292
x, y := elliptic.UnmarshalCompressed(this.curve, k)
293293
if x == nil || y == nil {
294-
err := errors.New("publicKey compress string error")
294+
err := errors.New("go-cryptobin/bip0340: publicKey compress string error")
295295

296296
return this.AppendError(err)
297297
}

cryptobin/bip0340/make.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (this BIP0340) MakePublicKey() BIP0340 {
1010
this.publicKey = nil
1111

1212
if this.privateKey == nil {
13-
err := errors.New("privateKey empty.")
13+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
1414
return this.AppendError(err)
1515
}
1616

@@ -23,7 +23,7 @@ func (this BIP0340) MakePublicKey() BIP0340 {
2323
func (this BIP0340) MakeKeyDer() BIP0340 {
2424
var block *pem.Block
2525
if block, _ = pem.Decode(this.keyData); block == nil {
26-
err := errors.New("keyData error.")
26+
err := errors.New("go-cryptobin/bip0340: keyData error.")
2727
return this.AppendError(err)
2828
}
2929

cryptobin/bip0340/parse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
)
1212

1313
var (
14-
ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
15-
ErrNotECPublicKey = errors.New("key is not a valid BIP0340 public key")
16-
ErrNotECPrivateKey = errors.New("key is not a valid BIP0340 private key")
14+
ErrKeyMustBePEMEncoded = errors.New("go-cryptobin/bip0340: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
15+
ErrNotECPublicKey = errors.New("go-cryptobin/bip0340: key is not a valid BIP0340 public key")
16+
ErrNotECPrivateKey = errors.New("go-cryptobin/bip0340: key is not a valid BIP0340 private key")
1717
)
1818

1919
// 解析私钥

cryptobin/bip0340/sign.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func (this BIP0340) Verify(data []byte) BIP0340 {
3737
// 私钥签名 ASN1
3838
func (this BIP0340) SignASN1() BIP0340 {
3939
if this.privateKey == nil {
40-
err := errors.New("privateKey empty.")
40+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
4141
return this.AppendError(err)
4242
}
4343

4444
if this.signHash == nil {
45-
err := errors.New("Hash func not set.")
45+
err := errors.New("go-cryptobin/bip0340: Hash func not set.")
4646
return this.AppendError(err)
4747
}
4848

@@ -61,12 +61,12 @@ func (this BIP0340) SignASN1() BIP0340 {
6161
// 使用原始数据[data]对比签名后数据
6262
func (this BIP0340) VerifyASN1(data []byte) BIP0340 {
6363
if this.publicKey == nil {
64-
err := errors.New("publicKey empty.")
64+
err := errors.New("go-cryptobin/bip0340: publicKey empty.")
6565
return this.AppendError(err)
6666
}
6767

6868
if this.signHash == nil {
69-
err := errors.New("Hash func not set.")
69+
err := errors.New("go-cryptobin/bip0340: Hash func not set.")
7070
return this.AppendError(err)
7171
}
7272

@@ -81,12 +81,12 @@ func (this BIP0340) VerifyASN1(data []byte) BIP0340 {
8181
// 私钥签名 Bytes
8282
func (this BIP0340) SignBytes() BIP0340 {
8383
if this.privateKey == nil {
84-
err := errors.New("privateKey empty.")
84+
err := errors.New("go-cryptobin/bip0340: privateKey empty.")
8585
return this.AppendError(err)
8686
}
8787

8888
if this.signHash == nil {
89-
err := errors.New("Hash func not set.")
89+
err := errors.New("go-cryptobin/bip0340: Hash func not set.")
9090
return this.AppendError(err)
9191
}
9292

@@ -104,12 +104,12 @@ func (this BIP0340) SignBytes() BIP0340 {
104104
// 使用原始数据[data]对比签名后数据
105105
func (this BIP0340) VerifyBytes(data []byte) BIP0340 {
106106
if this.publicKey == nil {
107-
err := errors.New("publicKey empty.")
107+
err := errors.New("go-cryptobin/bip0340: publicKey empty.")
108108
return this.AppendError(err)
109109
}
110110

111111
if this.signHash == nil {
112-
err := errors.New("Hash func not set.")
112+
err := errors.New("go-cryptobin/bip0340: Hash func not set.")
113113
return this.AppendError(err)
114114
}
115115

0 commit comments

Comments
 (0)