@@ -495,179 +495,5 @@ public void AsReqPreAuth_PkinitCertificateAccessible()
495495 Assert . AreEqual ( credCert . Thumbprint , clientCert . Thumbprint ) ;
496496 }
497497 }
498-
499- // -- TGS-REQ Channel Binding Tests --
500-
501- private static readonly byte [ ] TgsTestChannelBinding = new byte [ ]
502- {
503- 0x74 , 0x6C , 0x73 , 0x2D , 0x73 , 0x65 , 0x72 , 0x76 ,
504- 0x65 , 0x72 , 0x2D , 0x65 , 0x6E , 0x64 , 0x2D , 0x70 ,
505- 0x6F , 0x69 , 0x6E , 0x74 , 0x3A , 0xAA , 0xBB , 0xCC ,
506- 0xDD , 0xEE , 0xFF , 0x00 , 0x11 , 0x22 , 0x33 , 0x44
507- } ;
508-
509- [ TestMethod ]
510- public void KdcTgsReq_ChannelBinding_MatchingBindings_Succeeds ( )
511- {
512- // Channel bindings used by client in TGS-REQ
513- // The same channel bindings are expected by the server
514- // thus should result in a successful TGS-REQ processing
515- var bindings = new GssChannelBindings { ApplicationData = TgsTestChannelBinding } ;
516-
517- KrbAsRep asRep = RequestTgt ( cname : Upn , crealm : Realm , srealm : Realm , out KrbEncryptionKey tgtKey ) ;
518-
519- var tgsReq = KrbTgsReq . CreateTgsReq (
520- new RequestServiceTicket
521- {
522- Realm = Realm ,
523- ServicePrincipalName = "host/foo." + Realm ,
524- ChannelBindings = bindings
525- } ,
526- tgtKey , asRep , out _ ) ;
527-
528- var handler = new KdcTgsReqMessageHandler ( tgsReq . EncodeApplication ( ) , new KdcServerOptions
529- {
530- DefaultRealm = Realm ,
531- IsDebug = true ,
532- RealmLocator = realm => new FakeRealmService ( realm )
533- } ) ;
534-
535-
536- handler . ExpectedChannelBindings = bindings ;
537-
538- var results = handler . Execute ( ) ;
539-
540- var tgsRep = KrbTgsRep . DecodeApplication ( results ) ;
541- Assert . IsNotNull ( tgsRep ) ;
542- }
543-
544- [ TestMethod ]
545- public void KdcTgsReq_ChannelBinding_Mismatch_ReturnsError ( )
546- {
547- // Channel bindings used by client in TGS-REQ
548- // Different channel bindings are expected by the server
549- // thus should result in an error
550- var clientBindings = new GssChannelBindings { ApplicationData = TgsTestChannelBinding } ;
551- var serverBindings = new GssChannelBindings { ApplicationData = new byte [ ] { 0xFF , 0xFE , 0xFD } } ;
552-
553- KrbAsRep asRep = RequestTgt ( cname : Upn , crealm : Realm , srealm : Realm , out KrbEncryptionKey tgtKey ) ;
554-
555- var tgsReq = KrbTgsReq . CreateTgsReq (
556- new RequestServiceTicket
557- {
558- Realm = Realm ,
559- ServicePrincipalName = "host/foo." + Realm ,
560- ChannelBindings = clientBindings
561- } ,
562- tgtKey , asRep , out _ ) ;
563-
564- var handler = new KdcTgsReqMessageHandler ( tgsReq . EncodeApplication ( ) , new KdcServerOptions
565- {
566- DefaultRealm = Realm ,
567- IsDebug = true ,
568- RealmLocator = realm => new FakeRealmService ( realm )
569- } ) ;
570-
571- handler . ExpectedChannelBindings = serverBindings ;
572-
573- var results = handler . Execute ( ) ;
574-
575- var error = KrbError . DecodeApplication ( results ) ;
576- Assert . AreEqual ( KerberosErrorCode . KRB_ERR_GENERIC , error . ErrorCode ) ;
577- }
578-
579- [ TestMethod ]
580- public void KdcTgsReq_ChannelBinding_ServerExpectsNone_Succeeds ( )
581- {
582- // Channel bindings used by client in TGS-REQ
583- var clientBindings = new GssChannelBindings { ApplicationData = TgsTestChannelBinding } ;
584-
585- KrbAsRep asRep = RequestTgt ( cname : Upn , crealm : Realm , srealm : Realm , out KrbEncryptionKey tgtKey ) ;
586-
587- var tgsReq = KrbTgsReq . CreateTgsReq (
588- new RequestServiceTicket
589- {
590- Realm = Realm ,
591- ServicePrincipalName = "host/foo." + Realm ,
592- ChannelBindings = clientBindings
593- } ,
594- tgtKey , asRep , out _ ) ;
595-
596- // Server does not expect channel bindings
597- var handler = new KdcTgsReqMessageHandler ( tgsReq . EncodeApplication ( ) , new KdcServerOptions
598- {
599- DefaultRealm = Realm ,
600- IsDebug = true ,
601- RealmLocator = realm => new FakeRealmService ( realm )
602- // ExpectedChannelBindings = null
603- } ) ;
604-
605- var results = handler . Execute ( ) ;
606-
607- // Should succeed even though client included channel bindings as the server does not require them
608- var tgsRep = KrbTgsRep . DecodeApplication ( results ) ;
609- Assert . IsNotNull ( tgsRep ) ;
610- }
611-
612- [ TestMethod ]
613- public void KdcTgsReq_ChannelBinding_ServerExpects_ClientOmits_ReturnsError ( )
614- {
615- // Server expects channel bindings but client omits them in TGS-REQ
616- var serverBindings = new GssChannelBindings { ApplicationData = TgsTestChannelBinding } ;
617-
618- KrbAsRep asRep = RequestTgt ( cname : Upn , crealm : Realm , srealm : Realm , out KrbEncryptionKey tgtKey ) ;
619-
620- var tgsReq = KrbTgsReq . CreateTgsReq (
621- new RequestServiceTicket
622- {
623- Realm = Realm ,
624- ServicePrincipalName = "host/foo." + Realm
625- } ,
626- tgtKey , asRep , out _ ) ;
627-
628- // Server expects channel bindings
629- var handler = new KdcTgsReqMessageHandler ( tgsReq . EncodeApplication ( ) , new KdcServerOptions
630- {
631- DefaultRealm = Realm ,
632- IsDebug = true ,
633- RealmLocator = realm => new FakeRealmService ( realm )
634- } ) ;
635-
636- handler . ExpectedChannelBindings = serverBindings ;
637-
638- var results = handler . Execute ( ) ;
639-
640- // Expect an error due to missing channel bindings in client
641- var error = KrbError . DecodeApplication ( results ) ;
642- Assert . AreEqual ( KerberosErrorCode . KRB_ERR_GENERIC , error . ErrorCode ) ;
643- }
644-
645- [ TestMethod ]
646- public void KdcTgsReq_NoChannelBindings_Succeeds ( )
647- {
648- // Neither client nor server uses channel bindings
649- // should succeed without error
650- KrbAsRep asRep = RequestTgt ( cname : Upn , crealm : Realm , srealm : Realm , out KrbEncryptionKey tgtKey ) ;
651-
652- var tgsReq = KrbTgsReq . CreateTgsReq (
653- new RequestServiceTicket
654- {
655- Realm = Realm ,
656- ServicePrincipalName = "host/foo." + Realm
657- } ,
658- tgtKey , asRep , out _ ) ;
659-
660- var handler = new KdcTgsReqMessageHandler ( tgsReq . EncodeApplication ( ) , new KdcServerOptions
661- {
662- DefaultRealm = Realm ,
663- IsDebug = true ,
664- RealmLocator = realm => new FakeRealmService ( realm )
665- } ) ;
666-
667- var results = handler . Execute ( ) ;
668-
669- var tgsRep = KrbTgsRep . DecodeApplication ( results ) ;
670- Assert . IsNotNull ( tgsRep ) ;
671- }
672498 }
673499}
0 commit comments