|
|
@@ -40,13 +40,6 @@ NegTokenResp ::= SEQUENCE {
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
-// Tag attribute of NegotiationToken will indicate type:
|
|
|
-// 0xa0 (160) - negTokenInit
|
|
|
-// 0xa1 (161) - negTokenResp
|
|
|
-type NegotiationToken struct {
|
|
|
- Choice asn1.RawValue
|
|
|
-}
|
|
|
-
|
|
|
type NegTokenInit struct {
|
|
|
MechTypes []asn1.ObjectIdentifier `asn1:"explicit,tag:0"`
|
|
|
ReqFlags ContextFlags `asn1:"explicit,optional,tag:1"`
|
|
|
@@ -55,7 +48,7 @@ type NegTokenInit struct {
|
|
|
}
|
|
|
|
|
|
type NegTokenResp struct {
|
|
|
- NegState asn1.Enumerated `asn1:"explicit,optional,tag:0"`
|
|
|
+ NegState asn1.Enumerated `asn1:"explicit,tag:0"`
|
|
|
SupportedMech asn1.ObjectIdentifier `asn1:"explicit,optional,tag:1"`
|
|
|
ResponseToken []byte `asn1:"explicit,optional,tag:2"`
|
|
|
MechListMIC []byte `asn1:"explicit,optional,tag:3"`
|
|
|
@@ -67,24 +60,25 @@ type NegTokenTarg NegTokenResp
|
|
|
//
|
|
|
// The boolean indicates if the response is a NegTokenInit.
|
|
|
// If error is nil and the boolean is false the response is a NegTokenResp.
|
|
|
-func (n *NegotiationToken) Unmarshal(b []byte) (bool, interface{}, error) {
|
|
|
- _, err := asn1.Unmarshal(b, n)
|
|
|
+func UnmarshalNegToken(b []byte) (bool, interface{}, error) {
|
|
|
+ var a asn1.RawValue
|
|
|
+ _, err := asn1.Unmarshal(b, &a)
|
|
|
if err != nil {
|
|
|
return false, nil, fmt.Errorf("Error unmarshalling NegotiationToken: %v", err)
|
|
|
}
|
|
|
- switch n.Choice.Tag {
|
|
|
+ switch a.Tag {
|
|
|
case 0:
|
|
|
var negToken NegTokenInit
|
|
|
- _, err = asn1.Unmarshal(b, &negToken)
|
|
|
+ _, err = asn1.Unmarshal(a.Bytes, &negToken)
|
|
|
if err != nil {
|
|
|
- return false, nil, fmt.Errorf("Error unmarshalling NegotiationToken type %d: %v", n.Choice.Tag, err)
|
|
|
+ return false, nil, fmt.Errorf("Error unmarshalling NegotiationToken type %d: %v", a.Tag, err)
|
|
|
}
|
|
|
return true, negToken, nil
|
|
|
case 1:
|
|
|
var negToken NegTokenResp
|
|
|
- _, err = asn1.Unmarshal(b, &negToken)
|
|
|
+ _, err = asn1.Unmarshal(a.Bytes, &negToken)
|
|
|
if err != nil {
|
|
|
- return false, nil, fmt.Errorf("Error unmarshalling NegotiationToken type %d: %v", n.Choice.Tag, err)
|
|
|
+ return false, nil, fmt.Errorf("Error unmarshalling NegotiationToken type %d: %v", a.Tag, err)
|
|
|
}
|
|
|
return false, negToken, nil
|
|
|
default:
|
|
|
@@ -98,19 +92,17 @@ func (n *NegTokenInit) Marshal() ([]byte, error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- //nt := NegotiationToken{
|
|
|
- // Choice: asn1.RawValue{
|
|
|
- // Tag: 0,
|
|
|
- // Class: 2,
|
|
|
- // IsCompound: true,
|
|
|
- // Bytes: b,
|
|
|
- // },
|
|
|
- //}
|
|
|
- //nb, err := asn1.Marshal(nt)
|
|
|
- //if err != nil {
|
|
|
- // return nil, err
|
|
|
- //}
|
|
|
- return b, nil
|
|
|
+ nt := asn1.RawValue{
|
|
|
+ Tag: 0,
|
|
|
+ Class: 2,
|
|
|
+ IsCompound: true,
|
|
|
+ Bytes: b,
|
|
|
+ }
|
|
|
+ nb, err := asn1.Marshal(nt)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return nb, nil
|
|
|
}
|
|
|
|
|
|
// Returns marshalled bytes of a NegotiationToken rather than the NegTokenResp
|
|
|
@@ -119,13 +111,11 @@ func (n *NegTokenResp) Marshal() ([]byte, error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- nt := NegotiationToken{
|
|
|
- Choice: asn1.RawValue{
|
|
|
- Tag: 1,
|
|
|
- Class: 2,
|
|
|
- IsCompound: true,
|
|
|
- Bytes: b,
|
|
|
- },
|
|
|
+ nt := asn1.RawValue{
|
|
|
+ Tag: 1,
|
|
|
+ Class: 2,
|
|
|
+ IsCompound: true,
|
|
|
+ Bytes: b,
|
|
|
}
|
|
|
nb, err := asn1.Marshal(nt)
|
|
|
if err != nil {
|
|
|
@@ -133,3 +123,9 @@ func (n *NegTokenResp) Marshal() ([]byte, error) {
|
|
|
}
|
|
|
return nb, nil
|
|
|
}
|
|
|
+
|
|
|
+func NewNegTokenInitKrb5() NegTokenInit {
|
|
|
+ return NegTokenInit{
|
|
|
+ MechTypes: []asn1.ObjectIdentifier{MechTypeOID_Krb5},
|
|
|
+ }
|
|
|
+}
|