-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by shazled:
What steps will reproduce the problem? package main import ( "bytes" "code.google.com/p/go.crypto/openpgp" "crypto/rand" "log" "time" ) func main() { // Create new entities entity1, err := openpgp.NewEntity(rand.Reader, time.Now(), "Test user 1", "test1", "test1@localhost") if err != nil { log.Fatal("Cannot create new PGP entity", err) } println("Entity can sign? ", entity1.PrimaryKey.CanSign()) entity2, err := openpgp.NewEntity(rand.Reader, time.Now(), "Test user 2", "test2", "test2@localhost") if err != nil { log.Fatal("Cannot create new PGP entity", err) } // The buffer that holds the encrypted message encrypted := new(bytes.Buffer) // The message to encrypt content := "The quick brown fox" // Setup encryption enc, err := openpgp.Encrypt(encrypted, []*openpgp.Entity{entity2}, entity1, nil) if err != nil { log.Fatal("Encryption setup: ", err) } // Encrypt _, err = enc.Write([]byte(content)) if err != nil { log.Fatal("Encryption: ", err) } // Indicate that this is the end of the message enc.Close() println(encrypted.String()) } What is the expected output? A PGP encrypted buffer What do you see instead? Entity can sign? true panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x24 pc=0x80606b9] goroutine 1 [running]: code.google.com/p/go.crypto/openpgp.signatureWriter.Write(0x1867e120, 0x18679eb0, 0x1867e200, 0x18679ee0, 0x9, ...) /home/saul/go/src/pkg/code.google.com/p/go.crypto/openpgp/write.go:277 +0x45 code.google.com/p/go.crypto/openpgp.(*signatureWriter).Write(0x1867e060, 0x1867e080, 0x13, 0x13, 0x13, ...) /home/saul/go/src/pkg/code.google.com/p/go.crypto/openpgp/canonical_text.go:0 +0x72 main.main() /home/saul/play/auricular-go/bug.go:42 +0x435 Which compiler are you using (5g, 6g, 8g, gccgo)? 6g, 8g Which operating system are you using? Fedora 16 (Linux), Mint XFCE (Linux) Which revision are you using? (hg identify) f4b96aaf712d tip Please provide any additional information below. If an entity isn't used to sign the encryption is successful.
Attachments:
- bug.go (1060 bytes)