Rename to chacha20_
This commit is contained in:
parent
65a1763097
commit
f8e17de9da
6
nip44.go
6
nip44.go
@ -59,7 +59,7 @@ func Encrypt(key []byte, plaintext string, options *EncryptOptions) (string, err
|
|||||||
if padded, err = pad(plaintext); err != nil {
|
if padded, err = pad(plaintext); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if ciphertext, err = chacha20Encrypt(enc, nonce, []byte(padded)); err != nil {
|
if ciphertext, err = chacha20_(enc, nonce, []byte(padded)); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
hmac_ = sha256Hmac(auth, ciphertext)
|
hmac_ = sha256Hmac(auth, ciphertext)
|
||||||
@ -103,7 +103,7 @@ func Decrypt(key []byte, ciphertext string) (string, error) {
|
|||||||
if !bytes.Equal(hmac_, sha256Hmac(auth, ciphertext_)) {
|
if !bytes.Equal(hmac_, sha256Hmac(auth, ciphertext_)) {
|
||||||
return "", errors.New("invalid hmac")
|
return "", errors.New("invalid hmac")
|
||||||
}
|
}
|
||||||
if padded, err = chacha20Encrypt(enc, nonce, ciphertext_); err != nil {
|
if padded, err = chacha20_(enc, nonce, ciphertext_); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
unpaddedLen = binary.BigEndian.Uint16(padded[0:2])
|
unpaddedLen = binary.BigEndian.Uint16(padded[0:2])
|
||||||
@ -114,7 +114,7 @@ func Decrypt(key []byte, ciphertext string) (string, error) {
|
|||||||
return string(unpadded), nil
|
return string(unpadded), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func chacha20Encrypt(key []byte, nonce []byte, message []byte) ([]byte, error) {
|
func chacha20_(key []byte, nonce []byte, message []byte) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
cipher *chacha20.Cipher
|
cipher *chacha20.Cipher
|
||||||
dst = make([]byte, len(message))
|
dst = make([]byte, len(message))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user