コード例 #1
0
        public byte[] DecryptMessage(int messageLength, byte[] encryptedBytes)
        {
            using var inputBuffer  = new GssInputBuffer(encryptedBytes);
            using var outputBuffer = new GssOutputBuffer();
            var majorStatus = NativeMethods.gss_unwrap(out uint minorStatus, handle, inputBuffer, outputBuffer, out int _, out int _);

            Gss.ThrowIfError(majorStatus, minorStatus);
            return(outputBuffer.ToByteArray());
        }
コード例 #2
0
        public byte[] EncryptMessage(byte[] plainTextBytes)
        {
            using var inputBuffer  = new GssInputBuffer(plainTextBytes);
            using var outputBuffer = new GssOutputBuffer();
            var majorStatus = NativeMethods.gss_wrap(out uint minorStatus, handle, 0, 0, inputBuffer, out int _, outputBuffer);

            Gss.ThrowIfError(majorStatus, minorStatus);
            return(outputBuffer.ToByteArray());
        }
コード例 #3
0
        public byte[] Next(byte[] challenge)
        {
            using var inputToken  = new GssInputBuffer(challenge);
            using var outputToken = new GssOutputBuffer();
            const GssFlags authenticationFlags = GssFlags.GSS_C_MUTUAL_FLAG | GssFlags.GSS_C_SEQUENCE_FLAG;
            var            majorStatus         = NativeMethods.gss_init_sec_context(out var minorStatus, _credential, in handle, _servicePrincipalName, IntPtr.Zero, authenticationFlags, 0, IntPtr.Zero, inputToken, out var _, outputToken, out var _, out var _);

            Gss.ThrowIfError(majorStatus, minorStatus);

            _isInitialized = true;
            return(outputToken.ToByteArray());
        }