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());
}
}