mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 04:36:19 +08:00
Reduce function parameter
This commit is contained in:
parent
6e3f8e5d1c
commit
78e22c4df2
@ -369,15 +369,15 @@ func decrypt(priv *PrivateKey, ciphertext []byte, opts *DecrypterOpts) ([]byte,
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func AdjustCipherTextSplicingOrder(pub *ecdsa.PublicKey, ciphertext []byte, from, to cipherTextSplicingOrder) ([]byte, error) {
|
||||
func AdjustCipherTextSplicingOrder(ciphertext []byte, from, to cipherTextSplicingOrder) ([]byte, error) {
|
||||
curve := P256()
|
||||
if from == to {
|
||||
return ciphertext, nil
|
||||
}
|
||||
ciphertextLen := len(ciphertext)
|
||||
if ciphertextLen <= 1+(pub.Params().BitSize/8)+sm3.Size {
|
||||
if ciphertextLen <= 1+(curve.Params().BitSize/8)+sm3.Size {
|
||||
return nil, errors.New("SM2: invalid ciphertext length")
|
||||
}
|
||||
curve := pub.Curve
|
||||
|
||||
// get C1, and check C1
|
||||
_, _, c3Start, err := bytes2Point(curve, ciphertext)
|
||||
|
@ -61,7 +61,7 @@ func Test_SplicingOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
//Adjust splicing order
|
||||
ciphertext, err = AdjustCipherTextSplicingOrder(&priv.PublicKey, ciphertext, tt.from, tt.to)
|
||||
ciphertext, err = AdjustCipherTextSplicingOrder(ciphertext, tt.from, tt.to)
|
||||
if err != nil {
|
||||
t.Fatalf("adjust splicing order failed %v", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user