cifs: decoding negTokenInit with generic ASN1 decoder
Subsystems (2)
PATCH v5 1/1 cifs: decoding negTokenInit with generic ASN1 decoder
Decode negTokenInit with lib/asn1_decoder. For that, add OIDs in linux/oid_registry.h and a negTokenInit ASN1 file, "spnego_negtokeninit.asn1".
And define decoder's callback functions, which are the gssapi_this_mech for checking SPENGO oid and the neg_token_init_mech_type for getting authentication mechanisms supported by a server.
---
changes from v4:
- Append "cifs" prefix to asn1 decoder related names to avoid a link error.
changes from v3:
- Change Makefile to fix a compile error, "spnego_negtokeninit.asn1.h: No such file or directory".
changes from v2:
- Change Makefile to fix a compile error(kernel test bot).
- Add cifsproto.h into asn1.c to fix a compile warning(kernel test bot).
changes from v1:
- Select CONFIG_OID_REGISTRY
fs/cifs/Kconfig | 2 + fs/cifs/Makefile | 8 +- fs/cifs/asn1.c | 623 ++------------------------ fs/cifs/cifs_spnego_negtokeninit.asn1 | 40 ++ include/linux/oid_registry.h | 8 + 5 files changed, 93 insertions(+), 588 deletions(-) create mode 100644 fs/cifs/cifs_spnego_negtokeninit.asn1
fs/cifs/Kconfig +2 -0
@@ -19,6 +19,8 @@ config CIFS select CRYPTO_LIB_DES select KEYS select DNS_RESOLVER + select ASN1 + select OID_REGISTRY help This is the client VFS module for the SMB3 family of NAS protocols, (including support for the most recent, most secure dialect SMB3.1.1)
fs/cifs/Makefile +6 -2
@@ -6,12 +6,16 @@ ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_CIFS) += cifs.o cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ - inode.o link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ + inode.o link.o misc.o netmisc.o smbencrypt.o transport.o \ cifs_unicode.o nterr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o smb1ops.o unc.o winucase.o \ smb2ops.o smb2maperror.o smb2transport.o \ smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o \ - dns_resolve.o + dns_resolve.o cifs_spnego_negtokeninit.asn1.o asn1.o + +$(obj)/asn1.o: $(obj)/cifs_spnego_negtokeninit.asn1.h + +$(obj)/cifs_spnego_negtokeninit.asn1.o: $(obj)/cifs_spnego_negtokeninit.asn1.c $(obj)/cifs_spnego_negtokeninit.asn1.h cifs-$(CONFIG_CIFS_XATTR) += xattr.o
fs/cifs/asn1.c +37 -586
649 lines not on this page · raw message
fs/cifs/cifs_spnego_negtokeninit.asn1 new file +40 -0
@@ -0,0 +1,40 @@ +GSSAPI ::= + [APPLICATION 0] IMPLICIT SEQUENCE { + thisMech + OBJECT IDENTIFIER ({cifs_gssapi_this_mech}), + negotiationToken + NegotiationToken + } + +MechType ::= OBJECT IDENTIFIER ({cifs_neg_token_init_mech_type}) + +MechTypeList ::= SEQUENCE OF MechType + +NegHints ::= SEQUENCE { + hintName + [0] GeneralString OPTIONAL, + hintAddress + [1] OCTET STRING OPTIONAL + } + +NegTokenInit2 ::= + SEQUENCE { + mechTypes + [0] MechTypeList OPTIONAL, + reqFlags + [1] BIT STRING OPTIONAL, + mechToken + [2] OCTET STRING OPTIONAL, + negHints + [3] NegHints OPTIONAL, + mechListMIC + [3] OCTET STRING OPTIONAL + } + +NegotiationToken ::= + CHOICE { + negTokenInit + [0] NegTokenInit2, + negTokenTarg + [1] ANY + }
include/linux/oid_registry.h +8 -0
@@ -54,6 +54,10 @@ enum OID { OID_md4,/* 1.2.840.113549.2.4 */ OID_md5,/* 1.2.840.113549.2.5 */ + OID_mskrb5,/* 1.2.840.48018.1.2.2 */ + OID_krb5,/* 1.2.840.113554.1.2.2 */ + OID_krb5u2u,/* 1.2.840.113554.1.2.2.3 */ +/* Microsoft Authenticode & Software Publishing */ OID_msIndirectData,/* 1.3.6.1.4.1.311.2.1.4 */ OID_msStatementType, /* 1.3.6.1.4.1.311.2.1.11 */
@@ -62,6 +66,10 @@ enum OID { OID_msIndividualSPKeyPurpose,/* 1.3.6.1.4.1.311.2.1.21 */ OID_msOutlookExpress,/* 1.3.6.1.4.1.311.16.4 */ + OID_ntlmssp,/* 1.3.6.1.4.1.311.2.2.10 */ + + OID_spnego,/* 1.3.6.1.5.5.2 */ + OID_certAuthInfoAccess,/* 1.3.6.1.5.5.7.1.1 */ OID_sha1,/* 1.3.14.3.2.26 */ OID_id_ansip384r1, /* 1.3.132.0.34 */
Signature · 1 line
2.25.1