@@ -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 {
@@ -1169,7 +1169,7 @@ func TestAddSubkeySerialized(t *testing.T) {
11691169
11701170func TestAddHMACSubkey (t * testing.T ) {
11711171 c := & packet.Config {
1172- RSABits : 512 ,
1172+ RSABits : 512 ,
11731173 Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
11741174 }
11751175
@@ -1184,7 +1184,7 @@ func TestAddHMACSubkey(t *testing.T) {
11841184 }
11851185
11861186 buf := bytes .NewBuffer (nil )
1187- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1187+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
11881188 if err := entity .SerializePrivate (w , nil ); err != nil {
11891189 t .Errorf ("failed to serialize entity: %s" , err )
11901190 }
@@ -1201,37 +1201,36 @@ func TestAddHMACSubkey(t *testing.T) {
12011201 generatedPublicKey := entity .Subkeys [1 ].PublicKey .PublicKey .(* symmetric.HMACPublicKey )
12021202 parsedPublicKey := key [0 ].Subkeys [1 ].PublicKey .PublicKey .(* symmetric.HMACPublicKey )
12031203
1204- if bytes .Compare (parsedPrivateKey .Key , generatedPrivateKey .Key ) != 0 {
1204+ if ! bytes .Equal (parsedPrivateKey .Key , generatedPrivateKey .Key ) {
12051205 t .Error ("parsed wrong key" )
12061206 }
1207- if bytes .Compare (parsedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1207+ if ! bytes .Equal (parsedPublicKey .Key , generatedPrivateKey .Key ) {
12081208 t .Error ("parsed wrong key in public part" )
12091209 }
1210- if bytes .Compare (generatedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1210+ if ! bytes .Equal (generatedPublicKey .Key , generatedPrivateKey .Key ) {
12111211 t .Error ("generated Public and Private Key differ" )
12121212 }
12131213
1214- if bytes .Compare (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) != 0 {
1214+ if ! bytes .Equal (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) {
12151215 t .Error ("parsed wrong hash seed" )
12161216 }
12171217
12181218 if parsedPrivateKey .PublicKey .Hash != generatedPrivateKey .PublicKey .Hash {
12191219 t .Error ("parsed wrong cipher id" )
12201220 }
1221- if bytes .Compare (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) != 0 {
1221+ if ! bytes .Equal (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) {
12221222 t .Error ("parsed wrong binding hash" )
12231223 }
12241224}
12251225
12261226func TestSerializeSymmetricSubkeyError (t * testing.T ) {
1227- entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
1227+ entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
12281228 if err != nil {
12291229 t .Fatal (err )
12301230 }
12311231
1232-
12331232 buf := bytes .NewBuffer (nil )
1234- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1233+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
12351234
12361235 entity .PrimaryKey .PubKeyAlgo = 100
12371236 err = entity .Serialize (w )
@@ -1248,7 +1247,7 @@ func TestSerializeSymmetricSubkeyError(t *testing.T) {
12481247
12491248func TestAddAEADSubkey (t * testing.T ) {
12501249 c := & packet.Config {
1251- RSABits : 512 ,
1250+ RSABits : 512 ,
12521251 Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
12531252 }
12541253 entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
@@ -1264,7 +1263,7 @@ func TestAddAEADSubkey(t *testing.T) {
12641263 generatedPrivateKey := entity .Subkeys [1 ].PrivateKey .PrivateKey .(* symmetric.AEADPrivateKey )
12651264
12661265 buf := bytes .NewBuffer (nil )
1267- w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
1266+ w , _ := armor .Encode (buf , "PGP PRIVATE KEY BLOCK" , nil )
12681267 if err := entity .SerializePrivate (w , nil ); err != nil {
12691268 t .Errorf ("failed to serialize entity: %s" , err )
12701269 }
@@ -1280,39 +1279,39 @@ func TestAddAEADSubkey(t *testing.T) {
12801279 generatedPublicKey := entity .Subkeys [1 ].PublicKey .PublicKey .(* symmetric.AEADPublicKey )
12811280 parsedPublicKey := key [0 ].Subkeys [1 ].PublicKey .PublicKey .(* symmetric.AEADPublicKey )
12821281
1283- if bytes .Compare (parsedPrivateKey .Key , generatedPrivateKey .Key ) != 0 {
1282+ if ! bytes .Equal (parsedPrivateKey .Key , generatedPrivateKey .Key ) {
12841283 t .Error ("parsed wrong key" )
12851284 }
1286- if bytes .Compare (parsedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1285+ if ! bytes .Equal (parsedPublicKey .Key , generatedPrivateKey .Key ) {
12871286 t .Error ("parsed wrong key in public part" )
12881287 }
1289- if bytes .Compare (generatedPublicKey .Key , generatedPrivateKey .Key ) != 0 {
1288+ if ! bytes .Equal (generatedPublicKey .Key , generatedPrivateKey .Key ) {
12901289 t .Error ("generated Public and Private Key differ" )
12911290 }
12921291
1293- if bytes .Compare (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) != 0 {
1292+ if ! bytes .Equal (parsedPrivateKey .HashSeed [:], generatedPrivateKey .HashSeed [:]) {
12941293 t .Error ("parsed wrong hash seed" )
12951294 }
12961295
12971296 if parsedPrivateKey .PublicKey .Cipher .Id () != generatedPrivateKey .PublicKey .Cipher .Id () {
12981297 t .Error ("parsed wrong cipher id" )
12991298 }
1300- if bytes .Compare (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) != 0 {
1299+ if ! bytes .Equal (parsedPrivateKey .PublicKey .BindingHash [:], generatedPrivateKey .PublicKey .BindingHash [:]) {
13011300 t .Error ("parsed wrong binding hash" )
13021301 }
13031302}
13041303
13051304func TestNoSymmetricKeySerialized (t * testing.T ) {
13061305 aeadConfig := & packet.Config {
1307- RSABits : 512 ,
1308- DefaultHash : crypto .SHA512 ,
1309- Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
1306+ RSABits : 512 ,
1307+ DefaultHash : crypto .SHA512 ,
1308+ Algorithm : packet .ExperimentalPubKeyAlgoAEAD ,
13101309 DefaultCipher : packet .CipherAES256 ,
13111310 }
13121311 hmacConfig := & packet.Config {
1313- RSABits : 512 ,
1314- DefaultHash : crypto .SHA512 ,
1315- Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
1312+ RSABits : 512 ,
1313+ DefaultHash : crypto .SHA512 ,
1314+ Algorithm : packet .ExperimentalPubKeyAlgoHMAC ,
13161315 DefaultCipher : packet .CipherAES256 ,
13171316 }
13181317 entity ,
err := NewEntity (
"Golang Gopher" ,
"Test Key" ,
"[email protected] " ,
& packet.
Config {
RSABits :
1024 })
0 commit comments