Skip to content

Commit 10cfe37

Browse files
committed
Merge branch 'main' into v3_issue_836-spdm
2 parents 85e2d9b + 2dcdc15 commit 10cfe37

File tree

13 files changed

+271
-67
lines changed

13 files changed

+271
-67
lines changed

.github/workflows/dotnet_provisioner_unit_tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
git config --global core.eol lf
2222
2323
- name: Checkout repo
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525
with:
2626
submodules: recursive
2727

@@ -82,14 +82,14 @@ jobs:
8282
more $logName
8383
8484
- name: Upload Logs Ubuntu
85-
uses: actions/upload-artifact@v2
85+
uses: actions/upload-artifact@v4
8686
if: contains(matrix.os, 'ubuntu') && always()
8787
with:
8888
name: "${{matrix.os}}-unit-tests-${{steps.ubuntu_result.outputs.result}}.log"
8989
path: HIRS_Provisioner.NET/*.log
9090

9191
- name: Upload Logs Windows
92-
uses: actions/upload-artifact@v2
92+
uses: actions/upload-artifact@v4
9393
if: contains(matrix.os, 'windows') && always()
9494
with:
9595
name: "${{matrix.os}}-unit-tests-${{steps.window_result.outputs.result}}.log"

.github/workflows/hirs_package_linux.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Set up JDK 17
20-
uses: actions/setup-java@v3
20+
uses: actions/setup-java@v4
2121
with:
2222
java-version: '17'
2323
distribution: 'temurin'
@@ -26,44 +26,57 @@ jobs:
2626
- name: directory setup
2727
run: |
2828
mkdir -p artifacts/jars
29+
mkdir -p artifacts/win
30+
mkdir -p artifacts/win/hirstools
2931
- name: install dependencies
3032
run: |
3133
sudo apt-get update
3234
sudo apt-get install git curl nano cron mariadb-server
3335
- name: Setup Gradle
34-
uses: gradle/gradle-build-action@v2
36+
uses: gradle/actions/setup-gradle@v3
3537
- name: Execute Gradle build
3638
run: |
3739
./gradlew build;
3840
./gradlew bootWar;
3941
./gradlew buildDeb;
4042
./gradlew buildRpm;
43+
./gradlew buildZip
4144
cp HIRS_AttestationCAPortal/build/libs/*.jar artifacts/jars/.
4245
cp HIRS_AttestationCA/build/libs/*.jar artifacts/jars/.
4346
cp HIRS_Utils/build/libs/*.jar artifacts/jars/.
4447
cp HIRS_Structs/build/libs/*.jar artifacts/jars/.
48+
cp tools/tcg_rim_tool/build/distributions/*.zip artifacts/win
49+
cp tools/tcg_eventlog_tool/build/distributions/*.zip artifacts/win
50+
cp package/win/tcg-rim-tool/* artifacts/win/hirstools
4551
- name: Archive RPM files
46-
uses: actions/upload-artifact@v3
52+
uses: actions/upload-artifact@v4
4753
with:
4854
name: RPM_Files
4955
path: HIRS_AttestationCAPortal/build/distributions/*.rpm
5056
if-no-files-found: error
5157
- name: Archive DEB files
52-
uses: actions/upload-artifact@v3
58+
uses: actions/upload-artifact@v4
5359
with:
5460
name: DEB_Files
5561
path: HIRS_AttestationCAPortal/build/distributions/*.deb
5662
if-no-files-found: error
5763
- name: War files
58-
uses: actions/upload-artifact@v3
64+
uses: actions/upload-artifact@v4
5965
with:
6066
name: WAR_Files
6167
path: HIRS_AttestationCAPortal/build/libs/HIRS_AttestationCAPortal.war
6268
if-no-files-found: error
6369
- name: JAR_Files
64-
uses: actions/upload-artifact@v3
70+
uses: actions/upload-artifact@v4
6571
with:
6672
name: JAR_Files
6773
path: artifacts/jars/
6874
if-no-files-found: error
69-
75+
- name: ZIP_Files
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: ZIP_Files
79+
path: artifacts/win/
80+
if-no-files-found: error
81+
82+

HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java

+114-50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hirs.attestationca.persist.provision;
22

3+
import com.fasterxml.jackson.databind.ser.Serializers;
34
import com.google.protobuf.ByteString;
45
import hirs.attestationca.configuration.provisionerTpm2.ProvisionerTpm2;
56
import hirs.attestationca.persist.entity.manager.CertificateRepository;
@@ -61,6 +62,8 @@
6162
import java.util.LinkedList;
6263
import java.util.List;
6364
import java.util.Map;
65+
import java.util.Optional;
66+
import java.util.UUID;
6467
import java.util.regex.Matcher;
6568
import java.util.regex.Pattern;
6669

@@ -346,90 +349,151 @@ private DeviceInfoReport parseDeviceInfo(final ProvisionerTpm2.IdentityClaim cla
346349
dv.getHw().getManufacturer(),
347350
dv.getHw().getProductName());
348351
BaseReferenceManifest dbBaseRim = null;
349-
SupportReferenceManifest support;
352+
SupportReferenceManifest support = null;
350353
EventLogMeasurements measurements;
354+
boolean isReplacement = false;
355+
String replacementRimId = "";
351356
String tagId = "";
352357
String fileName = "";
353358
Pattern pattern = Pattern.compile("([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)");
354359
Matcher matcher;
355360
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
356361

357-
if (dv.getLogfileCount() > 0) {
358-
for (ByteString logFile : dv.getLogfileList()) {
359-
try {
360-
support = (SupportReferenceManifest) referenceManifestRepository.findByHexDecHashAndRimType(
361-
Hex.encodeHexString(messageDigest.digest(logFile.toByteArray())),
362-
ReferenceManifest.SUPPORT_RIM);
363-
if (support == null) {
364-
support = new SupportReferenceManifest(
365-
String.format("%s.rimel",
366-
defaultClientName),
367-
logFile.toByteArray());
368-
// this is a validity check
369-
new TCGEventLog(support.getRimBytes());
370-
// no issues, continue
371-
support.setPlatformManufacturer(dv.getHw().getManufacturer());
372-
support.setPlatformModel(dv.getHw().getProductName());
373-
support.setFileName(String.format("%s_[%s].rimel", defaultClientName,
374-
support.getHexDecHash().substring(
375-
support.getHexDecHash().length() - NUM_OF_VARIABLES)));
376-
support.setDeviceName(dv.getNw().getHostname());
377-
this.referenceManifestRepository.save(support);
378-
} else {
379-
log.info("Client provided Support RIM already loaded in database.");
380-
if (support.isArchived()) {
381-
support.restore();
382-
support.resetCreateTime();
383-
this.referenceManifestRepository.save(support);
384-
}
385-
}
386-
} catch (IOException ioEx) {
387-
log.error(ioEx);
388-
} catch (Exception ex) {
389-
log.error(String.format("Failed to load support rim: %s", ex.getMessage()));
390-
}
391-
}
392-
} else {
393-
log.warn(String.format("%s did not send support RIM file...",
394-
dv.getNw().getHostname()));
395-
}
396-
397362
if (dv.getSwidfileCount() > 0) {
398363
for (ByteString swidFile : dv.getSwidfileList()) {
399364
try {
400365
dbBaseRim = (BaseReferenceManifest) referenceManifestRepository
401366
.findByBase64Hash(Base64.getEncoder()
402-
.encodeToString(messageDigest
403-
.digest(swidFile.toByteArray())));
367+
.encodeToString(messageDigest
368+
.digest(swidFile.toByteArray())));
404369
if (dbBaseRim == null) {
370+
/*
371+
Either the swidFile does not have a corresponding base RIM in the backend
372+
or it was deleted. Check if there is a replacement by comparing tagId against
373+
all other base RIMs, and then set the corresponding support rim's deviceName.
374+
*/
405375
dbBaseRim = new BaseReferenceManifest(
406376
String.format("%s.swidtag",
407377
defaultClientName),
408378
swidFile.toByteArray());
379+
List<BaseReferenceManifest> baseRims = referenceManifestRepository.findAllBaseRims();
380+
for (BaseReferenceManifest bRim : baseRims) {
381+
if (bRim.getTagId().equals(dbBaseRim.getTagId())) {
382+
dbBaseRim = bRim;
383+
replacementRimId = dbBaseRim.getAssociatedRim().toString();
384+
isReplacement = true;
385+
break;
386+
}
387+
}
409388
dbBaseRim.setDeviceName(dv.getNw().getHostname());
410389
this.referenceManifestRepository.save(dbBaseRim);
411-
} else {
412-
log.info("Client provided Base RIM already loaded in database.");
413-
/**
414-
* Leaving this as is for now, however can there be a condition
415-
* in which the provisioner sends swidtags without support rims?
390+
} else if (dbBaseRim.isArchived()) {
391+
/*
392+
This block accounts for RIMs that may have been soft-deleted (archived)
393+
in an older version of the ACA.
416394
*/
395+
List<ReferenceManifest> rims = referenceManifestRepository.findByArchiveFlag(false);
396+
for (ReferenceManifest rim : rims) {
397+
if (rim.isBase() && rim.getTagId().equals(dbBaseRim.getTagId()) &&
398+
rim.getCreateTime().after(dbBaseRim.getCreateTime())) {
399+
dbBaseRim.setDeviceName(null);
400+
dbBaseRim = (BaseReferenceManifest) rim;
401+
dbBaseRim.setDeviceName(dv.getNw().getHostname());
402+
}
403+
}
417404
if (dbBaseRim.isArchived()) {
418-
dbBaseRim.restore();
419-
dbBaseRim.resetCreateTime();
405+
throw new Exception("Unable to locate an unarchived base RIM.");
406+
} else {
420407
this.referenceManifestRepository.save(dbBaseRim);
421408
}
409+
} else {
410+
dbBaseRim.setDeviceName(dv.getNw().getHostname());
411+
this.referenceManifestRepository.save(dbBaseRim);
422412
}
423413
tagId = dbBaseRim.getTagId();
424414
} catch (UnmarshalException e) {
425415
log.error(e);
416+
} catch (Exception ex) {
417+
log.error(String.format("Failed to load base rim: %s", ex.getMessage()));
426418
}
427419
}
428420
} else {
429421
log.warn(String.format("%s did not send swid tag file...",
430422
dv.getNw().getHostname()));
431423
}
432424

