Update go-crypto
This commit is contained in:
parent
1791c07702
commit
a065bf20b0
8 changed files with 33 additions and 20 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package crypto
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"crypto/rsa"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
|
|
@ -9,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp/ecdh"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/eddsa"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -63,8 +63,8 @@ func assertRSACleared(t *testing.T, rsaPriv *rsa.PrivateKey) {
|
|||
}
|
||||
}
|
||||
|
||||
func assertEdDSACleared(t *testing.T, priv *ed25519.PrivateKey) {
|
||||
assertMemCleared(t, *priv)
|
||||
func assertEdDSACleared(t *testing.T, priv *eddsa.PrivateKey) {
|
||||
assertMemCleared(t, priv.D)
|
||||
}
|
||||
|
||||
func assertECDHCleared(t *testing.T, priv *ecdh.PrivateKey) {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ package crypto
|
|||
|
||||
import (
|
||||
"crypto/dsa" //nolint:staticcheck
|
||||
"crypto/ecdsa"
|
||||
"crypto/ed25519"
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp/ecdh"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/ecdsa"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/eddsa"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/elgamal"
|
||||
)
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ func clearPrivateKey(privateKey interface{}) error {
|
|||
return clearElGamalPrivateKey(priv)
|
||||
case *ecdsa.PrivateKey:
|
||||
return clearECDSAPrivateKey(priv)
|
||||
case *ed25519.PrivateKey:
|
||||
case *eddsa.PrivateKey:
|
||||
return clearEdDSAPrivateKey(priv)
|
||||
case *ecdh.PrivateKey:
|
||||
return clearECDHPrivateKey(priv)
|
||||
|
|
@ -115,8 +115,8 @@ func clearECDSAPrivateKey(priv *ecdsa.PrivateKey) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func clearEdDSAPrivateKey(priv *ed25519.PrivateKey) error {
|
||||
clearMem(*priv)
|
||||
func clearEdDSAPrivateKey(priv *eddsa.PrivateKey) error {
|
||||
clearMem(priv.D)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package crypto
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
"testing"
|
||||
|
|
@ -9,6 +8,8 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp/ecdh"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/eddsa"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/v2/constants"
|
||||
)
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ func TestClearPrivateKey(t *testing.T) {
|
|||
|
||||
keys := keyRingCopy.GetKeys()
|
||||
assertRSACleared(t, keys[0].entity.PrivateKey.PrivateKey.(*rsa.PrivateKey))
|
||||
assertEdDSACleared(t, keys[1].entity.PrivateKey.PrivateKey.(*ed25519.PrivateKey))
|
||||
assertEdDSACleared(t, keys[1].entity.PrivateKey.PrivateKey.(*eddsa.PrivateKey))
|
||||
assertRSACleared(t, keys[2].entity.PrivateKey.PrivateKey.(*rsa.PrivateKey))
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +178,7 @@ func TestClearPrivateWithSubkeys(t *testing.T) {
|
|||
assertRSACleared(t, keys[0].entity.PrivateKey.PrivateKey.(*rsa.PrivateKey))
|
||||
assertRSACleared(t, keys[0].entity.Subkeys[0].PrivateKey.PrivateKey.(*rsa.PrivateKey))
|
||||
|
||||
assertEdDSACleared(t, keys[1].entity.PrivateKey.PrivateKey.(*ed25519.PrivateKey))
|
||||
assertEdDSACleared(t, keys[1].entity.PrivateKey.PrivateKey.(*eddsa.PrivateKey))
|
||||
assertECDHCleared(t, keys[1].entity.Subkeys[0].PrivateKey.PrivateKey.(*ecdh.PrivateKey))
|
||||
|
||||
assertRSACleared(t, keys[2].entity.PrivateKey.PrivateKey.(*rsa.PrivateKey))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue