openpgp: Handle signatures that have multiple signature packets
Fixes #12242 Change-Id: Ie40e84bc9e7db390219d85a7eddea99accb19cb8 Reviewed-on: https://go-review.googlesource.com/13781 Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
committed by
Adam Langley
parent
fc08251b06
commit
2b8f0970a8
+16
-3
@@ -315,6 +315,11 @@ func TestDetachedSignatureDSA(t *testing.T) {
|
||||
testDetachedSignature(t, kring, readerFromHex(detachedSignatureDSAHex), signedInput, "binary", testKey3KeyId)
|
||||
}
|
||||
|
||||
func TestMultipleSignaturePacketsDSA(t *testing.T) {
|
||||
kring, _ := ReadKeyRing(readerFromHex(dsaTestKeyHex))
|
||||
testDetachedSignature(t, kring, readerFromHex(missingHashFunctionHex+detachedSignatureDSAHex), signedInput, "binary", testKey3KeyId)
|
||||
}
|
||||
|
||||
func testHashFunctionError(t *testing.T, signatureHex string) {
|
||||
kring, _ := ReadKeyRing(readerFromHex(testKeys1And2Hex))
|
||||
_, err := CheckDetachedSignature(kring, nil, readerFromHex(signatureHex))
|
||||
@@ -338,8 +343,16 @@ func TestUnknownHashFunction(t *testing.T) {
|
||||
|
||||
func TestMissingHashFunction(t *testing.T) {
|
||||
// missingHashFunctionHex contains a signature packet that uses
|
||||
// RIPEMD160, which isn't compiled in.
|
||||
testHashFunctionError(t, missingHashFunctionHex)
|
||||
// RIPEMD160, which isn't compiled in. Since that's the only signature
|
||||
// packet we don't find any suitable packets and end up with ErrUnknownIssuer
|
||||
kring, _ := ReadKeyRing(readerFromHex(testKeys1And2Hex))
|
||||
_, err := CheckDetachedSignature(kring, nil, readerFromHex(missingHashFunctionHex))
|
||||
if err == nil {
|
||||
t.Fatal("Packet with missing hash type was correctly parsed")
|
||||
}
|
||||
if err != errors.ErrUnknownIssuer {
|
||||
t.Fatalf("Unexpected class of error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadingArmoredPrivateKey(t *testing.T) {
|
||||
@@ -488,6 +501,6 @@ const dsaKeyWithSHA512 = `9901a2044f04b07f110400db244efecc7316553ee08d179972aab8
|
||||
|
||||
const unknownHashFunctionHex = `8a00000040040001990006050253863c24000a09103b4fe6acc0b21f32ffff01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`
|
||||
|
||||
const missingHashFunctionHex = `8a00000040040001030006050253863c24000a09103b4fe6acc0b21f32ffff01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101`
|
||||
const missingHashFunctionHex = `8a00000040040001030006050253863c24000a09103b4fe6acc0b21f32ffff0101010101010101010101010101010101010101010101010101010101010101010101010101`
|
||||
|
||||
const campbellQuine = `a0b001000300fcffa0b001000d00f2ff000300fcffa0b001000d00f2ff8270a01c00000500faff8270a01c00000500faff000500faff001400ebff8270a01c00000500faff000500faff001400ebff428821c400001400ebff428821c400001400ebff428821c400001400ebff428821c400001400ebff428821c400000000ffff000000ffff000b00f4ff428821c400000000ffff000000ffff000b00f4ff0233214c40000100feff000233214c40000100feff0000`
|
||||
|
||||
Reference in New Issue
Block a user