Skip to content

Commit 7c0e7fc

Browse files
Add V5 Signature Packet Formats
1 parent 45263d5 commit 7c0e7fc

File tree

10 files changed

+223
-27
lines changed

10 files changed

+223
-27
lines changed

errs/errs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package errs
22

33
import "fmt"
44

5-
//Num is error number for CVSS
5+
//Num is error number for gpgpdumo
66
type Num int
77

88
const (

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/inconshreveable/mousetrap v1.0.0 // indirect
88
github.com/spf13/cobra v0.0.3
99
github.com/spf13/pflag v1.0.3 // indirect
10-
github.com/spiegel-im-spiegel/gocli v0.9.3
11-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
12-
golang.org/x/xerrors v0.0.0-20190212162355-a5947ffaace3
10+
github.com/spiegel-im-spiegel/gocli v0.9.4
11+
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576
12+
golang.org/x/xerrors v0.0.0-20190315151331-d61658bd2e18
1313
)

packet/tags/sub33.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (s *sub33) Parse() (*info.Item, error) {
3535
case 4:
3636
itm.Note = "need 20 octets length"
3737
case 5:
38-
itm.Note = "need 25 octets length"
38+
itm.Note = "need 32 octets length"
3939
default:
4040
itm.Note = values.Unknown
4141
}

packet/tags/sub34.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func newSub34(cxt *context.Context, subID values.SuboacketID, body []byte) Subs
2020
// Parse parsing Preferred AEAD Algorithms Sub-packet
2121
func (s *sub34) Parse() (*info.Item, error) {
2222
rootInfo := s.ToItem()
23+
for _, alg := range s.reader.GetBody() {
24+
rootInfo.Add(values.AEADID(alg).ToItem(s.cxt.Debug()))
25+
}
2326
return rootInfo, nil
2427
}
2528

