Skip to content

Commit 8dbe60c

Browse files
committed
Make device udid settable, add v3 vfs cert construtor
1 parent c1c4f47 commit 8dbe60c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

LibConeshell/ConeshellV2.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace LibConeshell;
1313

1414
public class ConeshellV2 : Coneshell
1515
{
16-
protected readonly byte[] DeviceUdid;
16+
public byte[] DeviceUdid { protected get; set; }
1717
public X25519PublicKeyParameters? ServerPublicKey { get; set; }
1818

1919
public ConeshellV2(byte[] deviceUdid, X25519PublicKeyParameters? serverPublicKey = null)
@@ -25,6 +25,11 @@ public ConeshellV2(byte[] deviceUdid, X25519PublicKeyParameters? serverPublicKey
2525
ServerPublicKey = serverPublicKey;
2626
}
2727

28+
public ConeshellV2()
29+
{
30+
DeviceUdid = new byte[16];
31+
}
32+
2833
#region Coneshell Message Functions
2934

3035
protected virtual uint HeaderMagic => 0x0200DEC0;

LibConeshell/ConeshellV3.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ConeshellV3 : ConeshellV2
1313

1414

1515
private readonly byte[] _versionKey;
16+
private readonly byte[]? _vfsCert;
1617

1718
public static ConeshellV3 FromTally(Guid deviceUdid, byte[] tally)
1819
{
@@ -22,7 +23,17 @@ public static ConeshellV3 FromTally(Guid deviceUdid, byte[] tally)
2223
return new ConeshellV3(
2324
Convert.FromHexString(deviceUdid.ToString().Replace("-", "")),
2425
tally[0x1f8..],
25-
new X25519PublicKeyParameters(tally[0x1d8..0x1f8].Reverse().ToArray()));
26+
new X25519PublicKeyParameters(tally[0x1d8..0x1f8].Reverse().ToArray()),
27+
tally[..0x1d8]);
28+
}
29+
30+
public ConeshellV3(byte[] deviceUdid, byte[] versionKey, X25519PublicKeyParameters serverPublicKey, byte[] vfsCert)
31+
: this(deviceUdid, versionKey, serverPublicKey)
32+
{
33+
if (vfsCert.Length != VfsCertLength)
34+
throw new ArgumentException($"The VFS certificate must be {VfsCertLength} bytes in length.", nameof(vfsCert));
35+
36+
_vfsCert = vfsCert;
2637
}
2738

2839
public ConeshellV3(byte[] deviceUdid, byte[] versionKey, X25519PublicKeyParameters serverPublicKey)
@@ -40,6 +51,11 @@ public ConeshellV3(byte[] deviceUdid, byte[] versionKey)
4051
_versionKey = versionKey;
4152
}
4253

54+
public ConeshellV3()
55+
{
56+
_versionKey = new byte[20];
57+
}
58+
4359
#region Coneshell Message Functions
4460

4561
protected override uint HeaderMagic => 0x0300DEC0;

0 commit comments

Comments
 (0)