1 diff -r 221f3eb76b52 src/pkg/crypto/openpgp/packet/signature.go
2 --- a/src/pkg/crypto/openpgp/packet/signature.go Thu Nov 24 08:51:47 2011 -0800
3 +++ b/src/pkg/crypto/openpgp/packet/signature.go Wed Nov 30 23:44:34 2011 +0100
6 creationTimeSubpacket signatureSubpacketType = 2
7 signatureExpirationSubpacket signatureSubpacketType = 3
8 - keyExpirySubpacket signatureSubpacketType = 9
9 + keyExpirationSubpacket signatureSubpacketType = 9
10 prefSymmetricAlgosSubpacket signatureSubpacketType = 11
11 issuerSubpacket signatureSubpacketType = 16
12 prefHashAlgosSubpacket signatureSubpacketType = 21
15 sig.SigLifetimeSecs = new(uint32)
16 *sig.SigLifetimeSecs = binary.BigEndian.Uint32(subpacket)
17 - case keyExpirySubpacket:
18 + case keyExpirationSubpacket:
19 // Key expiration time, section 5.2.3.6
24 func (sig *Signature) buildSubpackets() (subpackets []outputSubpacket) {
25 creationTime := make([]byte, 4)
26 - creationTime[0] = byte(sig.CreationTime >> 24)
27 - creationTime[1] = byte(sig.CreationTime >> 16)
28 - creationTime[2] = byte(sig.CreationTime >> 8)
29 - creationTime[3] = byte(sig.CreationTime)
30 + binary.BigEndian.PutUint32(creationTime, sig.CreationTime)
31 subpackets = append(subpackets, outputSubpacket{true, creationTimeSubpacket, false, creationTime})
33 if sig.IssuerKeyId != nil {
35 subpackets = append(subpackets, outputSubpacket{true, issuerSubpacket, false, keyId})
38 + if sig.SigLifetimeSecs != nil && *sig.SigLifetimeSecs != 0 {
39 + sigLifetime := make([]byte, 4)
40 + binary.BigEndian.PutUint32(sigLifetime, *sig.SigLifetimeSecs)
41 + // signature expiration is marked as critical
42 + subpackets = append(subpackets, outputSubpacket{true, signatureExpirationSubpacket, true, sigLifetime})
45 + // The following subpackets may only appear in self-signatures
47 + if sig.KeyLifetimeSecs != nil && *sig.KeyLifetimeSecs != 0 {
48 + keyLifetime := make([]byte, 4)
49 + binary.BigEndian.PutUint32(keyLifetime, *sig.KeyLifetimeSecs)
51 + // key expiration is marked as critical
52 + subpackets = append(subpackets, outputSubpacket{true, keyExpirationSubpacket, true, keyLifetime})
55 + if sig.IsPrimaryId != nil && *sig.IsPrimaryId {
56 + subpackets = append(subpackets, outputSubpacket{true, primaryUserIdSubpacket, false, []byte{1}})
59 + // []byte slices of preferred algorithms are not copied
61 + if len(sig.PreferredSymmetric) > 0 {
62 + subpackets = append(subpackets, outputSubpacket{true, prefSymmetricAlgosSubpacket, false, sig.PreferredSymmetric})
65 + if len(sig.PreferredHash) > 0 {
66 + subpackets = append(subpackets, outputSubpacket{true, prefHashAlgosSubpacket, false, sig.PreferredHash})
69 + if len(sig.PreferredCompression) > 0 {
70 + subpackets = append(subpackets, outputSubpacket{true, prefCompressionSubpacket, false, sig.PreferredCompression})
73 + // The Key Flags subpacket may only appear in self-signatures or certification signatures
77 + if sig.FlagCertify {
83 + if sig.FlagEncryptCommunications {
86 + if sig.FlagEncryptStorage {
89 + subpackets = append(subpackets, outputSubpacket{true, keyFlagsSubpacket, false, []byte{flags}})