425+
if (dv.getLogfileCount() > 0) {
426+
for (ByteString logFile : dv.getLogfileList()) {
427+
try {
428+
support = (SupportReferenceManifest) referenceManifestRepository.findByHexDecHashAndRimType(
429+
Hex.encodeHexString(messageDigest.digest(logFile.toByteArray())),
430+
ReferenceManifest.SUPPORT_RIM);
431+
if (support == null) {
432+
/*
433+
Either the logFile does not have a corresponding support RIM in the backend
434+
or it was deleted. The support RIM for a replacement base RIM is handled
435+
in the previous loop block.
436+
*/
437+
if (isReplacement) {
438+
Optional<ReferenceManifest> replacementRim =
439+
referenceManifestRepository.findById(UUID.fromString(replacementRimId));
440+
if (replacementRim.isPresent()) {
441+
support = (SupportReferenceManifest) replacementRim.get();
442+
support.setDeviceName(dv.getNw().getHostname());
443+
} else {
444+
throw new Exception("Unable to locate support RIM " + replacementRimId);
445+
}
446+
} else {
447+
support = new SupportReferenceManifest(
448+
String.format("%s.rimel",
449+
defaultClientName),
450+
logFile.toByteArray());
451+
// this is a validity check
452+
new TCGEventLog(support.getRimBytes());
453+
// no issues, continue
454+
support.setPlatformManufacturer(dv.getHw().getManufacturer());
455+
support.setPlatformModel(dv.getHw().getProductName());
456+
support.setFileName(String.format("%s_[%s].rimel", defaultClientName,
457+
support.getHexDecHash().substring(
458+
support.getHexDecHash().length() - NUM_OF_VARIABLES)));
459+
}
460+
support.setDeviceName(dv.getNw().getHostname());
461+
this.referenceManifestRepository.save(support);
462+
} else if (support.isArchived()) {
463+
/*
464+
This block accounts for RIMs that may have been soft-deleted (archived)
465+
in an older version of the ACA.
466+
*/
467+
List<ReferenceManifest> rims = referenceManifestRepository.findByArchiveFlag(false);
468+
for (ReferenceManifest rim : rims) {
469+
if (rim.isSupport() &&
470+
rim.getTagId().equals(support.getTagId()) &&
471+
rim.getCreateTime().after(support.getCreateTime())) {
472+
support.setDeviceName(null);
473+
support = (SupportReferenceManifest) rim;
474+
support.setDeviceName(dv.getNw().getHostname());
475+
}
476+
}
477+
if (support.isArchived()) {
478+
throw new Exception("Unable to locate an unarchived support RIM.");
479+
} else {
480+
this.referenceManifestRepository.save(support);
481+
}
482+
} else {
483+
support.setDeviceName(dv.getNw().getHostname());
484+
this.referenceManifestRepository.save(support);
485+
}
486+
} catch (IOException ioEx) {
487+
log.error(ioEx);
488+
} catch (Exception ex) {
489+
log.error(String.format("Failed to load support rim: %s", ex.getMessage()));
490+
}
491+
}
492+
} else {
493+
log.warn(String.format("%s did not send support RIM file...",
494+
dv.getNw().getHostname()));
495+
}
496+
433497
//update Support RIMs and Base RIMs.
434498
for (ByteString swidFile : dv.getSwidfileList()) {
435499
dbBaseRim = (BaseReferenceManifest) referenceManifestRepository

HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ public RedirectView delete(@RequestParam final String id,
239239
messages.addError(notFoundMessage);
240240
log.warn(notFoundMessage);
241241
} else {
242-
// if support rim, update associated events
243-
referenceManifest.archive();
244-
referenceManifestRepository.save(referenceManifest);
242+
referenceManifestRepository.delete(referenceManifest);
245243
String deleteCompletedMessage = "RIM successfully deleted";
246244
messages.addInfo(deleteCompletedMessage);
247245
log.info(deleteCompletedMessage);

HIRS_Provisioner.NET/hirs/HIRS_Provisioner.NET.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
77
<StartupObject>hirs.Program</StartupObject>
88
<PublishSingleFile>true</PublishSingleFile>
99
<ImplicitUsings>enable</ImplicitUsings>
1010
<Nullable>enable</Nullable>
11-
<PackageVersion>3.0.0</PackageVersion>
11+
<PackageVersion>3.0.1</PackageVersion>
1212
<Release></Release>
1313
</PropertyGroup>
1414

@@ -35,7 +35,7 @@
3535
<PackageReference Include="paccor.HardwareManifestPlugin" Version="1.0.0" />
3636
<PackageReference Include="paccor.HardwareManifestPluginManager" Version="1.0.0" />
3737
<PackageReference Include="paccor.paccor_scripts" Version="1.0.1" />
38-
<PackageReference Include="Packaging.Targets" Version="0.1.220">
38+
<PackageReference Include="Packaging.Targets" Version="0.1.226">
3939
<PrivateAssets>all</PrivateAssets> <!-- These assets will be consumed but won't flow to the parent project -->
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4141
</PackageReference>

HIRS_Provisioner.NET/hirsTest/hirsTest.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

package/win/tcg-rim-tool/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
This README is part of the ZIP_Files.zip generated from hirs_package_linux.yml the goal of this zip is to have the TCG RIM tool, and the TCG Eventlog tool available on windows.
2+
3+
To get the tools running on windows follow the instructions below:
4+
5+
1- Unzip "ZIP_Files"
6+
7+
2- open powershell as administrator and navigate to the hirstools folder.
8+
9+
3- run the following command: ```powershell -ExecutionPolicy Bypass -File '.\create_hirstools_desktop_shortcut.ps1'```
10+
11+
4- double-click the HIRS_tools shortcut on your desktop.
12+
13+
To run the rim tool try the following commands:
14+
15+
> rim -c base -a .\tcg_rim_tool\Base_Rim_Config.json -l .\tcg_rim_tool\TpmLog.bin -k .\tcg_rim_tool\PC_OEM1_rim_signer_rsa_3k_sha384.key -p .\tcg_rim_tool\PC_OEM1_rim_signer_rsa_3k_sha384.pem -o baseRim.swidtag
16+
17+
> rim -v .\baseRim.swidtag -p .\tcg_rim_tool\PC_OEM1_rim_signer_rsa_3k_sha384.pem -t .\tcg_rim_tool\PC_OEM1_Cert_Chain.pem -l .\tcg_rim_tool\TpmLog.bin
18+
19+
20+
21+
To run the eventlog tool:
22+
23+
elt -f C:\Windows\Logs\MeasuredBoot\[.log file here] -e
24+
25+
Eventlog files are found here windows:
26+
C:\Windows\Logs\MeasuredBoot
27+
28+
Example Command would be:
29+
> elt -f C:\Windows\Logs\MeasuredBoot\000000001-000000001.log -e (file name needs to match on on your system)

0 commit comments

Comments
 (0)