-
Notifications
You must be signed in to change notification settings - Fork 62
[#1090] Fix ACA Provisioning Issue When Using ECC Key #1127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 34 commits
8964f31
331328b
553ba00
879ec7e
9d14600
f7969bc
4f1e778
cc01535
40bd091
45471b0
6527bc0
6169988
ac90e40
b3b0259
ad14f48
9da7763
a0a49b4
fc79f20
72393a2
a190682
8f256fd
c55528c
b368c91
ac0ec5c
5e57027
7fb5757
1c796c5
35be596
fb47a66
335c42c
7e8307a
51d284d
582911e
d567049
252dedc
e63a30e
68b1a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| package hirs.attestationca.persist.entity.tpm; | ||
|
|
||
| import hirs.attestationca.persist.entity.manager.TPM2ProvisionerStateRepository; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Id; | ||
|
|
@@ -15,15 +14,17 @@ | |
| import java.util.Date; | ||
|
|
||
| /** | ||
| * This class is for saving the Identity Claim and the Nonce between the two passes of the | ||
| * TPM 2.0 Provisioner. | ||
| * This class is for saving the Identity Claim and the Nonce between the two passes of the TPM 2.0 Provisioner. | ||
| */ | ||
| @Log4j2 | ||
| @NoArgsConstructor | ||
| @Entity | ||
| public class TPM2ProvisionerState { | ||
| private static final int MAX_BLOB_SIZE = 16777215; | ||
|
|
||
| @Column(nullable = false) | ||
| private final Date timestamp = new Date(); | ||
|
|
||
| @Id | ||
| private Long firstPartOfNonce; | ||
|
|
||
|
|
@@ -34,9 +35,6 @@ public class TPM2ProvisionerState { | |
| @Column(nullable = false, length = MAX_BLOB_SIZE) | ||
| private byte[] identityClaim; | ||
|
|
||
| @Column(nullable = false) | ||
| private final Date timestamp = new Date(); | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
|
|
@@ -69,34 +67,6 @@ public TPM2ProvisionerState(final byte[] nonce, final byte[] identityClaim) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Convenience method for finding the {@link TPM2ProvisionerState} associated with the nonce. | ||
| * | ||
| * @param tpm2ProvisionerStateRepository the {@link TPM2ProvisionerStateRepository} | ||
| * to use when looking for the | ||
| * {@link TPM2ProvisionerState} | ||
| * @param nonce the nonce to use as the key for the {@link TPM2ProvisionerState} | ||
| * @return the {@link TPM2ProvisionerState} associated with the nonce; | ||
| * null if a match is not found | ||
| */ | ||
| public static TPM2ProvisionerState getTPM2ProvisionerState( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is used by one service class and a test class, so it was moved to a service responsible for managing the TpmState object. Additionally, it was removed from the entity because having a static method that takes in a repository breaks the separation of concerns and mixes persistence logic with the entity. |
||
| final TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository, | ||
| final byte[] nonce) { | ||
| try (DataInputStream dis | ||
| = new DataInputStream(new ByteArrayInputStream(nonce))) { | ||
| long firstPartOfNonce = dis.readLong(); | ||
| TPM2ProvisionerState stateFound = tpm2ProvisionerStateRepository | ||
| .findByFirstPartOfNonce(firstPartOfNonce); | ||
| if (stateFound != null && Arrays.areEqual(stateFound.getNonce(), nonce)) { | ||
| return stateFound; | ||
| } | ||
| } catch (IOException ioEx) { | ||
| log.error(ioEx.getMessage()); | ||
| return null; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Get the nonce. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need to exclude a test from the test classes since the SpotBug error has been addressed