Skip to content

Commit 6683cfe

Browse files
committed
Support for contact discovery service - Part 3
Reflects signalapp/libsignal-service-java@f1c52e9 Delete HelperMethods.cs
1 parent 8812948 commit 6683cfe

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

libsignal-service-dotnet/HelperMethods.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

libsignal-service-dotnet/contacts/crypto/ContactDiscoveryCipher.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class ContactDiscoveryCipher
1818
{
1919
private const int TAG_LENGTH_BYTES = 16;
2020
private const int TAG_LENGTH_BITS = TAG_LENGTH_BYTES * 8;
21+
private const long SIGNATURE_BODY_VERSION = 3;
2122

2223
public DiscoveryRequest CreateDiscoveryRequest(IList<string> addressBook, RemoteAttestation remoteAttestation)
2324
{
@@ -104,10 +105,9 @@ public void VerifyServerQuote(Quote quote, byte[] serverPublicStatic, string mre
104105
throw new UnauthenticatedQuoteException($"The response quote has the wrong mrenclave value in it: {Hex.ToStringCondensed(quote.Mrenclave)}");
105106
}
106107

107-
if (!quote.IsDebugQuote())
108+
if (quote.IsDebugQuote())
108109
{
109-
// XXX Invert in production
110-
throw new UnauthenticatedQuoteException("Expecting debug quote!");
110+
throw new UnauthenticatedQuoteException("Received quote for debuggable enclave");
111111
}
112112
}
113113
catch (IOException ex)
@@ -130,14 +130,17 @@ public void VerifyIasSignature(string certificates, string signatureBody, string
130130

131131
SignatureBodyEntity signatureBodyEntity = JsonUtil.FromJson<SignatureBodyEntity>(signatureBody);
132132

133+
if (signatureBodyEntity.Version != SIGNATURE_BODY_VERSION)
134+
{
135+
throw new CryptographicException($"Unexpected signed quote version {signatureBodyEntity.Version}");
136+
}
137+
133138
if (!Enumerable.SequenceEqual(ByteUtil.trim(signatureBodyEntity.IsvEnclaveQuoteBody, 432), ByteUtil.trim(quote.QuoteBytes, 432)))
134139
{
135140
throw new CryptographicException($"Signed quote is not the same as RA quote: {Hex.ToStringCondensed(signatureBodyEntity.IsvEnclaveQuoteBody!)} vs {Hex.ToStringCondensed(quote.QuoteBytes)}");
136141
}
137142

138-
// TODO: "GROUP_OUT_OF_DATE" should only be allowed during testing
139-
if ("OK" != signatureBodyEntity.IsvEnclaveQuoteStatus && "GROUP_OUT_OF_DATE" != signatureBodyEntity.IsvEnclaveQuoteStatus)
140-
//if ("OK" != signatureBodyEntity.IsvEnclaveQuoteStatus)
143+
if ("OK" != signatureBodyEntity.IsvEnclaveQuoteStatus)
141144
{
142145
throw new CryptographicException($"Quote status is: {signatureBodyEntity.IsvEnclaveQuoteStatus}");
143146
}

libsignal-service-dotnet/contacts/crypto/SignatureBodyEntity.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ internal class SignatureBodyEntity
1010
[JsonProperty("isvEnclaveQuoteStatus")]
1111
public string? IsvEnclaveQuoteStatus { get; }
1212

13+
[JsonProperty("version")]
14+
public long Version { get; }
15+
1316
[JsonProperty("timestamp")]
1417
public string? Timestamp { get; }
1518
}

0 commit comments

Comments
 (0)