Skip to content

Commit 8956a20

Browse files
Merge pull request #11 from spiegel-im-spiegel/more-testing
Add Issuer Fingerprint signature subpacket (sub33) again.
2 parents 90bd2b3 + 2022d32 commit 8956a20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+208
-164
lines changed

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ archive:
3939
files:
4040
- LICENSE*
4141
- README*
42-
- CHANGES*
4342
- dependency.png
4443

4544
changelog:

CHANGES.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# gpgpdump - OpenPGP packet visualizer
1+
# [gpgpdump] - OpenPGP packet visualizer
22

33
[![Build Status](https://travis-ci.org/spiegel-im-spiegel/gpgpdump.svg?branch=master)](https://travis-ci.org/spiegel-im-spiegel/gpgpdump)
44
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/spiegel-im-spiegel/gpgpdump/master/LICENSE)
55
[![GitHub release](http://img.shields.io/github/release/spiegel-im-spiegel/gpgpdump.svg)](https://github.com/spiegel-im-spiegel/gpgpdump/releases/latest)
66

7-
[gpgpdump](https://github.com/spiegel-im-spiegel/gpgpdump) is a OpenPGP ([RFC 4880](https://tools.ietf.org/html/rfc4880)) packet visualizer by [golang](https://golang.org/).
7+
[gpgpdump] is a OpenPGP ([RFC 4880]) packet visualizer by [golang](https://golang.org/).
88

99
- Based on [pgpdump](https://github.com/kazu-yamamoto/pgpdump)
10+
- Provide [golang](https://golang.org/) package and command-line Interface
1011
- Output with [TOML](https://github.com/toml-lang/toml) (or [JSON](https://tools.ietf.org/html/rfc7159)) format
11-
- Support [RFC 5581](http://tools.ietf.org/html/rfc5581)
12-
- Support [RFC 6637](http://tools.ietf.org/html/rfc6637)
12+
- Support [RFC 5581] and [RFC 6637]
1313

1414
## Install
1515

@@ -26,8 +26,7 @@ $ dep ensure -add github.com/spiegel-im-spiegel/godump
2626
### Usage
2727

2828
```go
29-
const (
30-
openpgpStr = `
29+
const openpgpStr = `
3130
-----BEGIN PGP SIGNATURE-----
3231
Version: GnuPG v2
3332
@@ -36,9 +35,8 @@ T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
3635
=ZOTN
3736
-----END PGP SIGNATURE-----
3837
`
39-
)
4038

41-
info, err := gpgpdump.Parse(strings.NewReader(openpgpStr), options.NewOptions())
39+
info, err := gpgpdump.Parse(strings.NewReader(openpgpStr), options.New())
4240
if err != nil {
4341
return
4442
}
@@ -81,7 +79,7 @@ T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
8179
=ZOTN
8280
-----END PGP SIGNATURE-----
8381
84-
$ cat sig | gpgpdump
82+
$ cat sig | gpgpdump -u
8583
[[Packet]]
8684
name = "Packet"
8785
value = "Signature Packet (tag 2)"
@@ -110,7 +108,7 @@ $ cat sig | gpgpdump
110108
111109
[[Packet.Item.Item]]
112110
name = "Signature Creation Time (sub 2)"
113-
value = "2015-01-24T11:52:15+09:00"
111+
value = "2015-01-24T02:52:15Z"
114112
115113
[[Packet.Item]]
116114
name = "Unhashed Subpacket"
@@ -132,7 +130,7 @@ $ cat sig | gpgpdump
132130
name = "Multi-precision integer"
133131
note = "ECDSA s (252 bits)"
134132
135-
$ cat sig | gpgpdump -j
133+
$ cat sig | gpgpdump -j -u
136134
{
137135
"Packet": [
138136
{
@@ -163,7 +161,7 @@ $ cat sig | gpgpdump -j
163161
"Item": [
164162
{
165163
"name": "Signature Creation Time (sub 2)",
166-
"value": "2015-01-24T11:52:15+09:00"
164+
"value": "2015-01-24T02:52:15Z"
167165
}
168166
]
169167
},
@@ -202,3 +200,9 @@ dep status -dot | dot -Tpng -o dependency.png
202200
```
203201

204202
[![Dependencies](dependency.png)](dependency.png)
203+
204+
[gpgpdump]: https://github.com/spiegel-im-spiegel/gpgpdump "spiegel-im-spiegel/gpgpdump: gpgpdump - OpenPGP packet visualizer"
205+
[RFC 4880]: https://tools.ietf.org/html/rfc4880
206+
[RFC 5581]: http://tools.ietf.org/html/rfc5581
207+
[RFC 6637]: http://tools.ietf.org/html/rfc6637
208+
[dep]: https://github.com/golang/dep "golang/dep: Go dependency management tool"

cli/gpgpdump/facade/facade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func getBool(cmd *cobra.Command, name string) bool {
8383
}
8484

8585
func parseOpt(cmd *cobra.Command) *options.Options {
86-
return options.NewOptions(
86+
return options.New(
8787
options.Set(options.ArmorOpt, getBool(cmd, options.ArmorOpt)),
8888
//options.Set(options.DebugOpt, getBool(cmd, options.DebugOpt)), //not use
8989
//options.Set(options.GDumpOpt, getBool(cmd, options.GDumpOpt)), //not use

options/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type Options struct {
3838
//OptFunc is self-referential function for functional options pattern
3939
type OptFunc func(*Options)
4040

41-
// NewOptions returns a new UI instance
42-
func NewOptions(opts ...OptFunc) *Options {
41+
// New returns a new Options instance
42+
func New(opts ...OptFunc) *Options {
4343
o := &Options{}
4444
o.options(opts...)
4545
return o

options/options_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestMain(m *testing.M) {
1414
}
1515

1616
func TestNewOptions(t *testing.T) {
17-
o := NewOptions()
17+
o := New()
1818
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
1919
if o.String() != res {
2020
t.Errorf("Options() = %v, want %v.", o.String(), res)
@@ -23,7 +23,7 @@ func TestNewOptions(t *testing.T) {
2323
}
2424

2525
func TestSetAllOpt(t *testing.T) {
26-
o := NewOptions(
26+
o := New(
2727
Set(ArmorOpt, true),
2828
Set(DebugOpt, true), //not use
2929
Set(GDumpOpt, true), //not use
@@ -40,71 +40,71 @@ func TestSetAllOpt(t *testing.T) {
4040
}
4141

4242
func TestArmorOpt(t *testing.T) {
43-
o := NewOptions(Set(ArmorOpt, true))
43+
o := New(Set(ArmorOpt, true))
4444
res := "armor:true,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
4545
if o.String() != res {
4646
t.Errorf("Options() = %v, want %v.", o.String(), res)
4747
}
4848
}
4949

5050
func TestDebugOpt(t *testing.T) {
51-
o := NewOptions(Set(DebugOpt, true))
51+
o := New(Set(DebugOpt, true))
5252
res := "armor:false,debug:true,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
5353
if o.String() != res {
5454
t.Errorf("Options() = %v, want %v.", o.String(), res)
5555
}
5656
}
5757

5858
func TestGDumpOpt(t *testing.T) {
59-
o := NewOptions(Set(GDumpOpt, true))
59+
o := New(Set(GDumpOpt, true))
6060
res := "armor:false,debug:false,gdump:true,int:false,literal:false,marker:false,private:false,utc:false"
6161
if o.String() != res {
6262
t.Errorf("Options() = %v, want %v.", o.String(), res)
6363
}
6464
}
6565

6666
func TestIntegerOpt(t *testing.T) {
67-
o := NewOptions(Set(IntegerOpt, true))
67+
o := New(Set(IntegerOpt, true))
6868
res := "armor:false,debug:false,gdump:false,int:true,literal:false,marker:false,private:false,utc:false"
6969
if o.String() != res {
7070
t.Errorf("Options() = %v, want %v.", o.String(), res)
7171
}
7272
}
7373

7474
func TestLiteralOpt(t *testing.T) {
75-
o := NewOptions(Set(LiteralOpt, true))
75+
o := New(Set(LiteralOpt, true))
7676
res := "armor:false,debug:false,gdump:false,int:false,literal:true,marker:false,private:false,utc:false"
7777
if o.String() != res {
7878
t.Errorf("Options() = %v, want %v.", o.String(), res)
7979
}
8080
}
8181

8282
func TestMarkerOpt(t *testing.T) {
83-
o := NewOptions(Set(MarkerOpt, true))
83+
o := New(Set(MarkerOpt, true))
8484
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:true,private:false,utc:false"
8585
if o.String() != res {
8686
t.Errorf("Options() = %v, want %v.", o.String(), res)
8787
}
8888
}
8989

9090
func TestPrivateOpt(t *testing.T) {
91-
o := NewOptions(Set(PrivateOpt, true))
91+
o := New(Set(PrivateOpt, true))
9292
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:true,utc:false"
9393
if o.String() != res {
9494
t.Errorf("Options() = %v, want %v.", o.String(), res)
9595
}
9696
}
9797

9898
func TestUTCOpt(t *testing.T) {
99-
o := NewOptions(Set(UTCOpt, true))
99+
o := New(Set(UTCOpt, true))
100100
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:true"
101101
if o.String() != res {
102102
t.Errorf("Options() = %v, want %v.", o.String(), res)
103103
}
104104
}
105105

106106
func TestFakeOpt(t *testing.T) {
107-
o := NewOptions(Set("json", true))
107+
o := New(Set("json", true))
108108
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
109109
if o.String() != res {
110110
t.Errorf("Options() = %v, want %v.", o.String(), res)

packet/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewParser(reader io.Reader, o *options.Options) (*Parser, error) {
2828
return nil, errors.Wrap(os.ErrInvalid, "error in packet.NewParser() function (null data)")
2929
}
3030
if o == nil {
31-
o = options.NewOptions()
31+
o = options.New()
3232
}
3333
var r io.Reader
3434
var err error

packet/parser_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestParseNilOption(t *testing.T) {
101101
}
102102

103103
func TestParseNilData(t *testing.T) {
104-
opts := options.NewOptions(
104+
opts := options.New(
105105
options.Set(options.ArmorOpt, true),
106106
options.Set(options.DebugOpt, true),
107107
)
@@ -112,7 +112,7 @@ func TestParseNilData(t *testing.T) {
112112
}
113113

114114
func TestParse(t *testing.T) {
115-
opts := options.NewOptions(
115+
opts := options.New(
116116
options.Set(options.ArmorOpt, true),
117117
options.Set(options.DebugOpt, true),
118118
options.Set(options.UTCOpt, true),

packet/pubkey/parse_sig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
pubkeySigName19b = "Multi-precision integer"
2020
)
2121

22-
var cxtSig = context.NewContext(options.NewOptions(
22+
var cxtSig = context.NewContext(options.New(
2323
options.Set(options.DebugOpt, true), //not use
2424
options.Set(options.GDumpOpt, true), //not use
2525
options.Set(options.IntegerOpt, true),
@@ -31,7 +31,7 @@ var cxtSig = context.NewContext(options.NewOptions(
3131

3232
func TestPubkeySig19(t *testing.T) {
3333
parent := info.NewItem()
34-
if err := New(cxtSig, values.PubID(19), reader.NewReader(pubkeySig19)).ParseSig(parent); err != nil {
34+
if err := New(cxtSig, values.PubID(19), reader.New(pubkeySig19)).ParseSig(parent); err != nil {
3535
t.Errorf("ParseSig() = %v, want nil error.", err)
3636
}
3737
if len(parent.Items) != 2 {

packet/pubkey/pubkey_ses_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
pubkeySesNameUn = "Multi-precision integers of Unknown (pub 100)"
2828
)
2929

30-
var cxtPub = context.NewContext(options.NewOptions(
30+
var cxtPub = context.NewContext(options.New(
3131
options.Set(options.DebugOpt, true), //not use
3232
options.Set(options.GDumpOpt, true), //not use
3333
options.Set(options.IntegerOpt, true),
@@ -39,7 +39,7 @@ var cxtPub = context.NewContext(options.NewOptions(
3939

4040
func TestPubkeySes17(t *testing.T) {
4141
parent := info.NewItem()
42-
New(cxtPub, values.PubID(pubkeySes17[0]), reader.NewReader(pubkeySes17[1:])).ParseSes(parent)
42+
New(cxtPub, values.PubID(pubkeySes17[0]), reader.New(pubkeySes17[1:])).ParseSes(parent)
4343
if len(parent.Items) != 1 {
4444
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
4545
} else if parent.Items[0].Name != pubkeySesName17 {
@@ -49,7 +49,7 @@ func TestPubkeySes17(t *testing.T) {
4949

5050
func TestPubkeySes18(t *testing.T) {
5151
parent := info.NewItem()
52-
New(cxtPub, values.PubID(pubkeySes18a[0]), reader.NewReader(pubkeySes18a[1:])).ParseSes(parent)
52+
New(cxtPub, values.PubID(pubkeySes18a[0]), reader.New(pubkeySes18a[1:])).ParseSes(parent)
5353
if len(parent.Items) != 2 {
5454
t.Errorf("Count of Items = %v, want 2.", len(parent.Items))
5555
} else if parent.Items[0].Name != pubkeySesName18a {
@@ -61,15 +61,15 @@ func TestPubkeySes18(t *testing.T) {
6161

6262
func TestPubkeySes18Err1(t *testing.T) {
6363
parent := info.NewItem()
64-
New(cxtPub, values.PubID(pubkeySes18b[0]), reader.NewReader(pubkeySes18b[1:])).ParseSes(parent)
64+
New(cxtPub, values.PubID(pubkeySes18b[0]), reader.New(pubkeySes18b[1:])).ParseSes(parent)
6565
if len(parent.Items) != 0 {
6666
t.Errorf("Count of Items = %v, want 0.", len(parent.Items))
6767
}
6868
}
6969

7070
func TestPubkeySes18Err2(t *testing.T) {
7171
parent := info.NewItem()
72-
New(cxtPub, values.PubID(pubkeySes18c[0]), reader.NewReader(pubkeySes18c[1:])).ParseSes(parent)
72+
New(cxtPub, values.PubID(pubkeySes18c[0]), reader.New(pubkeySes18c[1:])).ParseSes(parent)
7373
if len(parent.Items) != 1 {
7474
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
7575
} else if parent.Items[0].Name != pubkeySesName18a {
@@ -79,7 +79,7 @@ func TestPubkeySes18Err2(t *testing.T) {
7979

8080
func TestPubkeySes19(t *testing.T) {
8181
parent := info.NewItem()
82-
New(cxtPub, values.PubID(pubkeySes19[0]), reader.NewReader(pubkeySes19[1:])).ParseSes(parent)
82+
New(cxtPub, values.PubID(pubkeySes19[0]), reader.New(pubkeySes19[1:])).ParseSes(parent)
8383
if len(parent.Items) != 1 {
8484
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
8585
} else if parent.Items[0].Name != pubkeySesName19 {
@@ -89,7 +89,7 @@ func TestPubkeySes19(t *testing.T) {
8989

9090
func TestPubkeySesUnknown(t *testing.T) {
9191
parent := info.NewItem()
92-
New(cxtPub, values.PubID(pubkeySesUn[0]), reader.NewReader(pubkeySesUn[1:])).ParseSes(parent)
92+
New(cxtPub, values.PubID(pubkeySesUn[0]), reader.New(pubkeySesUn[1:])).ParseSes(parent)
9393
if len(parent.Items) != 1 {
9494
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
9595
} else if parent.Items[0].Name != pubkeySesNameUn {

0 commit comments

Comments
 (0)