public void CompareToMaaServiceJwtToken(AttestationResult attestationResult, bool includeDetails) { //if (includeDetails) //{ // Logger.WriteLine(""); // Logger.WriteLine("Claims in MAA Service JWT Token"); // Logger.WriteLine($"{jwtBody.ToString()}"); // Logger.WriteLine(""); //} var isDebuggable = (Attributes & 1) == 1; var isdpassed = isDebuggable == attestationResult.IsDebuggable; Logger.WriteLine($"IsDebuggable match : {isdpassed}"); if (includeDetails) { Logger.WriteLine($" We think : {isDebuggable}"); Logger.WriteLine($" MAA service: {attestationResult.IsDebuggable}"); } var mrepassed = MrEnclaveHex.ToLower().Equals(attestationResult.MrEnclave); Logger.WriteLine($"MRENCLAVE match : {mrepassed}"); if (includeDetails) { Logger.WriteLine($" We think : {MrEnclaveHex.ToLower()}"); Logger.WriteLine($" MAA service: {attestationResult.MrEnclave}"); } var mrspassed = MrSignerHex.ToLower().Equals(attestationResult.MrSigner.ToLower()); Logger.WriteLine($"MRSIGNER match : {mrspassed}"); if (includeDetails) { Logger.WriteLine($" We think : {MrSignerHex.ToLower()}"); Logger.WriteLine($" MAA service: {attestationResult.MrSigner}"); } var pidpassed = BitConverter.ToUInt64(HexHelper.ConvertHexToByteArray(ProductIdHex), 0) == (ulong)attestationResult.ProductId; Logger.WriteLine($"ProductID match : {pidpassed}"); if (includeDetails) { Logger.WriteLine($" We think : {BitConverter.ToUInt64(HexHelper.ConvertHexToByteArray(ProductIdHex), 0)}"); Logger.WriteLine($" MAA service: {attestationResult.ProductId}"); } var svnPassed = SecurityVersion == (uint)attestationResult.Svn; Logger.WriteLine($"Security Version match : {svnPassed}"); if (includeDetails) { Logger.WriteLine($" We think : {SecurityVersion}"); Logger.WriteLine($" MAA service: {attestationResult.Svn}"); } var ehdExpected = HexHelper.ConvertHexToByteArray(EnclaveHeldDataHex); var ehdActual = attestationResult.EnclaveHeldData; var ehdPassed = ehdExpected.SequenceEqual(ehdActual.ToArray()); Logger.WriteLine($"Enclave Held Data match : {ehdPassed}"); if (includeDetails) { Logger.WriteLine(17, 100, " We think : ", Base64Url.EncodeBytes(ehdExpected)); Logger.WriteLine(17, 100, " MAA service: ", Base64Url.EncodeBytes(attestationResult.EnclaveHeldData.ToArray())); } Logger.WriteLine(""); }
public static string ConvertHexToBase64Url(string hexString) { byte[] hexBytes = ConvertHexToByteArray(hexString); return(Base64Url.EncodeBytes(hexBytes)); }
public void CompareToMaaServiceJwtToken(string serviceJwtToken, bool includeDetails) { var jwtBody = JoseHelper.ExtractJosePart(serviceJwtToken, 1); //if (includeDetails) //{ // Logger.WriteLine(""); // Logger.WriteLine("Claims in MAA Service JWT Token"); // Logger.WriteLine($"{jwtBody.ToString()}"); // Logger.WriteLine(""); //} var isDebuggable = (Attributes & 1) == 1; var isd = jwtBody["is-debuggable"]; var isdpassed = isDebuggable == (bool)isd; Logger.WriteLine($"IsDebuggable match : {isdpassed}"); if (includeDetails) { Logger.WriteLine($" We think : {isDebuggable}"); Logger.WriteLine($" MAA service: {isd}"); } var mre = jwtBody["sgx-mrenclave"]; var mrepassed = MrEnclaveHex.ToLower().Equals((string)mre); Logger.WriteLine($"MRENCLAVE match : {mrepassed}"); if (includeDetails) { Logger.WriteLine($" We think : {MrEnclaveHex.ToLower()}"); Logger.WriteLine($" MAA service: {mre}"); } var mrs = jwtBody["sgx-mrsigner"]; var mrspassed = MrSignerHex.ToLower().Equals(((string)mrs).ToLower()); Logger.WriteLine($"MRSIGNER match : {mrspassed}"); if (includeDetails) { Logger.WriteLine($" We think : {MrSignerHex.ToLower()}"); Logger.WriteLine($" MAA service: {mrs}"); } var pid = jwtBody["product-id"]; var pidpassed = BitConverter.ToUInt64(HexHelper.ConvertHexToByteArray(ProductIdHex), 0) == (ulong)pid; Logger.WriteLine($"ProductID match : {pidpassed}"); if (includeDetails) { Logger.WriteLine($" We think : {BitConverter.ToUInt64(HexHelper.ConvertHexToByteArray(ProductIdHex), 0)}"); Logger.WriteLine($" MAA service: {pid}"); } var svn = jwtBody["svn"]; var svnPassed = SecurityVersion == (uint)svn; Logger.WriteLine($"Security Version match : {svnPassed}"); if (includeDetails) { Logger.WriteLine($" We think : {SecurityVersion}"); Logger.WriteLine($" MAA service: {svn}"); } var ehd = jwtBody["maa-ehd"]; var ehdPassed = HexHelper.ConvertHexToBase64Url(EnclaveHeldDataHex).Equals((string)ehd); Logger.WriteLine($"Enclave Held Data match : {ehdPassed}"); if (includeDetails) { Logger.WriteLine(17, 124, " We think : ", EnclaveHeldDataHex); Logger.WriteLine(17, 124, " MAA service: ", BitConverter.ToString(Base64Url.DecodeBytes(ehd.ToString())).Replace("-", "")); } Logger.WriteLine(""); }