Skip to content

Commit

Permalink
fix: removed never use variable
Browse files Browse the repository at this point in the history
Signed-off-by: yakumioto <yaku.mioto@gmail.com>
  • Loading branch information
yakumioto committed May 24, 2024
1 parent 240e55c commit 4c04b2e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 3 additions & 0 deletions chacha20/chacha20.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func (k *KeyImpl[T]) Decrypt(ciphertext T) (plaintext T, err error) {
nonce, ciphertextBytes := encryptedPayload[:k.nonceSize], encryptedPayload[k.nonceSize:]

aead, err := chacha20.NewUnauthenticatedCipher(k.expendKey, nonce)
if err != nil {
return T(""), fmt.Errorf("chacha20: decrypt failed to create cipher: %w", err)
}

plaintextBytes := make([]byte, len(ciphertextBytes))
aead.XORKeyStream(plaintextBytes, ciphertextBytes)
Expand Down
2 changes: 1 addition & 1 deletion ecdsa/ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestKeyImport(t *testing.T) {
pubKeyStr, err := pubKey.Export()
assert.NoErrorf(t, err, "Export failed: %s", err)

pubKey, err = ki.KeyImport(pubKeyStr, tc.algorithm)
_, err = ki.KeyImport(pubKeyStr, tc.algorithm)
assert.NoErrorf(t, err, "KeyImport failed: %s", err)
}
}
8 changes: 1 addition & 7 deletions rsa/rsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,12 @@ func TestUnsupportedMethod(t *testing.T) {
_, err = key.Encrypt("hello world")
assert.EqualError(t, err, ErrUnsupportedMethod.Error(), "Sign failed")

// _, err = key.Decrypt("hello world")
// assert.EqualError(t, err, ErrUnsupportedMethod.Error(), "Verify failed")

_, err = key.Verify("", "")
assert.EqualError(t, err, ErrUnsupportedMethod.Error(), "Verify failed")

pk, err := key.PublicKey()
assert.NoErrorf(t, err, "PublicKey failed: %s", err)

// _, err = pk.Encrypt("hello world")
// assert.EqualError(t, err, ErrUnsupportedMethod.Error(), "Encrypt failed")

_, err = pk.Decrypt("hello world")
assert.EqualError(t, err, ErrUnsupportedMethod.Error(), "Decrypt failed")

Expand Down Expand Up @@ -277,7 +271,7 @@ func TestKeyImport(t *testing.T) {
pubKeyStr, err := pubKey.Export()
assert.NoErrorf(t, err, "Export failed: %s", err)

pubKey, err = ki.KeyImport(pubKeyStr, tc.algorithm)
_, err = ki.KeyImport(pubKeyStr, tc.algorithm)
assert.NoErrorf(t, err, "KeyImport failed: %s", err)
}
}

0 comments on commit 4c04b2e

Please sign in to comment.