openpgp patch to properly check for creation time subpacket
authornsz <nsz@port70.net>
Fri, 2 Dec 2011 00:42:20 +0000 (01:42 +0100)
committernsz <nsz@port70.net>
Fri, 2 Dec 2011 00:42:20 +0000 (01:42 +0100)
patches/creationtime.diff [new file with mode: 0644]

diff --git a/patches/creationtime.diff b/patches/creationtime.diff
new file mode 100644 (file)
index 0000000..3c61d8f
--- /dev/null
@@ -0,0 +1,40 @@
+diff -r 221f3eb76b52 src/pkg/crypto/openpgp/packet/signature.go
+--- a/src/pkg/crypto/openpgp/packet/signature.go       Thu Nov 24 08:51:47 2011 -0800
++++ b/src/pkg/crypto/openpgp/packet/signature.go       Fri Dec 02 01:39:57 2011 +0100
+@@ -144,14 +144,21 @@
+ // parseSignatureSubpackets parses subpackets of the main signature packet. See
+ // RFC 4880, section 5.2.3.1.
+ func parseSignatureSubpackets(sig *Signature, subpackets []byte, isHashed bool) (err error) {
++      hasCreationTime := false
++
+       for len(subpackets) > 0 {
+-              subpackets, err = parseSignatureSubpacket(sig, subpackets, isHashed)
++              var packetType signatureSubpacketType
++
++              packetType, subpackets, err = parseSignatureSubpacket(sig, subpackets, isHashed)
+               if err != nil {
+                       return
+               }
++              if packetType == creationTimeSubpacket {
++                      hasCreationTime = true
++              }
+       }
+-      if sig.CreationTime == 0 {
++      if !hasCreationTime {
+               err = error_.StructuralError("no creation time in signature")
+       }
+@@ -173,11 +180,10 @@
+ )
+ // parseSignatureSubpacket parses a single subpacket. len(subpacket) is >= 1.
+-func parseSignatureSubpacket(sig *Signature, subpacket []byte, isHashed bool) (rest []byte, err error) {
++func parseSignatureSubpacket(sig *Signature, subpacket []byte, isHashed bool) (packetType signatureSubpacketType, rest []byte, err error) {
+       // RFC 4880, section 5.2.3.1
+       var (
+               length     uint32
+-              packetType signatureSubpacketType
+               isCritical bool
+       )
+       switch {