|
|
@@ -135,6 +135,25 @@ func TestTextSignedMessage(t *testing.T) {
|
|
|
checkSignedMessage(t, signedTextMessageHex, signedTextInput)
|
|
|
}
|
|
|
|
|
|
+// The reader should detect "compressed quines", which are compressed
|
|
|
+// packets that expand into themselves and cause an infinite recursive
|
|
|
+// parsing loop.
|
|
|
+// The packet in this test case comes from Taylor R. Campbell at
|
|
|
+// http://mumble.net/~campbell/misc/pgp-quine/
|
|
|
+func TestCampbellQuine(t *testing.T) {
|
|
|
+ md, err := ReadMessage(readerFromHex(campbellQuine), nil, nil, nil)
|
|
|
+ if md != nil {
|
|
|
+ t.Errorf("Reading a compressed quine should not return any data: %#v", md)
|
|
|
+ }
|
|
|
+ structural, ok := err.(errors.StructuralError)
|
|
|
+ if !ok {
|
|
|
+ t.Fatalf("Unexpected class of error: %T", err)
|
|
|
+ }
|
|
|
+ if !strings.Contains(string(structural), "too many layers of packets") {
|
|
|
+ t.Fatalf("Unexpected error: %s", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
var signedEncryptedMessageTests = []struct {
|
|
|
keyRingHex string
|
|
|
messageHex string
|
|
|
@@ -440,3 +459,5 @@ const dsaKeyWithSHA512 = `9901a2044f04b07f110400db244efecc7316553ee08d179972aab8
|
|
|
const unknownHashFunctionHex = `8a00000040040001990006050253863c24000a09103b4fe6acc0b21f32ffff01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`
|
|
|
|
|
|
const missingHashFunctionHex = `8a00000040040001030006050253863c24000a09103b4fe6acc0b21f32ffff01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`
|
|
|
+
|
|
|
+const campbellQuine = `a0b001000300fcffa0b001000d00f2ff000300fcffa0b001000d00f2ff8270a01c00000500faff8270a01c00000500faff000500faff001400ebff8270a01c00000500faff000500faff001400ebff428821c400001400ebff428821c400001400ebff428821c400001400ebff428821c400001400ebff428821c400000000ffff000000ffff000b00f4ff428821c400000000ffff000000ffff000b00f4ff0233214c40000100feff000233214c40000100feff0000`
|