-
Notifications
You must be signed in to change notification settings - Fork 8
Add Timestamp() to extract attestation timestamp #4
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?
Conversation
Timestamp()
to extract attestation timestamp
Timestamp()
to extract attestation timestamp// (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 |
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.
In go1.17 this line could be
return time.UnixMilli(int64(d.Timestamp)), nil
but I didn't want to bump the golang dependency.
timeToMillis := func(t time.Time) uint64 { | ||
return uint64(t.UnixNano() / 1e6) | ||
} |
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.
In go1.17 we could use time.UnixMilli
, but I didn't want to bump the go version
Yeah sure I'll have some time this weekend and check out this proposal! |
Overview
This PR adds the
Timestamp
function to extract the attestation timestamp, which can be used to setVerifyOptions.CurrentTime
toVerify
if 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.Verify
atdue to certificate expiration if
currentTime
exceeds anintermediates
certificateNot After
value.The
nitrite
library provides thenitrite.VerifyOptions.CurrentTime
to set thecurrentTime
used in certificate validation. We would like to set that time to attestationDocument.Timestamp
, butnitrite
does not currently export thecosePayload
to parse our theTimestamp
on the client.We propose to extend
nitrite
withfunc Timestamp(data []byte) (time.Time, error)
to extract the attestation timestamp on the client.Why is the proposed change useful in the
nitriding
libraryFor the client to extract attestation
Document.Timestamp
, the client needs tocbor.Unmarshal
anitrite.cosePayload
, which is not exported bynitrite
. While the client could redefine acosePayload
in its context, that is not very DRY and the client's definition ofcosePayload
could drift from the library. Alternatively,nitrite
could export theCOSEPayload
, but that is a more significant change to thenitrite
library 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
nitrite
interface and allows it to support the attestation archival use case with the existing options pattern.