mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-29 15:44:14 +00:00
Add validation of support RIM in payload
This commit is contained in:
parent
c69affd4f6
commit
64ddc39c2c
@ -75,6 +75,7 @@ import java.math.BigInteger;
|
||||
import hirs.swid.xjc.Directory;
|
||||
import hirs.swid.xjc.Entity;
|
||||
import hirs.swid.xjc.Link;
|
||||
import hirs.swid.xjc.Meta;
|
||||
import hirs.swid.xjc.ObjectFactory;
|
||||
import hirs.swid.xjc.ResourceCollection;
|
||||
import hirs.swid.xjc.SoftwareIdentity;
|
||||
@ -229,6 +230,8 @@ public class SwidTagGateway {
|
||||
si.append("SoftwareIdentity name: " + softwareIdentity.getAttribute("name") + "\n");
|
||||
si.append("SoftwareIdentity tagId: " + softwareIdentity.getAttribute("tagId") + "\n");
|
||||
System.out.println(si.toString());
|
||||
Element file = (Element) document.getElementsByTagName("File").item(0);
|
||||
validateFile(file);
|
||||
System.out.println("Signature core validity: " + validateSignedXMLDocument(document));
|
||||
return true;
|
||||
}
|
||||
@ -430,7 +433,22 @@ public class SwidTagGateway {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This method validates a hirs.swid.xjc.File from an indirect payload
|
||||
*/
|
||||
private boolean validateFile(Element file) {
|
||||
String filepath = file.getAttribute(SwidTagConstants.NAME);
|
||||
System.out.println("Support rim found at " + filepath);
|
||||
if (HashSwid.get256Hash(filepath).equals(file.getAttribute(_SHA256_HASH.getPrefix() + ":" + _SHA256_HASH.getLocalPart()))) {
|
||||
System.out.println("Support RIM hash verified!");
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("Support RIM hash does not match Base RIM!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a hirs.swid.xjc.File from a direct payload type.
|
||||
*
|
||||
* @param jsonObject
|
||||
|
@ -44,10 +44,8 @@ public class TestSwidTagGateway {
|
||||
@Test
|
||||
public void testCreateBaseWithCert() throws URISyntaxException {
|
||||
gateway.setDefaultCredentials(false);
|
||||
gateway.setPemCertificateFile(
|
||||
Paths.get(this.getClass().getResource(certificateFile).toURI()).toString());
|
||||
gateway.setPemPrivateKeyFile(
|
||||
Paths.get(this.getClass().getResource(privateKeyFile).toURI()).toString());
|
||||
gateway.setPemCertificateFile(certificateFile);
|
||||
gateway.setPemPrivateKeyFile(privateKeyFile);
|
||||
gateway.generateSwidTag(DEFAULT_OUTPUT);
|
||||
expectedFile = (InputStream) TestSwidTagGateway.class.getClassLoader().getResourceAsStream(DEFAULT_WITH_CERT);
|
||||
Assert.assertTrue(compareFileBytesToExpectedFile(DEFAULT_OUTPUT));
|
||||
|
Loading…
x
Reference in New Issue
Block a user