File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ func (pk *PublicKeyV3) parseRSA(r io.Reader) (err error) {
95
95
return
96
96
}
97
97
98
+ // RFC 4880 Section 12.2 requires the low 8 bytes of the
99
+ // modulus to form the key id.
100
+ if len (pk .n .bytes ) < 8 {
101
+ return errors .StructuralError ("v3 public key modulus is too short" )
102
+ }
98
103
if len (pk .e .bytes ) > 3 {
99
104
err = errors .UnsupportedError ("large public exponent" )
100
105
return
Original file line number Diff line number Diff line change @@ -369,12 +369,10 @@ func TestNoArmoredData(t *testing.T) {
369
369
}
370
370
}
371
371
372
- func TestIssue11503 (t * testing.T ) {
373
- data := "8c040402000aa430aa8228b9248b01fc899a91197130303030"
374
-
375
- buf , err := hex .DecodeString (data )
372
+ func testReadMessageError (t * testing.T , messageHex string ) {
373
+ buf , err := hex .DecodeString (messageHex )
376
374
if err != nil {
377
- t .Errorf ("hex.DecodeSting (): %v" , err )
375
+ t .Errorf ("hex.DecodeString (): %v" , err )
378
376
}
379
377
380
378
kr , err := ReadKeyRing (new (bytes.Buffer ))
@@ -392,6 +390,14 @@ func TestIssue11503(t *testing.T) {
392
390
}
393
391
}
394
392
393
+ func TestIssue11503 (t * testing.T ) {
394
+ testReadMessageError (t , "8c040402000aa430aa8228b9248b01fc899a91197130303030" )
395
+ }
396
+
397
+ func TestIssue11504 (t * testing.T ) {
398
+ testReadMessageError (t , "9303000130303030303030303030983002303030303030030000000130" )
399
+ }
400
+
395
401
const testKey1KeyId = 0xA34D7E18C20C31BB
396
402
const testKey3KeyId = 0x338934250CCC0360
397
403
You can’t perform that action at this time.
0 commit comments