/// <summary> /// Create a Gss_Wrap [RFC4121] token. /// </summary> /// <param name="isEncrypted">If encrypt the message.</param> /// <param name="message">The message to be wrapped. This argument can be null.</param> /// <param name="isInitiator">If the sender is initiator.</param> /// <returns>The created Gss_Wrap token.</returns> private Token4121 GssWrap4121(bool isEncrypted, byte[] message, bool isInitiator) { var token = new Token4121(Context); var tokenHeader = new TokenHeader4121(); tokenHeader.tok_id = TOK_ID.Wrap4121; tokenHeader.flags = isEncrypted ? WrapFlag.Sealed : WrapFlag.None; if (!isInitiator) { tokenHeader.flags |= WrapFlag.SentByAcceptor; } if (Context.AcceptorSubKey != null) { tokenHeader.flags |= WrapFlag.AcceptorSubkey; } tokenHeader.filler = KerberosConstValue.TOKEN_FILLER_1_BYTE; tokenHeader.ec = 16; // [MS-KILE] The RRC field ([RFC4121] section 4.2.5) is 12 if no encryption is requested or 28 if encryption is requested. tokenHeader.rrc = isEncrypted ? (ushort)28 : (ushort)12; tokenHeader.snd_seq = Context.CurrentLocalSequenceNumber; token.TokenHeader = tokenHeader; token.Data = message; return(token); }
/// <summary> /// Create a Gss_GetMic [RFC4121] token. /// </summary> /// <param name="message">The message to be wrapped. This argument can be null.</param> /// <param name="isInitiator">If the sender is initiator.</param> /// <returns>The created Gss_GetMic token.</returns> private Token4121 GssGetMic4121(byte[] message, bool isInitiator) { var token = new Token4121(Context); var tokenHeader = new TokenHeader4121(); tokenHeader.tok_id = TOK_ID.Mic4121; tokenHeader.flags = WrapFlag.None; if (!isInitiator) { tokenHeader.flags |= WrapFlag.SentByAcceptor; } if (Context.AcceptorSubKey != null) { tokenHeader.flags |= WrapFlag.AcceptorSubkey; } tokenHeader.filler = KerberosConstValue.TOKEN_FILLER_1_BYTE; tokenHeader.ec = KerberosConstValue.TOKEN_FILLER_2_BYTE; tokenHeader.rrc = KerberosConstValue.TOKEN_FILLER_2_BYTE; tokenHeader.snd_seq = Context.CurrentLocalSequenceNumber; token.TokenHeader = tokenHeader; token.Data = message; return(token); }