diff --git a/Bruce/Bruce.csproj b/Bruce/Bruce.csproj
index d5888e61..3fc4a585 100644
--- a/Bruce/Bruce.csproj
+++ b/Bruce/Bruce.csproj
@@ -12,6 +12,8 @@
Kerberos.NET Command Line Tool
A command line tool that manages the cross-platform, managed-code Kerberos Ticket parsing, validation, and authentication library Kerberos.NET.
security kerberos
+ 9
+ WINDOWS
@@ -38,6 +40,9 @@
+
+
+
diff --git a/Bruce/CommandLine/KerberosDumpCommand.cs b/Bruce/CommandLine/KerberosDumpCommand.cs
index 142f17b5..0133689b 100644
--- a/Bruce/CommandLine/KerberosDumpCommand.cs
+++ b/Bruce/CommandLine/KerberosDumpCommand.cs
@@ -4,8 +4,10 @@
// -----------------------------------------------------------------------
using System.Threading.Tasks;
+#if WINDOWS
using System.Windows.Forms;
using KerbDump;
+#endif
namespace Kerberos.NET.CommandLine
{
@@ -14,8 +16,10 @@ public class KerberosDumpCommand : BaseCommand
{
static KerberosDumpCommand()
{
+#if WINDOWS
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
+#endif
}
public KerberosDumpCommand(CommandLineParameters parameters)
@@ -34,6 +38,7 @@ public override Task Execute()
return Task.FromResult(false);
}
+#if WINDOWS
using (var form = new DecoderForm()
{
Ticket = this.Ticket,
@@ -42,6 +47,7 @@ public override Task Execute()
{
Application.Run(form);
}
+#endif
return Task.FromResult(true);
}
diff --git a/Bruce/Dns/PlatformIndependentDnsClient.cs b/Bruce/Dns/PlatformIndependentDnsClient.cs
index 765b3448..bc3373b5 100644
--- a/Bruce/Dns/PlatformIndependentDnsClient.cs
+++ b/Bruce/Dns/PlatformIndependentDnsClient.cs
@@ -11,6 +11,8 @@ internal class PlatformIndependentDnsClient : IKerberosDnsQuery
{
private static readonly WindowsDnsQuery WindowsDns = new WindowsDnsQuery();
+ public bool Debug { get; set; }
+
public async Task> Query(string query, DnsRecordType type)
{
if (WindowsDns.IsSupported)
diff --git a/Kerberos.NET/Dns/DnsQuery.cs b/Kerberos.NET/Dns/DnsQuery.cs
index 58b0834a..a7e201ad 100644
--- a/Kerberos.NET/Dns/DnsQuery.cs
+++ b/Kerberos.NET/Dns/DnsQuery.cs
@@ -22,13 +22,16 @@ static DnsQuery()
if (OSPlatform.IsWindows)
{
QueryImplementation = new WindowsDnsQuery();
+ return;
}
+ //for now assume it's POSIX
+ QueryImplementation = new POSIXDnsQuery();
}
public static bool Debug
{
- get => DnsQueryWin32.Debug;
- set => DnsQueryWin32.Debug = value;
+ get => QueryImplementation.Debug;
+ set => QueryImplementation.Debug = value;
}
///
diff --git a/Kerberos.NET/Dns/DnsQueryPOSIX.cs b/Kerberos.NET/Dns/DnsQueryPOSIX.cs
new file mode 100644
index 00000000..eb4fc30f
--- /dev/null
+++ b/Kerberos.NET/Dns/DnsQueryPOSIX.cs
@@ -0,0 +1,232 @@
+// -----------------------------------------------------------------------
+// Licensed to The .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// -----------------------------------------------------------------------
+
+using System;
+using System.Buffers;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Kerberos.NET.Dns
+{
+ public unsafe class DnsQueryPOSIX
+ {
+ private const int NS_PACKETSZ = 512;
+ private const int NS_MAXDNAME = 1025;
+
+ private const string LIBC = "libc.so";
+
+ [DllImport(LIBC, EntryPoint = "res_query")]
+ private static extern short ResQuery(
+ [MarshalAs(UnmanagedType.LPStr)] string dname,
+ NsClass @class,
+ DnsRecordType type,
+ char[] answer,
+ int anslen
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_initparse")]
+ private static extern short NsInitParse(
+ // [MarshalAs(UnmanagedType.LPStr)] string msg,
+ char[] msg,
+ short msglen,
+ NsMsg* handle
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_msg_count")]
+ private static extern ushort NsMsgCount(
+ NsMsg handle,
+ NsSect section
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_parserr")]
+ private static extern short NsParserr(
+ NsMsg* handle,
+ NsSect section,
+ short rrnum,
+ NsRr* rr
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_rr_type")]
+ private static extern DnsRecordType NsRrType(
+ NsRr rr
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_msg_base")]
+ private static extern string NsMsgBase(
+ NsMsg handle
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_msg_end")]
+ private static extern string NsMsgEnd(
+ NsMsg handle
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_rr_rdata")]
+ private static extern string NsRrRdata(
+ NsRr rr
+ );
+
+ [DllImport(LIBC, EntryPoint = "dn_expand")]
+ private static extern short DnExpand(
+ [MarshalAs(UnmanagedType.LPStr)] string msg,
+ [MarshalAs(UnmanagedType.LPStr)] string eomorig,
+ [MarshalAs(UnmanagedType.LPStr)] string comp_dn,
+ StringBuilder exp_dn,
+ short length
+ );
+
+ [DllImport(LIBC, EntryPoint = "ns_rr_name")]
+ private static extern string NsRrName(
+ NsRr rr
+ );
+
+ [DllImport(LIBC, EntryPoint = "inet_ntoa")]
+ private static extern string InetNToA(
+ InAddr @in
+ );
+
+ public static IReadOnlyCollection QuerySrvRecord(
+ string query,
+ DnsRecordType type,
+ DnsQueryOptions options = DnsQueryOptions.BypassCache)
+ {
+ var list = new List();
+ var buffer = new char[NS_PACKETSZ];
+
+ short respLen = -1;
+ if ((respLen = ResQuery(query, NsClass.NsCIn, type, buffer, NS_PACKETSZ)) < 0)
+ throw new Exception($"Query for {query} failed!");
+
+ NsMsg handle;
+ if (NsInitParse(buffer, respLen, &handle) < 0)
+ throw new Exception("Failed to parse response buffer!");
+
+ var count = NsMsgCount(handle, NsSect.NsSAn);
+ Debug.WriteLine($"{count} records returned in the answer section.");
+
+ for (short i = 0; i < count; i++)
+ {
+ NsRr rr;
+ if (NsParserr(&handle, NsSect.NsSAn, i, &rr) < 0)
+ throw new Exception("ns_parserr: TODO strerror");
+
+ if (NsRrType(rr) != DnsRecordType.SRV) continue;
+
+ var name = new StringBuilder(1025);
+ short ret;
+ if ((ret = DnExpand(NsMsgBase(handle),
+ NsMsgEnd(handle),
+ NsRrRdata(rr) + 6,
+ name,
+ 1025)) < 0)
+ throw new Exception($"Failed to uncompress name ({ret})");
+
+ Debug.WriteLine(name);
+
+ var p = NsRrRdata(rr);
+ var ip = new InAddr
+ {
+ s_addr = ((uint) p[3] << 24) | ((uint) p[2] << 16) | ((uint) p[1] << 8) | p[0]
+ };
+
+ list.Add(new DnsRecord
+ {
+ Target = InetNToA(ip),
+ Name = rr.name.ToString(),
+ //Port =
+ //Priority =
+ TimeToLive = (int) rr.ttl,
+ Type = rr.type,
+ //Weight = rr.
+ });
+ }
+
+ for (short i = 0; i < NsMsgCount(handle, NsSect.NsSAr); i++)
+ {
+ NsRr rr;
+ if (NsParserr(&handle, NsSect.NsSAr, i, &rr) < 0)
+ throw new Exception("ns_parserr: TODO strerror");
+
+ if (NsRrType(rr) != DnsRecordType.A) continue;
+
+ var p = NsRrRdata(rr);
+ var ip = new InAddr
+ {
+ s_addr = ((uint) p[3] << 24) | ((uint) p[2] << 16) | ((uint) p[1] << 8) | p[0]
+ };
+
+ Debug.WriteLine($"{NsRrName(rr)} has address {InetNToA(ip)}");
+
+ list.Add(new DnsRecord
+ {
+ Type = rr.type,
+ Name = rr.name.ToString(),
+ Target = InetNToA(ip)
+ });
+ }
+
+ return list;
+ }
+
+ private struct InAddr
+ {
+ public uint s_addr;
+ }
+
+ private struct NsRr
+ {
+ [MarshalAs(UnmanagedType.LPArray, SizeConst = NS_PACKETSZ)]
+ public char[] name;
+ public DnsRecordType type;
+ public ushort rr_class;
+ public uint ttl;
+ public ushort rdlength;
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string rdata;
+ }
+
+ private enum NsSect
+ {
+ NsSQd = 0, /*%< Query: Question. */
+ NsSZn = 0, /*%< Update: Zone. */
+ NsSAn = 1, /*%< Query: Answer. */
+ NsSPr = 1, /*%< Update: Prerequisites. */
+ NsSNs = 2, /*%< Query: Name servers. */
+ NsSUd = 2, /*%< Update: Update. */
+ NsSAr = 3, /*%< Query|Update: Additional records. */
+ NsSMax = 4
+ }
+
+ private struct NsMsg
+ {
+ [MarshalAs(UnmanagedType.LPStr)] public string _msg, _eom;
+ public ushort _id, _flags;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int) NsSect.NsSMax)]
+ public ushort[] _counts;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int) NsSect.NsSMax)]
+ public string[] _sections;
+ public NsSect _sect;
+ public short _rrnum;
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string _msg_ptr;
+ }
+
+ private enum NsClass : ushort
+ {
+ NsCInvalid,
+ NsCIn,
+ NsC2,
+ NsCChaos,
+ NsCHs,
+ NsCNone = 254,
+ NsCAny,
+ NsCMax = 65535
+ }
+ }
+}
diff --git a/Kerberos.NET/Dns/IKerberosDnsQuery.cs b/Kerberos.NET/Dns/IKerberosDnsQuery.cs
index 2ef7a9c9..b9891837 100644
--- a/Kerberos.NET/Dns/IKerberosDnsQuery.cs
+++ b/Kerberos.NET/Dns/IKerberosDnsQuery.cs
@@ -13,6 +13,8 @@ namespace Kerberos.NET.Dns
///
public interface IKerberosDnsQuery
{
+ public bool Debug { get; set; }
+
///
/// Make a DNS lookup for the provided query and record type.
///
diff --git a/Kerberos.NET/Dns/POSIXDnsQuery.cs b/Kerberos.NET/Dns/POSIXDnsQuery.cs
new file mode 100644
index 00000000..d3b6a671
--- /dev/null
+++ b/Kerberos.NET/Dns/POSIXDnsQuery.cs
@@ -0,0 +1,31 @@
+// -----------------------------------------------------------------------
+// Licensed to The .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// -----------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Kerberos.NET.Dns
+{
+ public class POSIXDnsQuery : IKerberosDnsQuery
+ {
+ public bool Debug { get; set; }
+
+ public bool IsSupported => OSPlatform.IsLinux;
+
+ public Task> Query(string query, DnsRecordType type)
+ {
+ if (!IsSupported)
+ {
+ throw new InvalidOperationException(
+ "The POSIX DNS query implementation is not supported outside of POSIX-compliant systems");
+ }
+
+ var result = DnsQueryWin32.QuerySrvRecord(query, type);
+
+ return Task.FromResult(result);
+ }
+ }
+}
diff --git a/Kerberos.NET/Kerberos.NET.csproj b/Kerberos.NET/Kerberos.NET.csproj
index 44e65959..db31aec9 100644
--- a/Kerberos.NET/Kerberos.NET.csproj
+++ b/Kerberos.NET/Kerberos.NET.csproj
@@ -5,6 +5,7 @@
A cross-platform, managed-code Kerberos Ticket parsing, validation, and authentication library.
security kerberos
true
+ 9
diff --git a/Samples/KerbDumpCore/KerbDumpCore.csproj b/Samples/KerbDumpCore/KerbDumpCore.csproj
index 8b67945e..14b286a5 100644
--- a/Samples/KerbDumpCore/KerbDumpCore.csproj
+++ b/Samples/KerbDumpCore/KerbDumpCore.csproj
@@ -4,25 +4,27 @@
Library
netcoreapp3.1
true
+ true
false
KerbDumpCore
KerbDump
+ 9
-
+
-
+
-
+
-
+
diff --git a/Tests/Tests.Kerberos.NET/BaseTest.cs b/Tests/Tests.Kerberos.NET/BaseTest.cs
index 2de16550..18e78820 100644
--- a/Tests/Tests.Kerberos.NET/BaseTest.cs
+++ b/Tests/Tests.Kerberos.NET/BaseTest.cs
@@ -119,7 +119,7 @@ public const ValidationActions DefaultActions
"AFffP2PNqYn95dA4HD/On0QpOkNykZ3JBzSLnEr0+lo7bgZOTAF5m1IBwwEMdMhZRYudg4/MRPgKSzAx2cDfFfqe3c5a/e8IjYdZHI3fmQa1rPXn5XQ03aw9YJNkW1VNb0+n5JGR4Jge" +
"C12oQyIh4DSu3XGvlXi+swg90=";
- protected static readonly string BasePath = $"data{Path.DirectorySeparatorChar}";
+ protected static readonly string BasePath = $"Data{Path.DirectorySeparatorChar}";
protected static byte[] ReadDataFile(string name)
{
diff --git a/Tests/Tests.Kerberos.NET/Client/Krb5CredentialCacheTests.cs b/Tests/Tests.Kerberos.NET/Client/Krb5CredentialCacheTests.cs
index 1b40561e..e34fd049 100644
--- a/Tests/Tests.Kerberos.NET/Client/Krb5CredentialCacheTests.cs
+++ b/Tests/Tests.Kerberos.NET/Client/Krb5CredentialCacheTests.cs
@@ -10,6 +10,7 @@
using Kerberos.NET.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
+using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -18,7 +19,7 @@ namespace Tests.Kerberos.NET
[TestClass]
public class Krb5CredentialCacheTests : BaseTest
{
- protected static string FilePath => $"{BasePath}cache\\krb5cc";
+ protected static string FilePath => Path.Combine(BasePath, "Cache", "krb5cc");
[TestMethod]
public void ParseFile()
@@ -34,7 +35,7 @@ public void ParseFile()
[TestMethod]
public void ParseFromBytes()
{
- var cacheBytes = ReadDataFile("cache\\krb5cc");
+ var cacheBytes = ReadDataFile(Path.Combine("Cache", "krb5cc"));
using (var cache = new Krb5TicketCache(cacheBytes))
{
@@ -61,7 +62,7 @@ public void ParseRoundTrip()
var serialized = cache.Serialize();
- var originalBytes = ReadDataFile("cache\\krb5cc");
+ var originalBytes = ReadDataFile(Path.Combine("Cache", "krb5cc"));
Assert.IsTrue(originalBytes.SequenceEqual(serialized));
}
diff --git a/Tests/Tests.Kerberos.NET/Configuration/Krb5ConfTests.cs b/Tests/Tests.Kerberos.NET/Configuration/Krb5ConfTests.cs
index e318f6f3..f6b3ea0d 100644
--- a/Tests/Tests.Kerberos.NET/Configuration/Krb5ConfTests.cs
+++ b/Tests/Tests.Kerberos.NET/Configuration/Krb5ConfTests.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using Kerberos.NET.Configuration;
@@ -250,7 +251,7 @@ public void ParseListWithComment()
private static ConfigurationSectionList ParseConfiguration()
{
- var file = ReadDataFile("Configuration\\krb5.conf");
+ var file = ReadDataFile(Path.Combine("Configuration", "krb5.conf"));
return Krb5ConfigurationSerializer.Deserialize(Encoding.Default.GetString(file));
}
diff --git a/Tests/Tests.Kerberos.NET/Crypto/CryptoTests.cs b/Tests/Tests.Kerberos.NET/Crypto/CryptoTests.cs
index 11be0856..8e3f19fb 100644
--- a/Tests/Tests.Kerberos.NET/Crypto/CryptoTests.cs
+++ b/Tests/Tests.Kerberos.NET/Crypto/CryptoTests.cs
@@ -104,6 +104,9 @@ public void Aes256Roundtrip()
[TestMethod]
public void RC4Roundtrip()
{
+ if(OSPlatform.IsLinux)
+ Assert.Inconclusive("MD4 operations are not supported by Linux");
+
var data = new Memory(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 });
var key = CreateKey();
@@ -501,4 +504,4 @@ protected override Task Validate(DecryptedKrbApReq decryptedToken)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Crypto/KeyTableTests.cs b/Tests/Tests.Kerberos.NET/Crypto/KeyTableTests.cs
index 2b65f80e..8a58ca89 100644
--- a/Tests/Tests.Kerberos.NET/Crypto/KeyTableTests.cs
+++ b/Tests/Tests.Kerberos.NET/Crypto/KeyTableTests.cs
@@ -169,6 +169,9 @@ public void KeyGeneration()
[TestMethod]
public async Task Authenticator_SerializedKeytab()
{
+ if(OSPlatform.IsLinux)
+ Assert.Inconclusive("MD4 operations are not supported by Linux");
+
var key = new KerberosKey(
password: "P@ssw0rd!",
principalName: new PrincipalName(
diff --git a/Tests/Tests.Kerberos.NET/Dns/DnsTests.cs b/Tests/Tests.Kerberos.NET/Dns/DnsTests.cs
index c001299f..181d50c4 100644
--- a/Tests/Tests.Kerberos.NET/Dns/DnsTests.cs
+++ b/Tests/Tests.Kerberos.NET/Dns/DnsTests.cs
@@ -82,6 +82,8 @@ private class FakeDnsImplementation : IKerberosDnsQuery
{
public bool WasCalled { get; set; }
+ public bool Debug { get; set; }
+
public Task> Query(string query, DnsRecordType type)
{
this.WasCalled = true;
diff --git a/Tests/Tests.Kerberos.NET/End2End/ClientToKdcE2ETests.cs b/Tests/Tests.Kerberos.NET/End2End/ClientToKdcE2ETests.cs
index 555b9982..e4371fa5 100644
--- a/Tests/Tests.Kerberos.NET/End2End/ClientToKdcE2ETests.cs
+++ b/Tests/Tests.Kerberos.NET/End2End/ClientToKdcE2ETests.cs
@@ -61,6 +61,9 @@ await RequestAndValidateTickets(
[TestMethod]
public async Task E2E_ClientWantsWeakCrypto_AllowWeak()
{
+ if(OSPlatform.IsLinux)
+ Assert.Inconclusive("MD4 operations are not supported by Linux");
+
var port = NextPort();
using (var listener = StartListener(port, allowWeakCrypto: true))
diff --git a/Tests/Tests.Kerberos.NET/Messages/AllMessagesTests.cs b/Tests/Tests.Kerberos.NET/Messages/AllMessagesTests.cs
index 64beec55..9bee2162 100644
--- a/Tests/Tests.Kerberos.NET/Messages/AllMessagesTests.cs
+++ b/Tests/Tests.Kerberos.NET/Messages/AllMessagesTests.cs
@@ -5,6 +5,7 @@
using System;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using Kerberos.NET.Crypto;
using Kerberos.NET.Entities;
@@ -18,7 +19,7 @@ public class AllMessagesTests : BaseTest
[TestMethod]
public void Message_AsRep()
{
- var file = ReadDataFile("messages\\as-rep");
+ var file = ReadDataFile(Path.Combine("Messages", "as-rep"));
var decoded = TestSimpleRoundtrip(
"as-rep",
@@ -33,7 +34,7 @@ public void Message_AsRep()
[TestMethod]
public void Message_AsReq()
{
- var file = ReadDataFile("messages\\as-req");
+ var file = ReadDataFile(Path.Combine("Messages", "as-req"));
var decoded = TestSimpleRoundtrip(
"as-req",
@@ -48,7 +49,7 @@ public void Message_AsReq()
[TestMethod]
public void Message_AsReqPreAuth()
{
- var file = ReadDataFile("messages\\as-req-preauth");
+ var file = ReadDataFile(Path.Combine("Messages", "as-req-preauth"));
var decoded = TestSimpleRoundtrip(
"as-req-preauth",
@@ -63,7 +64,7 @@ public void Message_AsReqPreAuth()
[TestMethod]
public void Message_KrbErrorPreAuth()
{
- var file = ReadDataFile("messages\\krb-error-preauth-required");
+ var file = ReadDataFile(Path.Combine("Messages", "krb-error-preauth-required"));
var decoded = TestSimpleRoundtrip(
"krb-error-preauth-required",
@@ -78,7 +79,7 @@ public void Message_KrbErrorPreAuth()
[TestMethod]
public void Message_TgsRep()
{
- var file = ReadDataFile("messages\\tgs-rep-testuser-host-app03");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-rep-testuser-host-app03"));
var decoded = TestSimpleRoundtrip(
"tgs-rep-testuser-host-app03",
@@ -93,7 +94,7 @@ public void Message_TgsRep()
[TestMethod]
public void Message_TgsRepKrbTgtRenew()
{
- var file = ReadDataFile("messages\\tgs-rep-testuser-krbtgt-renew");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-rep-testuser-krbtgt-renew"));
var decoded = TestSimpleRoundtrip(
"tgs-rep-testuser-krbtgt-renew",
@@ -108,7 +109,7 @@ public void Message_TgsRepKrbTgtRenew()
[TestMethod]
public void Message_TgsReq()
{
- var file = ReadDataFile("messages\\tgs-req-testuser-host-app03");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-req-testuser-host-app03"));
var decoded = TestSimpleRoundtrip(
"tgs-req-testuser-host-app03",
@@ -123,7 +124,7 @@ public void Message_TgsReq()
[TestMethod]
public void Message_TgsReqKrbTgtRenew()
{
- var file = ReadDataFile("messages\\tgs-req-testuser-krbtgt-renew");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-req-testuser-krbtgt-renew"));
var decoded = TestSimpleRoundtrip(
"tgs-req-testuser-krbtgt-renew",
@@ -138,7 +139,7 @@ public void Message_TgsReqKrbTgtRenew()
[TestMethod]
public void Message_TgsReqS4uSelf()
{
- var file = ReadDataFile("messages\\tgs-req-app2-s4u-self");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-req-app2-s4u-self"));
var decoded = TestSimpleRoundtrip(
"tgs-req-app2-s4u-self",
@@ -153,7 +154,7 @@ public void Message_TgsReqS4uSelf()
[TestMethod]
public void Message_TgsRepS4uSelf()
{
- var file = ReadDataFile("messages\\tgs-rep-app2-s4u-self");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-rep-app2-s4u-self"));
var decoded = TestSimpleRoundtrip(
"tgs-rep-app2-s4u-self",
@@ -168,7 +169,7 @@ public void Message_TgsRepS4uSelf()
[TestMethod]
public void Message_TgsReqS4uProxy()
{
- var file = ReadDataFile("messages\\tgs-req-app2-s4u-proxy");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-req-app2-s4u-proxy"));
var decoded = TestSimpleRoundtrip(
"tgs-req-app2-s4u-proxy",
@@ -183,7 +184,7 @@ public void Message_TgsReqS4uProxy()
[TestMethod]
public void Message_TgsRepS4uProxy()
{
- var file = ReadDataFile("messages\\tgs-rep-app2-s4u-proxy");
+ var file = ReadDataFile(Path.Combine("Messages", "tgs-rep-app2-s4u-proxy"));
var decoded = TestSimpleRoundtrip(
"tgs-rep-app2-s4u-proxy",
@@ -210,4 +211,4 @@ private static T TestSimpleRoundtrip(string key, byte[] value, Func 0);
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Messages/KrbAsReqTests.cs b/Tests/Tests.Kerberos.NET/Messages/KrbAsReqTests.cs
index 690cadea..6fbe8f0a 100644
--- a/Tests/Tests.Kerberos.NET/Messages/KrbAsReqTests.cs
+++ b/Tests/Tests.Kerberos.NET/Messages/KrbAsReqTests.cs
@@ -4,6 +4,7 @@
// -----------------------------------------------------------------------
using System;
+using System.IO;
using System.Linq;
using System.Text;
using Kerberos.NET.Client;
@@ -34,7 +35,7 @@ public void AsReqRoundtripParse()
[TestMethod]
public void ParseAsReqApplicationMessage()
{
- var asReqBin = ReadDataFile("messages\\as-req").Skip(4).ToArray();
+ var asReqBin = ReadDataFile(Path.Combine("Messages", "as-req")).Skip(4).ToArray();
var asReq = KrbAsReq.DecodeApplication(asReqBin);
@@ -49,7 +50,7 @@ public void ParseAsReqApplicationMessage()
[TestMethod]
public void DecryptAsReqApplicationMessage()
{
- var asReqBin = ReadDataFile("messages\\as-req-preauth").Skip(4).ToArray();
+ var asReqBin = ReadDataFile(Path.Combine("Messages", "as-req-preauth")).Skip(4).ToArray();
var asReq = KrbAsReq.DecodeApplication(asReqBin);
@@ -160,4 +161,4 @@ public void GenerateAsReqApplicationMessage()
Assert.IsNotNull(roundtrip);
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Messages/KrbErrorTests.cs b/Tests/Tests.Kerberos.NET/Messages/KrbErrorTests.cs
index 94e8260e..89f626db 100644
--- a/Tests/Tests.Kerberos.NET/Messages/KrbErrorTests.cs
+++ b/Tests/Tests.Kerberos.NET/Messages/KrbErrorTests.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using Kerberos.NET.Crypto;
using Kerberos.NET.Entities;
@@ -18,7 +19,7 @@ public class KrbErrorTests : BaseTest
[TestMethod]
public void ErrorPreAuthRoundtrip()
{
- var krbErrBin = ReadDataFile("messages\\krb-error-preauth-required").Skip(4).ToArray();
+ var krbErrBin = ReadDataFile(Path.Combine("Messages", "krb-error-preauth-required")).Skip(4).ToArray();
var err = KrbError.DecodeApplication(krbErrBin);
@@ -30,7 +31,7 @@ public void ErrorPreAuthRoundtrip()
[TestMethod]
public void KrbErrorParseEtypeInfo()
{
- var krbErrBin = ReadDataFile("messages\\krb-error-preauth-required").Skip(4).ToArray();
+ var krbErrBin = ReadDataFile(Path.Combine("Messages", "krb-error-preauth-required")).Skip(4).ToArray();
var err = KrbError.DecodeApplication(krbErrBin);
@@ -87,4 +88,4 @@ public void KrbErrorRoundtrip()
Assert.AreEqual(err.Realm, decoded.Realm);
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Messages/KrbTgsReqTests.cs b/Tests/Tests.Kerberos.NET/Messages/KrbTgsReqTests.cs
index 13cf8fb1..b085da50 100644
--- a/Tests/Tests.Kerberos.NET/Messages/KrbTgsReqTests.cs
+++ b/Tests/Tests.Kerberos.NET/Messages/KrbTgsReqTests.cs
@@ -3,6 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// -----------------------------------------------------------------------
+using System.IO;
using System.Linq;
using System.Security;
using Kerberos.NET.Crypto;
@@ -23,7 +24,7 @@ public class KrbTgsReqTests : BaseTest
[TestMethod]
public void TgsParse()
{
- var tgsReqBytes = ReadDataFile("messages\\tgs-req-testuser-host-app03").Skip(4).ToArray();
+ var tgsReqBytes = ReadDataFile(Path.Combine("Messages", "tgs-req-testuser-host-app03")).Skip(4).ToArray();
var tgsReq = KrbTgsReq.DecodeApplication(tgsReqBytes);
@@ -64,7 +65,7 @@ public void ValidateS4uSelfPacOptions()
private static void RetrieveS4u(out KrbTgsReq tgsReq, out KrbEncTicketPart krbtgt)
{
- var tgsReqBytes = ReadDataFile("messages\\tgs-req-app2-s4u-self").Skip(4).ToArray();
+ var tgsReqBytes = ReadDataFile(Path.Combine("Messages", "tgs-req-app2-s4u-self")).Skip(4).ToArray();
tgsReq = KrbTgsReq.DecodeApplication(tgsReqBytes);
Assert.IsNotNull(tgsReq);
@@ -103,4 +104,4 @@ private static KrbEncTicketPart ExtractTgt(KrbTgsReq tgsReq)
return apReq.Ticket.EncryptedPart.Decrypt(krbtgtKey, KeyUsage.Ticket, b => new KrbEncTicketPart().DecodeAsApplication(b));
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Messages/KrbtgtTests.cs b/Tests/Tests.Kerberos.NET/Messages/KrbtgtTests.cs
index 54b686cb..7349c10c 100644
--- a/Tests/Tests.Kerberos.NET/Messages/KrbtgtTests.cs
+++ b/Tests/Tests.Kerberos.NET/Messages/KrbtgtTests.cs
@@ -4,6 +4,7 @@
// -----------------------------------------------------------------------
using System.Globalization;
+using System.IO;
using System.Linq;
using Kerberos.NET.Crypto;
using Kerberos.NET.Entities;
@@ -43,7 +44,7 @@ public void KrbtgtDecode()
var krbtgtKey = new KerberosKey(key: Key, etype: EncryptionType.AES256_CTS_HMAC_SHA1_96);
var longUserTermKey = new KerberosKey("P@ssw0rd!", salt: "CORP.IDENTITYINTERVENTION.COMtestuser");
- var krbAsRepBytes = ReadDataFile("messages\\as-rep").Skip(4).ToArray();
+ var krbAsRepBytes = ReadDataFile(Path.Combine("Messages", "as-rep")).Skip(4).ToArray();
var asRep = new KrbAsRep().DecodeAsApplication(krbAsRepBytes);
diff --git a/Tests/Tests.Kerberos.NET/Resources/ResourcesTest.cs b/Tests/Tests.Kerberos.NET/Resources/ResourcesTest.cs
index d781c427..5609c08a 100644
--- a/Tests/Tests.Kerberos.NET/Resources/ResourcesTest.cs
+++ b/Tests/Tests.Kerberos.NET/Resources/ResourcesTest.cs
@@ -4,6 +4,7 @@
// -----------------------------------------------------------------------
using System;
+using System.IO;
using System.Security.Cryptography;
using Kerberos.NET.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -17,7 +18,7 @@ public class ResourcesTest : BaseTest
[ExpectedException(typeof(CryptographicException))]
public void ResourceManagerFormattedResource()
{
- var asReq = ReadDataFile("messages\\as-req");
+ var asReq = ReadDataFile(Path.Combine("Messages", "as-req"));
try
{
@@ -30,4 +31,4 @@ public void ResourceManagerFormattedResource()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Tests/Tests.Kerberos.NET/Tests.Kerberos.NET.csproj b/Tests/Tests.Kerberos.NET/Tests.Kerberos.NET.csproj
index 642e9926..6e68f606 100644
--- a/Tests/Tests.Kerberos.NET/Tests.Kerberos.NET.csproj
+++ b/Tests/Tests.Kerberos.NET/Tests.Kerberos.NET.csproj
@@ -9,13 +9,11 @@
WEAKCRYPTO
+ X64
+ WINDOWS
true
-
- X64
-
-
..\..\CodeAnalysisRules.ruleset
diff --git a/Tests/Tests.Kerberos.NET/Win32/LsaInteropTests.cs b/Tests/Tests.Kerberos.NET/Win32/LsaInteropTests.cs
index 59709b70..ec6c10b0 100644
--- a/Tests/Tests.Kerberos.NET/Win32/LsaInteropTests.cs
+++ b/Tests/Tests.Kerberos.NET/Win32/LsaInteropTests.cs
@@ -18,6 +18,7 @@ namespace Tests.Kerberos.NET
[TestClass]
public class LsaInteropTests
{
+#if WINDOWS
private const string RequestedSpn = "host/test.com";
private static readonly KerberosKey Key = new KerberosKey(key: new byte[16], etype: EncryptionType.AES128_CTS_HMAC_SHA1_96);
@@ -163,5 +164,6 @@ private static void RetrieveAndVerifyTicket()
Assert.AreEqual("test.com", decryptedToken.Ticket.CRealm);
}
}
+#endif
}
}
diff --git a/Tests/Tests.Kerberos.NET/Win32/SspiTests.cs b/Tests/Tests.Kerberos.NET/Win32/SspiTests.cs
index 14ea82fd..e2cfa21d 100644
--- a/Tests/Tests.Kerberos.NET/Win32/SspiTests.cs
+++ b/Tests/Tests.Kerberos.NET/Win32/SspiTests.cs
@@ -14,6 +14,7 @@ namespace Tests.Kerberos.NET
[TestClass]
public class SspiTests
{
+#if WINDOWS
[TestMethod]
public void TryGettingSspiTicketTest()
{
@@ -48,5 +49,6 @@ public void TryGettingSspiTicketTest()
Assert.IsTrue(KerberosCryptoTransformer.AreEqualSlow(contextSender.SessionKey, contextReceiver.SessionKey));
}
}
+#endif
}
}