Add Timestamp() to extract attestation timestamp#4
Open
Conversation
Timestamp() to extract attestation timestamp
Timestamp() to extract attestation timestamp
mwittie
commented
Aug 23, 2024
| // (p. 64) describes Timestamp as "UTC time when document was created, | ||
| // in milliseconds" | ||
| msec := int64(doc.Timestamp) | ||
| return time.Unix(msec/1e3, (msec%1e3)*1e6), nil |
Author
There was a problem hiding this comment.
In go1.17 this line could be
return time.UnixMilli(int64(d.Timestamp)), nilbut I didn't want to bump the golang dependency.
mwittie
commented
Aug 23, 2024
Comment on lines
+40
to
+42
| timeToMillis := func(t time.Time) uint64 { | ||
| return uint64(t.UnixNano() / 1e6) | ||
| } |
Author
There was a problem hiding this comment.
In go1.17 we could use time.UnixMilli, but I didn't want to bump the go version
Owner
|
Yeah sure I'll have some time this weekend and check out this proposal! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds the
Timestampfunction to extract the attestation timestamp, which can be used to setVerifyOptions.CurrentTimetoVerifyif an attestation was valid when it was created.Why we propose the change
Our application archives AWS Nitro Enclave attestations. We want to be able to verify these attestations at a future time. However, verifying an attestation at a future can fail in
nitrite.Verifyatdue to certificate expiration if
currentTimeexceeds anintermediatescertificateNot Aftervalue.The
nitritelibrary provides thenitrite.VerifyOptions.CurrentTimeto set thecurrentTimeused in certificate validation. We would like to set that time to attestationDocument.Timestamp, butnitritedoes not currently export thecosePayloadto parse our theTimestampon the client.We propose to extend
nitritewithfunc Timestamp(data []byte) (time.Time, error)to extract the attestation timestamp on the client.Why is the proposed change useful in the
nitridinglibraryFor the client to extract attestation
Document.Timestamp, the client needs tocbor.Unmarshalanitrite.cosePayload, which is not exported bynitrite. While the client could redefine acosePayloadin its context, that is not very DRY and the client's definition ofcosePayloadcould drift from the library. Alternatively,nitritecould export theCOSEPayload, but that is a more significant change to thenitritelibrary than our proposal. Either of these approaches put a burden on the client for extracting attestation information to feed it back tonitrite, while replicating attestation parsing functionality that is already implemented bynitrite.Adding the Timestamp function augments the existing
nitriteinterface and allows it to support the attestation archival use case with the existing options pattern.