Skip to content

Commit

Permalink
修复
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Sep 2, 2024
1 parent e0356c6 commit 11d799c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gm/sm9/encrypt_cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/subtle"

"github.com/deatil/go-cryptobin/cipher/sm4"
cryptobin_cipher "github.com/deatil/go-cryptobin/cipher"
cryptobin_mode "github.com/deatil/go-cryptobin/mode"
)

const(
Expand Down Expand Up @@ -163,7 +163,7 @@ func (this *ECBEncrypt) Encrypt(rand io.Reader, key, plaintext []byte) ([]byte,

ciphertext := make([]byte, len(paddedPlainText))

mode := cryptobin_cipher.NewECBEncrypter(block)
mode := cryptobin_mode.NewECBEncrypter(block)
mode.CryptBlocks(ciphertext, paddedPlainText)

return ciphertext, nil
Expand All @@ -181,7 +181,7 @@ func (this *ECBEncrypt) Decrypt(key, ciphertext []byte) ([]byte, error) {

plaintext := make([]byte, len(ciphertext))

mode := cryptobin_cipher.NewECBDecrypter(block)
mode := cryptobin_mode.NewECBDecrypter(block)
mode.CryptBlocks(plaintext, ciphertext)

plaintext, err = pkcs7UnPadding(plaintext)
Expand Down
2 changes: 1 addition & 1 deletion mode/siv/aes/siv.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/aes"
"crypto/cipher"

"github.com/deatil/go-cryptobin/cipher/siv"
"github.com/deatil/go-cryptobin/mode/siv"
)

var KeySizeErr = errors.New("siv: bad key size")
Expand Down
2 changes: 1 addition & 1 deletion pkcs/pbes2/cipher_ccm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/cipher"
"encoding/asn1"

"github.com/deatil/go-cryptobin/cipher/ccm"
"github.com/deatil/go-cryptobin/mode/ccm"
)

// ccm 模式加密参数
Expand Down
2 changes: 1 addition & 1 deletion pkcs/pbes2/cipher_ccm_iv.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/cipher"
"encoding/asn1"

"github.com/deatil/go-cryptobin/cipher/ccm"
"github.com/deatil/go-cryptobin/mode/ccm"
)

// ccm 模式加密参数
Expand Down
6 changes: 3 additions & 3 deletions pkcs/pbes2/cipher_cfb1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/cipher"
"encoding/asn1"

cryptobin_cipher "github.com/deatil/go-cryptobin/cipher"
cryptobin_mode "github.com/deatil/go-cryptobin/mode"
)

// CFB1 模式加密参数
Expand Down Expand Up @@ -58,7 +58,7 @@ func (this CipherCFB1) Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, [
// 需要保存的加密数据
encrypted := make([]byte, len(plaintext))

enc := cryptobin_cipher.NewCFB1Encrypter(block, iv)
enc := cryptobin_mode.NewCFB1Encrypter(block, iv)
enc.XORKeyStream(encrypted, plaintext)

// 编码 iv
Expand Down Expand Up @@ -89,7 +89,7 @@ func (this CipherCFB1) Decrypt(key, params, ciphertext []byte) ([]byte, error) {

plaintext := make([]byte, len(ciphertext))

mode := cryptobin_cipher.NewCFB1Decrypter(block, iv)
mode := cryptobin_mode.NewCFB1Decrypter(block, iv)
mode.XORKeyStream(plaintext, ciphertext)

return plaintext, nil
Expand Down
6 changes: 3 additions & 3 deletions pkcs/pbes2/cipher_cfb8.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/cipher"
"encoding/asn1"

cryptobin_cipher "github.com/deatil/go-cryptobin/cipher"
cryptobin_mode "github.com/deatil/go-cryptobin/mode"
)

// CFB8 模式加密参数
Expand Down Expand Up @@ -58,7 +58,7 @@ func (this CipherCFB8) Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, [
// 需要保存的加密数据
encrypted := make([]byte, len(plaintext))

enc := cryptobin_cipher.NewCFB8Encrypter(block, iv)
enc := cryptobin_mode.NewCFB8Encrypter(block, iv)
enc.XORKeyStream(encrypted, plaintext)

// 编码 iv
Expand Down Expand Up @@ -89,7 +89,7 @@ func (this CipherCFB8) Decrypt(key, params, ciphertext []byte) ([]byte, error) {

plaintext := make([]byte, len(ciphertext))

mode := cryptobin_cipher.NewCFB8Decrypter(block, iv)
mode := cryptobin_mode.NewCFB8Decrypter(block, iv)
mode.XORKeyStream(plaintext, ciphertext)

return plaintext, nil
Expand Down
6 changes: 3 additions & 3 deletions pkcs/pbes2/cipher_ecb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/cipher"
"encoding/asn1"

cryptobin_cipher "github.com/deatil/go-cryptobin/cipher"
cryptobin_mode "github.com/deatil/go-cryptobin/mode"
)

// ecb 模式加密
Expand Down Expand Up @@ -52,7 +52,7 @@ func (this CipherECB) Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, []
// 需要保存的加密数据
encrypted := make([]byte, len(plaintext))

mode := cryptobin_cipher.NewECBEncrypter(block)
mode := cryptobin_mode.NewECBEncrypter(block)
mode.CryptBlocks(encrypted, plaintext)

// 返回数据
Expand All @@ -76,7 +76,7 @@ func (this CipherECB) Decrypt(key, params, ciphertext []byte) ([]byte, error) {

plaintext := make([]byte, len(ciphertext))

mode := cryptobin_cipher.NewECBDecrypter(block)
mode := cryptobin_mode.NewECBDecrypter(block)
mode.CryptBlocks(plaintext, ciphertext)

// 判断数据是否为填充数据
Expand Down

0 comments on commit 11d799c

Please sign in to comment.