Beispiel #1
0
        /// <summary>
        /// Unwraps a proxy-encoded message for further processing
        /// </summary>
        /// <param name="mode">Indicates whether the proxy message includes the length prefix or not</param>
        /// <returns>Returns the unwrapped message</returns>
        public ReadOnlyMemory <byte> UnwrapMessage(out KdcProxyMessageMode mode)
        {
            var prefix  = KerbMessage.Slice(0, 4).AsLong();
            var message = KerbMessage;

            if (prefix != KerbMessage.Length - 4)
            {
                var possibleMessageType = KrbMessage.DetectMessageType(KerbMessage);

                if (!possibleMessageType.IsValidMessageType())
                {
                    throw new InvalidOperationException(
                              $"Proxy message length {prefix} doesn't match actual message length {message.Length}"
                              );
                }

                mode = KdcProxyMessageMode.NoPrefix;
            }
            else
            {
                message = KerbMessage.Slice(4);
                mode    = KdcProxyMessageMode.IncludeLengthPrefix;
            }

            return(message);
        }
Beispiel #2
0
        public ReadOnlyMemory <byte> UnwrapMessage()
        {
            var length  = KerbMessage.Slice(0, 4).AsLong();
            var message = KerbMessage.Slice(4);

            if (length != message.Length)
            {
                throw new InvalidOperationException(
                          $"Proxy message length {length} doesn't match actual message length {message.Length}"
                          );
            }

            return(message);
        }