From b5d944c92b2f2e252bae1242fbbf45c39fcb9808 Mon Sep 17 00:00:00 2001 From: Philipp Winter Date: Mon, 14 Oct 2024 06:53:02 -0500 Subject: [PATCH] Refactor comments. --- internal/nonce/nonce.go | 8 ++++++-- internal/service/attestation/aux.go | 2 -- internal/service/attestation/hashes.go | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/nonce/nonce.go b/internal/nonce/nonce.go index aff7253..7e96061 100644 --- a/internal/nonce/nonce.go +++ b/internal/nonce/nonce.go @@ -9,7 +9,8 @@ import ( "github.com/Amnesic-Systems/veil/internal/errs" ) -const Len = 20 // The length of a nonce in bytes. +// Len is the length of a nonce in bytes. +const Len = 20 var ( // Accessing rand.Reader via variable facilitates mocking. @@ -17,16 +18,18 @@ var ( errNotEnoughRead = errors.New("failed to read enough random bytes") ) +// Nonce is a random value that guarantees attestation document freshness. type Nonce [Len]byte +// URLEncode returns the nonce as a URL-encoded string. func (n *Nonce) URLEncode() string { return url.QueryEscape( base64.StdEncoding.EncodeToString(n[:]), ) } +// New creates a new nonce. func New() (*Nonce, error) { - // TODO: panic on error cause we may not be able to recover? var newNonce Nonce n, err := cryptoRead.Read(newNonce[:]) if err != nil { @@ -38,6 +41,7 @@ func New() (*Nonce, error) { return &newNonce, nil } +// FromSlice turns a byte slice into a nonce. func FromSlice(s []byte) (*Nonce, error) { if len(s) != Len { return nil, errs.InvalidLength diff --git a/internal/service/attestation/aux.go b/internal/service/attestation/aux.go index f258c99..3260a0f 100644 --- a/internal/service/attestation/aux.go +++ b/internal/service/attestation/aux.go @@ -1,7 +1,5 @@ package attestation -// TODO: does this belong in the enclave package? - import ( "slices" diff --git a/internal/service/attestation/hashes.go b/internal/service/attestation/hashes.go index bf7ce2f..fc8687d 100644 --- a/internal/service/attestation/hashes.go +++ b/internal/service/attestation/hashes.go @@ -14,8 +14,6 @@ import ( // the enclave's attestation document for clients to verify. type Hashes struct { sync.Mutex - // TODO: is this better off in models? model.AttestationHashes sounds less - // nice though TlsKeyHash [sha256.Size]byte `json:"tls_key_hash"` // Always set. AppKeyHash [sha256.Size]byte `json:"app_key_hash"` // Only set if the application has keys. }