mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 04:06:18 +08:00
typo
This commit is contained in:
parent
78e22c4df2
commit
a7921d9513
16
sm2/sm2.go
16
sm2/sm2.go
@ -55,29 +55,29 @@ const (
|
|||||||
MarshalMixed
|
MarshalMixed
|
||||||
)
|
)
|
||||||
|
|
||||||
type cipherTextSplicingOrder byte
|
type ciphertextSplicingOrder byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
C1C3C2 cipherTextSplicingOrder = iota
|
C1C3C2 ciphertextSplicingOrder = iota
|
||||||
C1C2C3
|
C1C2C3
|
||||||
)
|
)
|
||||||
|
|
||||||
// EncrypterOpts encryption options
|
// EncrypterOpts encryption options
|
||||||
type EncrypterOpts struct {
|
type EncrypterOpts struct {
|
||||||
PointMarshalMode pointMarshalMode
|
PointMarshalMode pointMarshalMode
|
||||||
CipherTextSplicingOrder cipherTextSplicingOrder
|
CiphertextSplicingOrder ciphertextSplicingOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecrypterOpts decryption options
|
// DecrypterOpts decryption options
|
||||||
type DecrypterOpts struct {
|
type DecrypterOpts struct {
|
||||||
CipherTextSplicingOrder cipherTextSplicingOrder
|
CipherTextSplicingOrder ciphertextSplicingOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEncrypterOpts(marhsalMode pointMarshalMode, splicingOrder cipherTextSplicingOrder) *EncrypterOpts {
|
func NewEncrypterOpts(marhsalMode pointMarshalMode, splicingOrder ciphertextSplicingOrder) *EncrypterOpts {
|
||||||
return &EncrypterOpts{marhsalMode, splicingOrder}
|
return &EncrypterOpts{marhsalMode, splicingOrder}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDecrypterOpts(splicingOrder cipherTextSplicingOrder) *DecrypterOpts {
|
func NewDecrypterOpts(splicingOrder ciphertextSplicingOrder) *DecrypterOpts {
|
||||||
return &DecrypterOpts{splicingOrder}
|
return &DecrypterOpts{splicingOrder}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ func Encrypt(random io.Reader, pub *ecdsa.PublicKey, msg []byte, opts *Encrypter
|
|||||||
//A7, C3 = hash(x2||M||y2)
|
//A7, C3 = hash(x2||M||y2)
|
||||||
c3 := calculateC3(curve, x2, y2, msg)
|
c3 := calculateC3(curve, x2, y2, msg)
|
||||||
|
|
||||||
if opts.CipherTextSplicingOrder == C1C3C2 {
|
if opts.CiphertextSplicingOrder == C1C3C2 {
|
||||||
// c1 || c3 || c2
|
// c1 || c3 || c2
|
||||||
return append(append(c1, c3...), c2...), nil
|
return append(append(c1, c3...), c2...), nil
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ func decrypt(priv *PrivateKey, ciphertext []byte, opts *DecrypterOpts) ([]byte,
|
|||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AdjustCipherTextSplicingOrder(ciphertext []byte, from, to cipherTextSplicingOrder) ([]byte, error) {
|
func AdjustCipherTextSplicingOrder(ciphertext []byte, from, to ciphertextSplicingOrder) ([]byte, error) {
|
||||||
curve := P256()
|
curve := P256()
|
||||||
if from == to {
|
if from == to {
|
||||||
return ciphertext, nil
|
return ciphertext, nil
|
||||||
|
@ -35,8 +35,8 @@ func Test_SplicingOrder(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
plainText string
|
plainText string
|
||||||
from cipherTextSplicingOrder
|
from ciphertextSplicingOrder
|
||||||
to cipherTextSplicingOrder
|
to ciphertextSplicingOrder
|
||||||
}{
|
}{
|
||||||
// TODO: Add test cases.
|
// TODO: Add test cases.
|
||||||
{"less than 32 1", "encryption standard", C1C2C3, C1C3C2},
|
{"less than 32 1", "encryption standard", C1C2C3, C1C3C2},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user