Skip to content

Commit b0ea664

Browse files
committed
Interface changes and bug fixes
* Add SPDX identifiers * Add GSS_NT_COMPOSITE_EXPORT name type * Fix address family constants * Initial extensions support * Fix typos * Return a real GssName in SecContextInfo * Support indefinite / expired time specs
1 parent c329d9d commit b0ea664

20 files changed

+228
-103
lines changed

build-tools/gen-gss-mech-oids.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
13
package main
24

35
import (
@@ -27,7 +29,9 @@ var namesToOids = []struct {
2729
{"GSS_MECH_SPKM-3", "1.3.6.1.5.5.1.3", []string{}},
2830
}
2931

30-
var codeTemplate = `package gssapi
32+
var codeTemplate = `// SPDX-License-Identifier: Apache-2.0
33+
34+
package gssapi
3135
3236
// GENERATED CODE: DO NOT EDIT
3337
@@ -140,7 +144,7 @@ func makeParams() []tmplParam {
140144
func bytesFormat(b []byte) string {
141145
strs := make([]string, len(b))
142146
for i, s := range b {
143-
strs[i] = fmt.Sprintf("0x%x", s)
147+
strs[i] = fmt.Sprintf("0x%02x", s)
144148
}
145149
return strings.Join(strs, ", ")
146150
}

build-tools/gen-gss-name-oids.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
13
package main
24

35
import (
@@ -11,6 +13,7 @@ import (
1113
"text/template"
1214
)
1315

16+
// ORDER MATTERS - must be the same as names.go!
1417
var namesToOids = []struct {
1518
name string
1619
oid string
@@ -24,6 +27,7 @@ var namesToOids = []struct {
2427
{"GSS_NO_OID", "", []string{}},
2528
{"GSS_NT_EXPORT_NAME", "1.3.6.1.5.6.4", []string{}},
2629
{"GSS_NO_NAME", "", []string{}},
30+
{"GSS_NT_COMPOSITE_EXPORT", "1.3.6.1.5.6.6", []string{}},
2731
{"GSS_KRB5_NT_PRINCIPAL_NAME", "1.2.840.113554.1.2.2.1", []string{"1.2.840.48018.1.2.2"}},
2832
{"GSS_KRB5_NT_ENTERPRISE_NAME", "1.2.840.113554.1.2.2.6", []string{}},
2933
{"GSS_KRB5_NT_X509_CERT", "1.2.840.113554.1.2.2.7", []string{}},
@@ -32,7 +36,9 @@ var namesToOids = []struct {
3236
{"GSS_SPKM_NT_STRING_UID_NAME", "1.2.840.113554.1.2.1.3", []string{}},
3337
}
3438

35-
var codeTemplate = `package gssapi
39+
var codeTemplate = `// SPDX-License-Identifier: Apache-2.0
40+
41+
package gssapi
3642
3743
// GENERATED CODE: DO NOT EDIT
3844
@@ -145,7 +151,7 @@ func makeParams() []tmplParam {
145151
func bytesFormat(b []byte) string {
146152
strs := make([]string, len(b))
147153
for i, s := range b {
148-
strs[i] = fmt.Sprintf("0x%x", s)
154+
strs[i] = fmt.Sprintf("0x%02x", s)
149155
}
150156
return strings.Join(strs, ", ")
151157
}

v3/channelbinding.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
import "net"
56

67
type GssAddressFamily int
78

89
const (
9-
GssAddrFamilyUNSPEC GssAddressFamily = 0
10-
GssAddrFamilyLOCAL GssAddressFamily = 1 << iota
10+
GssAddrFamilyUNSPEC GssAddressFamily = iota
11+
GssAddrFamilyLOCAL
1112
GssAddrFamilyINET
1213
GssAddrFamilyIMPLINK
1314
GssAddrFamilyPUP

v3/cred.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
// GSSAPI Credential Management, RFC 2743 § 2.1

v3/ctxflags.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
import "strings"
56

7+
// The ContextFlag type holds the possible the security context reqest flags
68
type ContextFlag uint32
79

8-
// GSS-API request context flags - the same as C bindings for compatibility
10+
// GSS-API context flags - the values are the same as C bindings for compatibility
11+
// The flags are used when initializing a security context and may be queried
12+
// to determine the protection levels available.
913
const (
1014
ContextFlagDeleg ContextFlag = 1 << iota // delegate credentials, not currently supported
1115
ContextFlagMutual // request remote peer authenticates itself
1216
ContextFlagReplay // enable replay detection for signed/sealed messages
1317
ContextFlagSequence // enable detection of out of sequence signed/sealed messages
14-
ContextFlagConf // confidentiality available
15-
ContextFlagInteg // integrity available
18+
ContextFlagConf // request confidentiality / condidentiality available
19+
ContextFlagInteg // request integrity / integrity available
1620
ContextFlagAnon // do not transfer initiator identity to acceptor
1721

1822
// extensions
@@ -69,6 +73,7 @@ func FlagName(f ContextFlag) string {
6973
return "Unknown"
7074
}
7175

76+
// Returns a string describing the enabled flags
7277
func (f ContextFlag) String() string {
7378
var names []string
7479
for _, flag := range FlagList(f) {

v3/ctxflags_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
import (

v3/doc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/*
4+
Package gssapi defines an interface for using the
5+
Generic Security Services Application Programming Interface
6+
for the Go programming language.
7+
8+
The interface is described in detail in the
9+
[Golang GSSAPI bindings specification].
10+
11+
This package must be used in conjunction with a GSSAPI provider
12+
that implements the interface, such as the
13+
[C bindings] provider.
14+
15+
[Golang GSSAPI bindings specification]: https://github.com/golang-auth/go-gssapi/wiki/Golang-GSSAPI-bindings-specification
16+
[C bindings]: https://github.com/golang-auth/go-gssapi-c
17+
*/
18+
package gssapi

v3/mechs.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
import "slices"
56

67
//go:generate go run ../build-tools/gen-gss-mech-oids.go -o mechs_gen.go
78

9+
// GssMech describes an available GSSAPI mechanism.
810
type GssMech interface {
911
Oid() Oid
1012
OidString() string
@@ -14,35 +16,38 @@ type GssMech interface {
1416
// gssMechImpl defines GSSAPI mechanisms
1517
type gssMechImpl int
1618

19+
// Well known GSSAPI mechanisms
1720
const (
18-
// Official Kerberos Mech (IETF)
21+
// Official Kerberos Mechanism (IETF)
1922
GSS_MECH_KRB5 gssMechImpl = iota
2023

2124
GSS_MECH_IAKERB
2225

2326
GSS_MECH_SPNEGO
2427

2528
GSS_MECH_SPKM
29+
30+
_GSS_MECH_LAST
2631
)
2732

2833
func (mech gssMechImpl) Oid() Oid {
29-
if mech > GSS_MECH_SPNEGO {
34+
if mech >= _GSS_MECH_LAST {
3035
panic(ErrBadMech)
3136
}
3237

3338
return mechs[mech].oid
3439
}
3540

3641
func (mech gssMechImpl) OidString() string {
37-
if mech > GSS_MECH_SPNEGO {
42+
if mech >= _GSS_MECH_LAST {
3843
panic(ErrBadMech)
3944
}
4045

4146
return mechs[mech].oidString
4247
}
4348

4449
func (mech gssMechImpl) String() string {
45-
if mech > GSS_MECH_SPNEGO {
50+
if mech >= _GSS_MECH_LAST {
4651
panic(ErrBadMech)
4752
}
4853

v3/mechs_gen.go

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
13
package gssapi
24

35
// GENERATED CODE: DO NOT EDIT
@@ -9,50 +11,53 @@ var mechs = []struct {
911
oid Oid
1012
altOids []Oid
1113
}{
14+
1215

1316
// 1.2.840.113554.1.2.2
14-
{GSS_MECH_KRB5,
17+
{ GSS_MECH_KRB5,
1518
"GSS_MECH_KRB5",
1619
"1.2.840.113554.1.2.2",
17-
[]byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x1, 0x2, 0x2},
20+
[]byte{ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x01, 0x02, 0x02 },
1821
[]Oid{
19-
{0x2b, 0x6, 0x1, 0x5, 0x2}, // 1.3.6.1.5.2
20-
21-
{0x2a, 0x86, 0x48, 0x82, 0xf7, 0x12, 0x1, 0x2, 0x2}, // 1.2.840.48018.1.2.2
22-
}},
22+
{0x2b, 0x06, 0x01, 0x05, 0x02 }, // 1.3.6.1.5.2
23+
24+
{0x2a, 0x86, 0x48, 0x82, 0xf7, 0x12, 0x01, 0x02, 0x02 }, // 1.2.840.48018.1.2.2
25+
}},
2326

2427
// 1.3.6.1.5.2.5
25-
{GSS_MECH_IAKERB,
28+
{ GSS_MECH_IAKERB,
2629
"GSS_MECH_IAKERB",
2730
"1.3.6.1.5.2.5",
28-
[]byte{0x2b, 0x6, 0x1, 0x5, 0x2, 0x5},
29-
[]Oid{}},
31+
[]byte{ 0x2b, 0x06, 0x01, 0x05, 0x02, 0x05 },
32+
[]Oid{ }},
3033

3134
// 1.3.6.1.5.5.2
32-
{GSS_MECH_SPNEGO,
35+
{ GSS_MECH_SPNEGO,
3336
"GSS_MECH_SPNEGO",
3437
"1.3.6.1.5.5.2",
35-
[]byte{0x2b, 0x6, 0x1, 0x5, 0x5, 0x2},
36-
[]Oid{}},
38+
[]byte{ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 },
39+
[]Oid{ }},
3740

3841
// 1.3.6.1.5.5.1.1
39-
{GSS_MECH_SPKM - 1,
42+
{ GSS_MECH_SPKM-1,
4043
"GSS_MECH_SPKM-1",
4144
"1.3.6.1.5.5.1.1",
42-
[]byte{0x2b, 0x6, 0x1, 0x5, 0x5, 0x1, 0x1},
43-
[]Oid{}},
45+
[]byte{ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x01, 0x01 },
46+
[]Oid{ }},
4447

4548
// 1.3.6.1.5.5.1.2
46-
{GSS_MECH_SPKM - 2,
49+
{ GSS_MECH_SPKM-2,
4750
"GSS_MECH_SPKM-2",
4851
"1.3.6.1.5.5.1.2",
49-
[]byte{0x2b, 0x6, 0x1, 0x5, 0x5, 0x1, 0x2},
50-
[]Oid{}},
52+
[]byte{ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x01, 0x02 },
53+
[]Oid{ }},
5154

5255
// 1.3.6.1.5.5.1.3
53-
{GSS_MECH_SPKM - 3,
56+
{ GSS_MECH_SPKM-3,
5457
"GSS_MECH_SPKM-3",
5558
"1.3.6.1.5.5.1.3",
56-
[]byte{0x2b, 0x6, 0x1, 0x5, 0x5, 0x1, 0x3},
57-
[]Oid{}},
59+
[]byte{ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x01, 0x03 },
60+
[]Oid{ }},
61+
5862
}
63+

v3/mechs_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
23
package gssapi
34

45
import (

0 commit comments

Comments
 (0)