@@ -19,10 +19,10 @@ import (
1919 "github.com/ProtonMail/go-crypto/openpgp/eddsa"
2020 "github.com/ProtonMail/go-crypto/openpgp/elgamal"
2121 "github.com/ProtonMail/go-crypto/openpgp/errors"
22- "github.com/ProtonMail/go-crypto/openpgp/symmetric"
2322 "github.com/ProtonMail/go-crypto/openpgp/internal/algorithm"
2423 "github.com/ProtonMail/go-crypto/openpgp/packet"
2524 "github.com/ProtonMail/go-crypto/openpgp/s2k"
25+ "github.com/ProtonMail/go-crypto/openpgp/symmetric"
2626)
2727
2828var hashes = []crypto.Hash {
@@ -1172,7 +1172,7 @@ func TestAddSubkeySerialized(t *testing.T) {
11721172
11731173func TestAddHMACSubkey (t * testing.T ) {
11741174 c := & packet.Config {
1175- RSABits : 512 ,
1175+ RSABits : 512 ,
11761176 Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
11771177 }
11781178
@@ -1187,7 +1187,7 @@ func TestAddHMACSubkey(t *testing.T) {
11871187 }
11881188
11891189 buf := bytes .NewBuffer (nil )
1190- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1190+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
11911191 if err := entity .SerializePrivate (w , nil ); err != nil {
11921192 t .Errorf ("failed to serialize entity: %s" , err )
11931193 }
@@ -1204,37 +1204,36 @@ func TestAddHMACSubkey(t *testing.T) {
12041204 generatedPublicKey := entity .Subkeys [1 ].PublicKey .PublicKey .(* symmetric.HMACPublicKey )
12051205 parsedPublicKey := key [0 ].Subkeys [1 ].PublicKey .PublicKey .(* symmetric.HMACPublicKey )
12061206
1207- if bytes .Compare (parsedPrivateKey .Key , generatedPrivateKey .Key ) != 0 {
1207+ if ! bytes .Equal (parsedPrivateKey .Key , generatedPrivateKey .Key ) {
12081208 t .Error ("parsed wrong key" )
12091209 }
1210- if bytes .Compare (parsedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1210+ if ! bytes .Equal (parsedPublicKey .Key , generatedPrivateKey .Key ) {
12111211 t .Error ("parsed wrong key in public part" )
12121212 }
1213- if bytes .Compare (generatedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1213+ if ! bytes .Equal (generatedPublicKey .Key , generatedPrivateKey .Key ) {
12141214 t .Error ("generated Public and Private Key differ" )
12151215 }
12161216
1217- if bytes .Compare (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) != 0 {
1217+ if ! bytes .Equal (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) {
12181218 t .Error ("parsed wrong hash seed" )
12191219 }
12201220
12211221 if parsedPrivateKey .PublicKey .Hash != generatedPrivateKey .PublicKey .Hash {
12221222 t .Error ("parsed wrong cipher id" )
12231223 }
1224- if bytes .Compare (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) != 0 {
1224+ if ! bytes .Equal (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) {
12251225 t .Error ("parsed wrong binding hash" )
12261226 }
12271227}
12281228
12291229func TestSerializeSymmetricSubkeyError (t * testing.T ) {
1230- entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
1230+ entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
12311231 if err != nil {
12321232 t .Fatal (err )
12331233 }
12341234
1235-
12361235 buf := bytes .NewBuffer (nil )
1237- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1236+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
12381237
12391238 entity .PrimaryKey .PubKeyAlgo = 100
12401239 err = entity .Serialize (w )
@@ -1251,7 +1250,7 @@ func TestSerializeSymmetricSubkeyError(t *testing.T) {
12511250
12521251func TestAddAEADSubkey (t * testing.T ) {
12531252 c := & packet.Config {
1254- RSABits : 512 ,
1253+ RSABits : 512 ,
12551254 Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
12561255 }
12571256 entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
@@ -1267,7 +1266,7 @@ func TestAddAEADSubkey(t *testing.T) {
12671266 generatedPrivateKey := entity .Subkeys [1 ].PrivateKey .PrivateKey .(* symmetric.AEADPrivateKey )
12681267
12691268 buf := bytes .NewBuffer (nil )
1270- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1269+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
12711270 if err := entity .SerializePrivate (w , nil ); err != nil {
12721271 t .Errorf ("failed to serialize entity: %s" , err )
12731272 }
@@ -1283,39 +1282,39 @@ func TestAddAEADSubkey(t *testing.T) {
12831282 generatedPublicKey := entity .Subkeys [1 ].PublicKey .PublicKey .(* symmetric.AEADPublicKey )
12841283 parsedPublicKey := key [0 ].Subkeys [1 ].PublicKey .PublicKey .(* symmetric.AEADPublicKey )
12851284
1286- if bytes .Compare (parsedPrivateKey .Key , generatedPrivateKey .Key ) != 0 {
1285+ if ! bytes .Equal (parsedPrivateKey .Key , generatedPrivateKey .Key ) {
12871286 t .Error ("parsed wrong key" )
12881287 }
1289- if bytes .Compare (parsedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1288+ if ! bytes .Equal (parsedPublicKey .Key , generatedPrivateKey .Key ) {
12901289 t .Error ("parsed wrong key in public part" )
12911290 }
1292- if bytes .Compare (generatedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1291+ if ! bytes .Equal (generatedPublicKey .Key , generatedPrivateKey .Key ) {
12931292 t .Error ("generated Public and Private Key differ" )
12941293 }
12951294
1296- if bytes .Compare (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) != 0 {
1295+ if ! bytes .Equal (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) {
12971296 t .Error ("parsed wrong hash seed" )
12981297 }
12991298
13001299 if parsedPrivateKey .PublicKey .Cipher .Id () != generatedPrivateKey .PublicKey .Cipher .Id () {
13011300 t .Error ("parsed wrong cipher id" )
13021301 }
1303- if bytes .Compare (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) != 0 {
1302+ if ! bytes .Equal (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) {
13041303 t .Error ("parsed wrong binding hash" )
13051304 }
13061305}
13071306
13081307func TestNoSymmetricKeySerialized (t * testing.T ) {
13091308 aeadConfig := & packet.Config {
1310- RSABits : 512 ,
1311- DefaultHash : crypto .SHA512 ,
1312- Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
1309+ RSABits : 512 ,
1310+ DefaultHash : crypto .SHA512 ,
1311+ Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
13131312 DefaultCipher : packet .CipherAES256 ,
13141313 }
13151314 hmacConfig := & packet.Config {
1316- RSABits : 512 ,
1317- DefaultHash : crypto .SHA512 ,
1318- Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
1315+ RSABits : 512 ,
1316+ DefaultHash : crypto .SHA512 ,
1317+ Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
13191318 DefaultCipher : packet .CipherAES256 ,
13201319 }
13211320 entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
0 commit comments