From 11e7e6d3f04169d414f642e6b41010a149e31b8c Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Thu, 15 Feb 2024 14:48:06 +1100 Subject: [PATCH 1/5] Adding url to attestation data --- pom.xml | 4 ++-- .../azure/AzureCCAttestationProvider.java | 4 +++- .../azure/AzureCCAttestationProviderTest.java | 15 +++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 73274f3..0347d04 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.uid2 attestation-azure - 1.5.16-d43239058c + 2.0.0-SNAPSHOT ${project.groupId}:${project.artifactId} Azure Enclave attestation @@ -36,7 +36,7 @@ com.uid2 uid2-attestation-api - 1.5.0-676519b018 + 1.6.10-SNAPSHOT com.google.code.gson diff --git a/src/main/java/com/uid2/attestation/azure/AzureCCAttestationProvider.java b/src/main/java/com/uid2/attestation/azure/AzureCCAttestationProvider.java index 2c7ebc1..98e99ab 100644 --- a/src/main/java/com/uid2/attestation/azure/AzureCCAttestationProvider.java +++ b/src/main/java/com/uid2/attestation/azure/AzureCCAttestationProvider.java @@ -80,13 +80,14 @@ public AzureCCAttestationProvider(String maaServerBaseUrl, String skrUrl, HttpCl } @Override - public byte[] getAttestationRequest(byte[] publicKey) throws AttestationException { + public byte[] getAttestationRequest(byte[] publicKey, byte[] userData) throws AttestationException { var base64Encoder = Base64.getEncoder(); var gson = new Gson(); var runtimeData = new RuntimeData(); runtimeData.location = this.location; runtimeData.publicKey = base64Encoder.encodeToString(publicKey); + runtimeData.userData = base64Encoder.encodeToString(userData); String runtimeDataJson = gson.toJson(runtimeData); var skrRequest = new SkrRequest(); @@ -130,6 +131,7 @@ private String getLocation() { private static class RuntimeData { private String location; private String publicKey; + private String userData; } private static class SkrRequest { diff --git a/src/test/java/com/uid2/attestation/azure/AzureCCAttestationProviderTest.java b/src/test/java/com/uid2/attestation/azure/AzureCCAttestationProviderTest.java index 6941559..014a570 100644 --- a/src/test/java/com/uid2/attestation/azure/AzureCCAttestationProviderTest.java +++ b/src/test/java/com/uid2/attestation/azure/AzureCCAttestationProviderTest.java @@ -18,12 +18,14 @@ import java.util.Map; public class AzureCCAttestationProviderTest { + final private byte[] publicTokenMock = new byte[] {0x01, 0x02}; + final private byte[] userDataMock = new byte[] {0x03, 0x04}; + @Test public void testGetAttestationRequestSuccess() throws Exception { var gson = new Gson(); // Mock response - final var publicTokenMock = new byte[] {0x01, 0x02}; final var skrUrlMock = "http://skr"; final var maaTokenMock = "abc"; final var httpResponseMock = mock(HttpResponse.class); @@ -35,7 +37,7 @@ public void testGetAttestationRequestSuccess() throws Exception { // Verify output final var provider = new AzureCCAttestationProvider(null, skrUrlMock, httpClientMock); - var output = provider.getAttestationRequest(publicTokenMock); + var output = provider.getAttestationRequest(publicTokenMock, userDataMock); Assert.assertArrayEquals(maaTokenMock.getBytes(), output); // Verify sent request @@ -47,7 +49,6 @@ public void testGetAttestationRequestSuccess() throws Exception { @Test public void testGetAttestationRequestFailure_InvalidStatusCode() throws Exception { - final var publicTokenMock = new byte[] {0x01, 0x02}; final var httpResponseMock = mock(HttpResponse.class); when(httpResponseMock.statusCode()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR); @@ -55,13 +56,12 @@ public void testGetAttestationRequestFailure_InvalidStatusCode() throws Exceptio when(httpClientMock.send(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(httpResponseMock); final var provider = new AzureCCAttestationProvider(null, null, httpClientMock); - var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock)); + var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock, userDataMock)); Assert.assertTrue(thrown.getMessage().startsWith("Skr failed with status code: " + HttpURLConnection.HTTP_INTERNAL_ERROR)); } @Test public void testGetAttestationRequestFailure_EmptyResponseBody() throws Exception { - final var publicTokenMock = new byte[] {0x01, 0x02}; final var httpResponseMock = mock(HttpResponse.class); when(httpResponseMock.statusCode()).thenReturn(HttpURLConnection.HTTP_OK); @@ -69,14 +69,13 @@ public void testGetAttestationRequestFailure_EmptyResponseBody() throws Exceptio when(httpClientMock.send(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(httpResponseMock); final var provider = new AzureCCAttestationProvider(null, null, httpClientMock); - var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock)); + var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock, userDataMock)); Assert.assertEquals("response is null", thrown.getMessage()); } @Test public void testGetAttestationRequestFailure_InvalidResponseBody() throws Exception { var gson = new Gson(); - final var publicTokenMock = new byte[] {0x01, 0x02}; final var httpResponseMock = mock(HttpResponse.class); when(httpResponseMock.statusCode()).thenReturn(HttpURLConnection.HTTP_OK); when(httpResponseMock.body()).thenReturn(gson.toJson(Map.of("key", 123))); @@ -85,7 +84,7 @@ public void testGetAttestationRequestFailure_InvalidResponseBody() throws Except when(httpClientMock.send(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(httpResponseMock); final var provider = new AzureCCAttestationProvider(null, null, httpClientMock); - var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock)); + var thrown = Assert.assertThrows(AttestationException.class, () -> provider.getAttestationRequest(publicTokenMock, userDataMock)); Assert.assertEquals("token field not exist in Skr response", thrown.getMessage()); } } From 9ac81fc449d172e4f795a92247e0b539bbe13c69 Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Thu, 15 Feb 2024 15:44:50 +1100 Subject: [PATCH 2/5] Add snapshot repo --- pom.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 0347d04..738f107 100644 --- a/pom.xml +++ b/pom.xml @@ -83,12 +83,15 @@ - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - + + + snapshots-repo + https://s01.oss.sonatype.org/content/repositories/snapshots + false + true + + + From a3d41c197d74e480e69e0cdbe15161405ae66cfe Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Thu, 15 Feb 2024 15:50:30 +1100 Subject: [PATCH 3/5] Add repo back --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 738f107..d87f86b 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,12 @@ true + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + From 8dc10ad70ec0eba1526858357e915a705fe96680 Mon Sep 17 00:00:00 2001 From: Release Workflow Date: Thu, 15 Feb 2024 04:52:49 +0000 Subject: [PATCH 4/5] [CI Pipeline] Released Snapshot version: 1.5.25-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d87f86b..d4936d4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.uid2 attestation-azure - 2.0.0-SNAPSHOT + 1.5.25-SNAPSHOT ${project.groupId}:${project.artifactId} Azure Enclave attestation From db2242f3fc5c3aabf2b9c290e319da93f34b2518 Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Fri, 16 Feb 2024 11:37:37 +1100 Subject: [PATCH 5/5] Updated to published version of attestation-api --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4936d4..4a88bcb 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ com.uid2 uid2-attestation-api - 1.6.10-SNAPSHOT + 2.0.0-f968aec0e3 com.google.code.gson