2019-05-27 09:55:05 +03:00
// SPDX-License-Identifier: GPL-2.0-or-later
2005-04-17 02:20:36 +04:00
# include <linux/module.h>
# include <linux/kernel.h>
2021-06-08 17:53:14 +03:00
# include <linux/oid_registry.h>
2005-04-17 02:20:36 +04:00
# include "cifsglob.h"
# include "cifs_debug.h"
# include "cifsproto.h"
2021-06-08 17:53:14 +03:00
# include "cifs_spnego_negtokeninit.asn1.h"
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
int
decode_negTokenInit ( unsigned char * security_blob , int length ,
struct TCP_Server_Info * server )
2005-04-17 02:20:36 +04:00
{
2021-06-08 17:53:14 +03:00
if ( asn1_ber_decoder ( & cifs_spnego_negtokeninit_decoder , server ,
security_blob , length ) = = 0 )
2005-04-17 02:20:36 +04:00
return 1 ;
else
return 0 ;
2007-07-13 04:33:32 +04:00
}
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
int cifs_gssapi_this_mech ( void * context , size_t hdrlen ,
unsigned char tag , const void * value , size_t vlen )
2005-04-17 02:20:36 +04:00
{
2021-06-08 17:53:14 +03:00
enum OID oid ;
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
oid = look_up_OID ( value , vlen ) ;
if ( oid ! = OID_spnego ) {
char buf [ 50 ] ;
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
sprint_oid ( value , vlen , buf , sizeof ( buf ) ) ;
cifs_dbg ( FYI , " Error decoding negTokenInit header: unexpected OID %s \n " ,
buf ) ;
return - EBADMSG ;
2005-04-17 02:20:36 +04:00
}
2021-06-08 17:53:14 +03:00
return 0 ;
2005-04-17 02:20:36 +04:00
}
2021-06-08 17:53:14 +03:00
int cifs_neg_token_init_mech_type ( void * context , size_t hdrlen ,
unsigned char tag ,
const void * value , size_t vlen )
2005-04-17 02:20:36 +04:00
{
2021-06-08 17:53:14 +03:00
struct TCP_Server_Info * server = context ;
enum OID oid ;
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
oid = look_up_OID ( value , vlen ) ;
if ( oid = = OID_mskrb5 )
server - > sec_mskerberos = true ;
else if ( oid = = OID_krb5u2u )
server - > sec_kerberosu2u = true ;
else if ( oid = = OID_krb5 )
server - > sec_kerberos = true ;
else if ( oid = = OID_ntlmssp )
server - > sec_ntlmssp = true ;
2005-04-17 02:20:36 +04:00
else {
2021-06-08 17:53:14 +03:00
char buf [ 50 ] ;
2005-04-17 02:20:36 +04:00
2021-06-08 17:53:14 +03:00
sprint_oid ( value , vlen , buf , sizeof ( buf ) ) ;
cifs_dbg ( FYI , " Decoding negTokenInit: unsupported OID %s \n " ,
buf ) ;
2008-08-01 01:30:11 +04:00
}
2021-06-08 17:53:14 +03:00
return 0 ;
2005-04-17 02:20:36 +04:00
}