Skip to content

Commit

Permalink
💾 Feat: Try to connect to remote device and get token.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Mar 6, 2024
1 parent a2408ec commit d0d790a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions KitX Shared/KitX.Shared.CSharp/Device/DeviceKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,19 @@ public class DeviceKey

public string? RsaPrivateKeyD { get; set; }
}

public static class DeviceKeyExtensions
{
public static bool IsSameKey(this DeviceKey key, DeviceKey other)
{
var result = true;

if (key.RsaPublicKeyExponent is not null && key.RsaPublicKeyModulus is not null)
result = result && key.RsaPublicKeyExponent == other.RsaPublicKeyExponent && key.RsaPublicKeyModulus == other.RsaPublicKeyModulus;

if (key.RsaPrivateKeyD is not null && key.RsaPrivateKeyModulus is not null)
result = result && key.RsaPrivateKeyD == other.RsaPrivateKeyD && key.RsaPrivateKeyModulus == other.RsaPrivateKeyModulus;

return result && key.Device.IsSameDevice(other.Device);
}
}
7 changes: 7 additions & 0 deletions KitX Shared/KitX.Shared.CSharp/Device/DeviceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ public override bool Equals(object obj)

public override int GetHashCode() => base.GetHashCode();
}

public static class DeviceLocatorExtensions
{
public static bool IsSameDevice(this DeviceLocator current, DeviceLocator target)
=> current.DeviceName.Equals(target.DeviceName)
&& current.MacAddress.Equals(target.MacAddress);
}

0 comments on commit d0d790a

Please sign in to comment.