use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMEmulator in project azure-iot-sdk-java by Azure.
the class SecurityProviderTPMEmulatorTest method getStorageRootSucceeds.
// SRS_SecurityProviderTPMEmulator_25_033: [ This method shall return the TPM2B_PUBLIC form of SRK. ]
@Test
public void getStorageRootSucceeds() throws Exception {
// arrange
createPersistentPrimaryExpectations();
createPersistentPrimaryExpectations();
SecurityProviderTPMEmulator securityProviderTPMEmulator = new SecurityProviderTPMEmulator();
// act //assert
TestCase.assertNotNull(securityProviderTPMEmulator.getStorageRootKey());
}
use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMEmulator in project azure-iot-sdk-java by Azure.
the class SecurityProviderTPMEmulatorTest method constructorThrowsOnResponseCodeNotSuccessNotHandle.
@Test(expected = SecurityProviderException.class)
public void constructorThrowsOnResponseCodeNotSuccessNotHandle() throws Exception {
// arrange
new StrictExpectations() {
{
mockedTpm._allowErrors();
mockedTpm.ReadPublic((TPM_HANDLE) any);
result = mockedReadPublicResponse;
mockedTpm._getLastResponseCode();
result = TPM_RC.TESTING;
}
};
// act
SecurityProviderTPMEmulator securityProviderTPMEmulator = new SecurityProviderTPMEmulator();
}
use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMEmulator in project azure-iot-sdk-java by Azure.
the class ProvisioningTests method reprovisioningFlow.
protected void reprovisioningFlow(EnrollmentType enrollmentType, AllocationPolicy allocationPolicy, ReprovisionPolicy reprovisionPolicy, CustomAllocationDefinition customAllocationDefinition, List<String> iothubsToStartAt, List<String> iothubsToFinishAt, DeviceCapabilities capabilities) throws Exception {
if (enrollmentType == EnrollmentType.GROUP && testInstance.attestationType != AttestationType.SYMMETRIC_KEY) {
// tpm doesn't support group, and x509 group test has not been implemented yet
return;
}
testInstance.securityProvider = getSecurityProviderInstance(enrollmentType, allocationPolicy, reprovisionPolicy, customAllocationDefinition, iothubsToStartAt, capabilities);
ProvisioningStatus provisioningStatus = registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpoint, true, iothubsToStartAt);
assertProvisionedDeviceCapabilitiesAreExpected(capabilities, farAwayIotHubConnectionString);
String expectedReportedPropertyName = "someProperty";
String expectedReportedPropertyValue = "someValue";
sendReportedPropertyUpdate(expectedReportedPropertyName, expectedReportedPropertyValue, testInstance.provisionedIotHubUri, testInstance.provisionedDeviceId);
updateEnrollmentToForceReprovisioning(enrollmentType, iothubsToFinishAt);
if (testInstance.securityProvider instanceof SecurityProviderTPMEmulator) {
((SecurityProviderTPMEmulator) testInstance.securityProvider).shutDown();
testInstance.securityProvider = new SecurityProviderTPMEmulator(testInstance.registrationId);
}
// re-register device, test which hub it was provisioned to
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpoint, true, reprovisionPolicy.getUpdateHubAssignment() ? iothubsToFinishAt : iothubsToStartAt);
assertTwinIsCorrect(reprovisionPolicy, expectedReportedPropertyName, expectedReportedPropertyValue, !reprovisionPolicy.getUpdateHubAssignment());
}
use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMEmulator in project azure-iot-sdk-java by Azure.
the class SecurityProviderTPMEmulatorTest method constructorSucceeds.
// SRS_SecurityProviderTPMEmulator_25_001: [ The constructor shall start the local TPM Simulator, clear persistent for EK and SRK if it exist, create persistent primary for EK and SRK. ]
// SRS_SecurityProviderTPMEmulator_25_002: [ The constructor shall set the registration Id to null if none was provided. ]
@Test
public void constructorSucceeds() throws Exception {
createPersistentPrimaryExpectations();
createPersistentPrimaryExpectations();
SecurityProviderTPMEmulator securityProviderTPMEmulator = new SecurityProviderTPMEmulator();
new Verifications() {
{
TpmFactory.localTpmSimulator();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMEmulator in project azure-iot-sdk-java by Azure.
the class SecurityProviderTPMEmulatorTest method constructorThrowsOnCreatePrimaryResponseNull.
@Test(expected = SecurityProviderException.class)
public void constructorThrowsOnCreatePrimaryResponseNull() throws Exception {
// arrange
new StrictExpectations() {
{
mockedTpm._allowErrors();
mockedTpm.ReadPublic((TPM_HANDLE) any);
result = mockedReadPublicResponse;
mockedTpm._getLastResponseCode();
result = TPM_RC.HANDLE;
mockedTpm.CreatePrimary((TPM_HANDLE) any, (TPMS_SENSITIVE_CREATE) any, (TPMT_PUBLIC) any, (byte[]) any, (TPMS_PCR_SELECTION[]) any);
result = null;
}
};
// act
SecurityProviderTPMEmulator securityProviderTPMEmulator = new SecurityProviderTPMEmulator();
}
Aggregations