packet/tags/tag02.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,23 @@ func (t *tag02) Parse() (*info.Item, error) {
3333
version := values.SigVer(v)
3434
rootInfo.Add(version.ToItem(t.cxt.Debug()))
3535

36-
if version.IsCurrent() {
37-
_, err2 := t.parseV4(rootInfo)
38-
if err2 != nil {
36+
switch true {
37+
case version.IsDraft():
38+
_, err := t.parseV5(rootInfo)
39+
if err != nil {
40+
return rootInfo, errs.Wrapf(err, "error in parsing tag %d", int(t.tag))
41+
}
42+
case version.IsCurrent():
43+
_, err := t.parseV4(rootInfo)
44+
if err != nil {
3945
return rootInfo, errs.Wrapf(err, "error in parsing tag %d", int(t.tag))
4046
}
41-
} else if version.IsOld() {
42-
switch version.Number() {
43-
case 3:
47+
case version.IsOld():
48+
if version.Number() == 3 {
4449
_, err2 := t.parseV3(rootInfo)
4550
if err2 != nil {
4651
return rootInfo, errs.Wrapf(err, "error in parsing tag %d", int(t.tag))
4752
}
48-
default:
4953
}
5054
}
5155

@@ -125,78 +129,82 @@ func (t *tag02) parseV4(rootInfo *info.Item) (*info.Item, error) {
125129
// [01] One-octet signature type.
126130
sig, err := t.reader.ReadByte()
127131
if err != nil {
128-
return rootInfo, errs.Wrap(err, "illegal sigid in parsing Signiture V4 Packet")
132+
return rootInfo, errs.Wrap(err, "illegal sigid in parsing Signiture V4/V5 Packet")
129133
}
130134
rootInfo.Add(values.SigID(sig).ToItem(t.cxt.Debug()))
131135
// [02] One-octet public-key algorithm.
132136
pubid, err := t.reader.ReadByte()
133137
if err != nil {
134-
return rootInfo, errs.Wrap(err, "illegal pubid in parsing Signiture V4 Packet")
138+
return rootInfo, errs.Wrap(err, "illegal pubid in parsing Signiture V4/V5 Packet")
135139
}
136140
rootInfo.Add(values.PubID(pubid).ToItem(t.cxt.Debug()))
137141
// [03] One-octet hash algorithm.
138142
hashid, err := t.reader.ReadByte()
139143
if err != nil {
140-
return rootInfo, errs.Wrap(err, "illegal hashid in parsing Signiture V4 Packet")
144+
return rootInfo, errs.Wrap(err, "illegal hashid in parsing Signiture V4/V5 Packet")
141145
}
142146
rootInfo.Add(values.HashID(hashid).ToItem(t.cxt.Debug()))
143147
// [04] Two-octet scalar octet count for following hashed subpacket data.(= HS)
144148
s, err := t.reader.ReadBytes(2)
145149
if err != nil {
146-
return rootInfo, errs.Wrap(err, "illegal length of hashed subpacket in parsing Signiture V4 Packet")
150+
return rootInfo, errs.Wrap(err, "illegal length of hashed subpacket in parsing Signiture V4/V5 Packet")
147151
}
148152
sizeHS := binary.BigEndian.Uint16(s)
149153
// [06] Hashed subpacket data set (zero or more subpackets).
150154
if sizeHS > 0 {
151155
sp, err := t.reader.ReadBytes(int64(sizeHS))
152156
if err != nil {
153-
return rootInfo, errs.Wrapf(err, "illegal hashed subpacket in parsing Signiture V4 Packet (size: %d bytes)", int64(sizeHS))
157+
return rootInfo, errs.Wrapf(err, "illegal hashed subpacket in parsing Signiture V4/V5 Packet (size: %d bytes)", int64(sizeHS))
154158
}
155159
subpcket, err := newSubparser(t.cxt, t.tag, "Hashed Subpacket", sp)
156160
if err != nil {
157-
return rootInfo, errs.Wrapf(err, "error in parsing hashed subpacket in Signiture V4 Packet (size: %d bytes)", int64(sizeHS))
161+
return rootInfo, errs.Wrapf(err, "error in parsing hashed subpacket in Signiture V4/V5 Packet (size: %d bytes)", int64(sizeHS))
158162
}
159163
itm, err := subpcket.Parse()
160164
if err != nil {
161-
return rootInfo, errs.Wrapf(err, "error in parsing hashed subpacket in Signiture V4 Packet (size: %d bytes)", int64(sizeHS))
165+
return rootInfo, errs.Wrapf(err, "error in parsing hashed subpacket in Signiture V4/V5 Packet (size: %d bytes)", int64(sizeHS))
162166
}
163167
rootInfo.Add(itm)
164168
}
165169
// [06+HS] Two-octet scalar octet count for the following unhashed subpacket data.(= US)
166170
s, err = t.reader.ReadBytes(2)
167171
if err != nil {
168-
return rootInfo, errs.Wrap(err, "illegal length of unhashed subpacket in parsing Signiture V4 Packet")
172+
return rootInfo, errs.Wrap(err, "illegal length of unhashed subpacket in parsing Signiture V4/V5 Packet")
169173
}
170174
sizeUS := binary.BigEndian.Uint16(s)
171175
// [08+HS] Unhashed subpacket data set (zero or more subpackets).
172176
if sizeUS > 0 {
173177
sp, err := t.reader.ReadBytes(int64(sizeUS))
174178
if err != nil {
175-
return rootInfo, errs.Wrapf(err, "illegal unhashed subpacket in parsing Signiture V4 Packet (size: %d bytes)", int64(sizeUS))
179+
return rootInfo, errs.Wrapf(err, "illegal unhashed subpacket in parsing Signiture V4/V5 Packet (size: %d bytes)", int64(sizeUS))
176180
}
177181
subpcket, err := newSubparser(t.cxt, t.tag, "Unhashed Subpacket", sp)
178182
if err != nil {
179-
return rootInfo, errs.Wrapf(err, "error in parsing unhashed subpacket in Signiture V4 Packet (size: %d bytes)", int64(sizeUS))
183+
return rootInfo, errs.Wrapf(err, "error in parsing unhashed subpacket in Signiture V4/V5 Packet (size: %d bytes)", int64(sizeUS))
180184
}
181185
itm, err := subpcket.Parse()
182186
if err != nil {
183-
return rootInfo, errs.Wrapf(err, "error in parsing unhashed subpacket in Signiture V4 Packet (size: %d bytes)", int64(sizeUS))
187+
return rootInfo, errs.Wrapf(err, "error in parsing unhashed subpacket in Signiture V4/V5 Packet (size: %d bytes)", int64(sizeUS))
184188
}
185189
rootInfo.Add(itm)
186190
}
187191
// [08+HS+US] Two-octet field holding the left 16 bits of the signed hash value.
188192
hv, err := t.reader.ReadBytes(2)
189193
if err != nil {
190-
return rootInfo, errs.Wrap(err, "illegal hash value in parsing Signiture V4 Packet")
194+
return rootInfo, errs.Wrap(err, "illegal hash value in parsing Signiture V4/V5 Packet")
191195
}
192196
rootInfo.Add(t.hashLeft2(hv))
193197
// [10+HS+US] One or more multiprecision integers comprising the signature.
194198
if err := pubkey.New(t.cxt, values.PubID(pubid), t.reader).ParseSig(rootInfo); err != nil {
195-
return rootInfo, errs.Wrap(err, "error in parsing Signiture V4 Packet")
199+
return rootInfo, errs.Wrap(err, "error in parsing Signiture V4/V5 Packet")
196200
}
197201
return rootInfo, nil
198202
}
199203

204+
func (t *tag02) parseV5(rootInfo *info.Item) (*info.Item, error) {
205+
return t.parseV4(rootInfo)
206+
}
207+
200208
func (t *tag02) hashLeft2(hv []byte) *info.Item {
201209
return info.NewItem(
202210
info.Name("Hash left 2 bytes"),

packet/tags/tag02_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var (
1818
tag02Body4 = []byte{0x03, 0x05, 0x00, 0x36, 0x5e, 0xba, 0x44, 0x0f, 0x64, 0x8a, 0x1c, 0x9e, 0x4f, 0x74, 0x4d, 0x01, 0x01, 0x66, 0x36, 0x04, 0x00, 0x8f, 0x8c, 0x6b, 0x45, 0xa7, 0x65, 0xbd, 0x37, 0xf6, 0x76, 0x58, 0x85, 0x7c, 0x39, 0x66, 0x7a, 0xc5, 0xc1, 0x48, 0xf3, 0xb8, 0x85, 0x69, 0x7f, 0x22, 0x54, 0x71, 0x50, 0x0e, 0x97, 0xb2, 0x51, 0x77, 0x53, 0xa2, 0x22, 0xd4, 0x46, 0xec, 0x0c, 0x50, 0xbe, 0xee, 0xe6, 0xb0, 0xc2, 0x76, 0x08, 0xf0, 0x6b, 0x0e, 0x6c, 0xfc, 0xe6, 0xef, 0xcd, 0x10, 0x3d, 0x10, 0xfd, 0xb3, 0x87, 0x40, 0x20, 0x55, 0x6c, 0x06, 0xae, 0x41, 0xc5, 0x7c, 0x0d, 0x17, 0x75, 0x44, 0x32, 0x7d, 0x08, 0x41, 0x45, 0x95, 0xda, 0xd6, 0x57, 0x74, 0x58, 0x38, 0x72, 0x6e, 0xf7, 0x1f, 0x63, 0xce, 0xd8, 0x00, 0x1b, 0x25, 0x37, 0x23, 0xb2, 0x56, 0x1a, 0x02, 0x9a, 0xee, 0x5a, 0x57, 0xf7, 0xa3, 0xab, 0x2d, 0x89, 0x20, 0x85, 0x1c, 0xc5, 0xc0, 0xec, 0x64, 0xe9, 0x2f, 0x0b, 0xf5, 0x4b, 0x5f, 0x2b, 0x65, 0x39}
1919
tag02Body5 = []byte{0x04, 0x13, 0x01, 0x08, 0x00, 0x1e, 0x05, 0x02, 0x5a, 0xfa, 0x85, 0x65, 0x02, 0x9b, 0x2f, 0x05, 0x8b, 0x09, 0x08, 0x07, 0x02, 0x06, 0x95, 0x0a, 0x09, 0x08, 0x0b, 0x02, 0x04, 0x96, 0x02, 0x03, 0x01, 0x02, 0x9e, 0x01, 0x00, 0x0a, 0x09, 0x10, 0x8e, 0x3d, 0xba, 0x0e, 0xc4, 0xdc, 0xc3, 0xb7, 0xef, 0x56, 0x07, 0xff, 0x63, 0xcf, 0x00, 0x07, 0x32, 0xd7, 0x4c, 0x58, 0x0b, 0xa3, 0x81, 0x0e, 0xd7, 0x3e, 0xde, 0x04, 0xd4, 0xf8, 0x63, 0x87, 0x49, 0xf3, 0x3c, 0x8a, 0x36, 0x47, 0x30, 0x25, 0x15, 0x5b, 0x3a, 0xea, 0x75, 0x95, 0x53, 0x70, 0x31, 0xbe, 0xb9, 0x23, 0x2a, 0xa7, 0xc5, 0xb4, 0xd7, 0x56, 0xcb, 0x00, 0x1c, 0xc6, 0x03, 0xf4, 0x49, 0x87, 0xcd, 0x07, 0xd5, 0xd4, 0x1f, 0xc1, 0x95, 0xc1, 0xf7, 0x0e, 0x16, 0x27, 0x54, 0xda, 0x4e, 0xa0, 0xea, 0xde, 0x5b, 0xdd, 0xeb, 0x4d, 0x17, 0x19, 0x4b, 0x61, 0x30, 0x52, 0xd0, 0x02, 0x50, 0x16, 0x5a, 0xb5, 0xcf, 0xa7, 0x64, 0x2c, 0x89, 0xff, 0x67, 0x12, 0x9b, 0xce, 0xb6, 0xba, 0x92, 0xa4, 0x61, 0x25, 0x96, 0x06, 0x14, 0x23, 0xed, 0x6d, 0x30, 0x8f, 0xe5, 0x26, 0x9c, 0x66, 0x5b, 0x6f, 0x34, 0x05, 0x66, 0x13, 0xb7, 0xcd, 0x90, 0xbc, 0x38, 0x84, 0xaf, 0x5f, 0x8f, 0x20, 0x07, 0xd0, 0xe5, 0xbd, 0x17, 0x23, 0x4f, 0x2a, 0x5d, 0x37, 0x17, 0xd8, 0xf8, 0xb4, 0x2f, 0xe6, 0xbe, 0x28, 0x79, 0xbc, 0x00, 0x05, 0x18, 0xac, 0xab, 0xd6, 0xea, 0x9d, 0xf4, 0x6c, 0x1a, 0xdd, 0xc9, 0x6a, 0x87, 0x9e, 0x19, 0x2f, 0xff, 0x12, 0xaa, 0x69, 0x49, 0x3e, 0x93, 0xee, 0x78, 0x8c, 0xf7, 0xab, 0x29, 0xd5, 0xdc, 0x47, 0x50, 0xa6, 0x94, 0x02, 0xa4, 0xb4, 0x97, 0x10, 0xa4, 0x7d, 0x4a, 0x36, 0xbe, 0xfe, 0xe9, 0x1f, 0xc4, 0x44, 0x63, 0x7b, 0x75, 0x55, 0x3b, 0xd5, 0x7b, 0xf7, 0x76, 0x16, 0x93, 0x01, 0xb3, 0xbe, 0xf0, 0x1c, 0xc4, 0x12, 0x2a, 0x51, 0x99, 0xa2, 0xf4, 0x9d, 0x22, 0x0a, 0x51, 0x8c, 0x96, 0x77, 0x4d, 0x94, 0x24, 0x32, 0x0a, 0xde, 0x5b, 0x7d, 0x53, 0x4b, 0x24, 0xab, 0xfc, 0x30, 0x99, 0xd8, 0x7c, 0x0b, 0x88, 0x8a, 0x75, 0x4d}
2020
tag02Body6 = []byte{0x04, 0x13, 0x16, 0x0a, 0x00, 0x30, 0x02, 0x9b, 0x03, 0x05, 0x82, 0x5b, 0x1a, 0x4e, 0x1d, 0x05, 0x89, 0x01, 0xdf, 0xe2, 0x00, 0x16, 0xa1, 0x04, 0x2b, 0x77, 0x57, 0xd8, 0xaf, 0x28, 0x34, 0x68, 0xa0, 0x57, 0x46, 0x99, 0x91, 0x0e, 0x55, 0x44, 0x78, 0xcc, 0xde, 0x00, 0x09, 0x90, 0x91, 0x0e, 0x55, 0x44, 0x78, 0xcc, 0xde, 0x00, 0x00, 0x00, 0xbd, 0xfc, 0x00, 0xfd, 0x17, 0xe2, 0xb2, 0xa9, 0xa4, 0xdd, 0x49, 0x9c, 0x67, 0xe8, 0xa2, 0x9d, 0x82, 0xb7, 0x0e, 0x8a, 0xe9, 0xee, 0xc4, 0x0d, 0x69, 0x67, 0xf6, 0xcf, 0xd9, 0x36, 0x01, 0x58, 0xb5, 0xe8, 0x8a, 0xb4, 0x00, 0xfb, 0x04, 0xe6, 0xf4, 0xad, 0x9a, 0x49, 0xcf, 0x58, 0xba, 0x56, 0xc9, 0x70, 0x51, 0x77, 0x5c, 0xa4, 0x09, 0x0f, 0x3b, 0xca, 0x78, 0x3c, 0xa4, 0x9e, 0x89, 0x3e, 0x4d, 0x5c, 0xd8, 0x21, 0x53, 0x08}
21+
tag02Body7 = []byte{0x05, 0x13, 0x16, 0x08, 0x00, 0x48, 0x22, 0x21, 0x05, 0x19, 0x34, 0x7b, 0xc9, 0x87, 0x24, 0x64, 0x02, 0x5f, 0x99, 0xdf, 0x3e, 0xc2, 0xe0, 0x00, 0x0e, 0xd9, 0x88, 0x48, 0x92, 0xe1, 0xf7, 0xb3, 0xea, 0x4c, 0x94, 0x00, 0x91, 0x59, 0x56, 0x9b, 0x54, 0x05, 0x02, 0x5c, 0x91, 0xf4, 0xe4, 0x02, 0x1b, 0x03, 0x05, 0x0b, 0x09, 0x08, 0x07, 0x02, 0x03, 0x22, 0x02, 0x01, 0x06, 0x15, 0x0a, 0x09, 0x08, 0x0b, 0x02, 0x04, 0x16, 0x02, 0x03, 0x01, 0x02, 0x1e, 0x07, 0x02, 0x17, 0x80, 0x00, 0x00, 0xf5, 0xc0, 0x00, 0xfe, 0x38, 0x91, 0xdf, 0x23, 0x2c, 0x64, 0xc7, 0x84, 0x43, 0x8d, 0x2e, 0xea, 0xec, 0xc4, 0xa1, 0x76, 0xba, 0x51, 0x77, 0x95, 0xfd, 0x2d, 0xf0, 0xc0, 0x90, 0x17, 0x44, 0x9c, 0xbd, 0x33, 0xcb, 0x34, 0x00, 0xff, 0x6f, 0xb8, 0xbf, 0xfb, 0x03, 0x24, 0xdf, 0x15, 0x7c, 0x30, 0xcd, 0x28, 0xc3, 0x9d, 0x89, 0xb3, 0x4b, 0x4a, 0x80, 0x85, 0xb2, 0xc3, 0x43, 0xae, 0x37, 0x37, 0xe3, 0x17, 0x18, 0x12, 0x76, 0x05}
2122
)
2223

2324
const (
@@ -217,6 +218,79 @@ const (
217218
17 e2 b2 a9 a4 dd 49 9c 67 e8 a2 9d 82 b7 0e 8a e9 ee c4 0d 69 67 f6 cf d9 36 01 58 b5 e8 8a b4
218219
EdDSA compressed value s (251 bits)
219220
04 e6 f4 ad 9a 49 cf 58 ba 56 c9 70 51 77 5c a4 09 0f 3b ca 78 3c a4 9e 89 3e 4d 5c d8 21 53 08
221+
`
222+
tag02Redult7 = `Signature Packet (tag 2) (150 bytes)
223+
05 13 16 08 00 48 22 21 05 19 34 7b c9 87 24 64 02 5f 99 df 3e c2 e0 00 0e d9 88 48 92 e1 f7 b3 ea 4c 94 00 91 59 56 9b 54 05 02 5c 91 f4 e4 02 1b 03 05 0b 09 08 07 02 03 22 02 01 06 15 0a 09 08 0b 02 04 16 02 03 01 02 1e 07 02 17 80 00 00 f5 c0 00 fe 38 91 df 23 2c 64 c7 84 43 8d 2e ea ec c4 a1 76 ba 51 77 95 fd 2d f0 c0 90 17 44 9c bd 33 cb 34 00 ff 6f b8 bf fb 03 24 df 15 7c 30 cd 28 c3 9d 89 b3 4b 4a 80 85 b2 c3 43 ae 37 37 e3 17 18 12 76 05
224+
Version: 5 (draft)
225+
05
226+
Signiture Type: Positive certification of a User ID and Public-Key packet (0x13)
227+
13
228+
Public-key Algorithm: EdDSA (pub 22)
229+
16
230+
Hash Algorithm: SHA2-256 (hash 8)
231+
08
232+
Hashed Subpacket (72 bytes)
233+
22 21 05 19 34 7b c9 87 24 64 02 5f 99 df 3e c2 e0 00 0e d9 88 48 92 e1 f7 b3 ea 4c 94 00 91 59 56 9b 54 05 02 5c 91 f4 e4 02 1b 03 05 0b 09 08 07 02 03 22 02 01 06 15 0a 09 08 0b 02 04 16 02 03 01 02 1e 07 02 17 80
234+
Issuer Fingerprint (sub 33) (33 bytes)
235+
05 19 34 7b c9 87 24 64 02 5f 99 df 3e c2 e0 00 0e d9 88 48 92 e1 f7 b3 ea 4c 94 00 91 59 56 9b 54
236+
Version: 5 (need 32 octets length)
237+
Fingerprint (32 bytes)
238+
19 34 7b c9 87 24 64 02 5f 99 df 3e c2 e0 00 0e d9 88 48 92 e1 f7 b3 ea 4c 94 00 91 59 56 9b 54
239+
Signature Creation Time (sub 2): 2019-03-20T08:08:04Z
240+
5c 91 f4 e4
241+
Key Flags (sub 27) (1 bytes)
242+
03
243+
Flag: This key may be used to certify other keys.
244+
Flag: This key may be used to sign data.
245+
Preferred Symmetric Algorithms (sub 11) (4 bytes)
246+
09 08 07 02
247+
Symmetric Algorithm: AES with 256-bit key (sym 9)
248+
09
249+
Symmetric Algorithm: AES with 192-bit key (sym 8)
250+
08
251+
Symmetric Algorithm: AES with 128-bit key (sym 7)
252+
07
253+
Symmetric Algorithm: TripleDES (168 bit key derived from 192) (sym 2)
254+
02
255+
Preferred AEAD Algorithms (sub 34) (2 bytes)
256+
02 01
257+
AEAD Algorithm: OCB mode <RFC7253> (aead 2)
258+
02
259+
AEAD Algorithm: EAX mode (aead 1)
260+
01
261+
Preferred Hash Algorithms (sub 21) (5 bytes)
262+
0a 09 08 0b 02
263+
Hash Algorithm: SHA2-512 (hash 10)
264+
0a
265+
Hash Algorithm: SHA2-384 (hash 9)
266+
09
267+
Hash Algorithm: SHA2-256 (hash 8)
268+
08
269+
Hash Algorithm: SHA2-224 (hash 11)
270+
0b
271+
Hash Algorithm: SHA-1 (hash 2)
272+
02
273+
Preferred Compression Algorithms (sub 22) (3 bytes)
274+
02 03 01
275+
Compression Algorithm: ZLIB <RFC1950> (comp 2)
276+
02
277+
Compression Algorithm: BZip2 (comp 3)
278+
03
279+
Compression Algorithm: ZIP <RFC1951> (comp 1)
280+
01
281+
Features (sub 30) (1 bytes)
282+
07
283+
Flag: Modification Detection (packets 18 and 19)
284+
Flag: Unknown flag1(0x06)
285+
Key Server Preferences (sub 23) (1 bytes)
286+
80
287+
Flag: No-modify
288+
Hash left 2 bytes
289+
f5 c0
290+
EdDSA compressed value r (254 bits)
291+
38 91 df 23 2c 64 c7 84 43 8d 2e ea ec c4 a1 76 ba 51 77 95 fd 2d f0 c0 90 17 44 9c bd 33 cb 34
292+
EdDSA compressed value s (255 bits)
293+
6f b8 bf fb 03 24 df 15 7c 30 cd 28 c3 9d 89 b3 4b 4a 80 85 b2 c3 43 ae 37 37 e3 17 18 12 76 05
220294
`
221295
)
222296

@@ -234,6 +308,7 @@ func TestTag02(t *testing.T) {
234308
{tag: 2, content: tag02Body4, ktm: []byte{0x54, 0xc3, 0x01, 0xbf}, cxt: context.ModeNotSpecified, res: tag02Redult4},
235309
{tag: 2, content: tag02Body5, ktm: []byte{0x54, 0xc3, 0x01, 0xbf}, cxt: context.ModeNotSpecified, res: tag02Redult5},
236310
{tag: 2, content: tag02Body6, ktm: []byte{0x5b, 0x1a, 0x4e, 0x1d}, cxt: context.ModeNotSpecified, res: tag02Redult6},
311+
{tag: 2, content: tag02Body7, ktm: []byte{0x5b, 0x1a, 0x4e, 0x1d}, cxt: context.ModeNotSpecified, res: tag02Redult7},
237312
}
238313
for _, tc := range testCases {
239314
op := &openpgp.OpaquePacket{Tag: tc.tag, Contents: tc.content}

packet/values/aeadid.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package values
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spiegel-im-spiegel/gpgpdump/info"
7+
)
8+
9+
var aeadIDNames = Msgs{
10+
1: "EAX mode",
11+
2: "OCB mode <RFC7253>",
12+
}
13+
14+
//AEADID is AEAD Algorithm ID
15+
type AEADID byte
16+
17+
// ToItem returns Item instance
18+
func (aa AEADID) ToItem(dumpFlag bool) *info.Item {
19+
return info.NewItem(
20+
info.Name("AEAD Algorithm"),
21+
info.Value(aa.String()),
22+
info.DumpStr(DumpByteString(byte(aa), dumpFlag)),
23+
)
24+
}
25+
26+
func (aa AEADID) String() string {
27+
var name string
28+
if 100 <= aa && aa <= 110 {
29+
name = PrivateAlgName
30+
} else {
31+
name = aeadIDNames.Get(int(aa), Unknown)
32+
}
33+
return fmt.Sprintf("%s (aead %d)", name, int(aa))
34+
}
35+
36+
/* Copyright 2019 Spiegel
37+
*
38+
* Licensed under the Apache License, Version 2.0 (the "License");
39+
* you may not use this file except in compliance with the License.
40+
* You may obtain a copy of the License at
41+
*
42+
* http://www.apache.org/licenses/LICENSE-2.0
43+
*
44+
* Unless required by applicable law or agreed to in writing, software
45+
* distributed under the License is distributed on an "AS IS" BASIS,
46+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47+
* See the License for the specific language governing permissions and
48+
* limitations under the License.
49+
*/

packet/values/aeadid_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package values
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
var testAEADIDNames = []string{
9+
"Unknown (aead 0)",
10+
"EAX mode (aead 1)",
11+
"OCB mode <RFC7253> (aead 2)",
12+
"Unknown (aead 3)",
13+
}
14+
15+
func TestAEADID(t *testing.T) {
16+
for tag := 0; tag < len(testAEADIDNames); tag++ {
17+
i := AEADID(tag).ToItem(false)
18+
if i.Name != "AEAD Algorithm" {
19+
t.Errorf("AEADID.Name = \"%s\", want \"AEAD Algorithm\".", i.Name)
20+
}
21+
if i.Value != testAEADIDNames[tag] {
22+
t.Errorf("AEADID.Value = \"%s\", want \"%s\".", i.Value, testAEADIDNames[tag])
23+
}
24+
if i.Note != "" {
25+
t.Errorf("AEADID.Note = \"%s\", want \"\"", i.Note)
26+
}
27+
if i.Dump != "" {
28+
t.Errorf("AEADID.Dump = \"%s\", want \"\".", i.Dump)
29+
}
30+
}
31+
for tag := 100; tag <= 110; tag++ {
32+
i := AEADID(tag).ToItem(false)
33+
value := fmt.Sprintf("Private/Experimental algorithm (aead %d)", tag)
34+
if i.Value != value {
35+
t.Errorf("AEADID.Value = \"%s\", want \"%s\".", i.Value, value)
36+
}
37+
}
38+
}
39+
40+
/* Copyright 2019 Spiegel
41+
*
42+
* Licensed under the Apache License, Version 2.0 (the "License");
43+
* you may not use this file except in compliance with the License.
44+
* You may obtain a copy of the License at
45+
*
46+
* http://www.apache.org/licenses/LICENSE-2.0
47+
*
48+
* Unless required by applicable law or agreed to in writing, software
49+
* distributed under the License is distributed on an "AS IS" BASIS,
50+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51+
* See the License for the specific language governing permissions and
52+
* limitations under the License.
53+
*/

packet/values/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func PubVer(ver byte) *Version {
9393

9494
// SigVer is Signiture Packet Version
9595
func SigVer(ver byte) *Version {
96-
return NewVersion(ver, 4, 0)
96+
return NewVersion(ver, 4, 5)
9797
}
9898

9999
// OneSigVer is One-Pass Signature Packet Version
@@ -111,7 +111,7 @@ func SymSessKeyVer(ver byte) *Version {
111111
return NewVersion(ver, 4, 5)
112112
}
113113

114-
/* Copyright 2016-2018 Spiegel
114+
/* Copyright 2016-2019 Spiegel
115115
*
116116
* Licensed under the Apache License, Version 2.0 (the "License");
117117
* you may not use this file except in compliance with the License.

packet/values/version_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ func TestPubVer5(t *testing.T) {
193193
}
194194
}
195195

196+
func TestSigVer5(t *testing.T) {
197+
i := SigVer(5).ToItem(true)
198+
199+
if i.Note != "draft" {
200+
t.Errorf("Version.Note = \"%v\", want \"draft\"", i.Note)
201+
}
202+
}
203+
196204
func TestSigVer4(t *testing.T) {
197205
i := SigVer(4).ToItem(true)
198206

0 commit comments

Comments
 (0)