1- // Package fake provides a FakeAttestor that produces structurally valid
1+ // Package fake provides an Attestor that produces structurally valid
22// COSE Sign1 attestation documents. These documents pass nitrite.Verify's
33// full validation chain (CBOR parsing, cert chain, ECDSA signature, UserData,
44// PCRs) without requiring real Nitro hardware.
@@ -21,9 +21,9 @@ import (
2121 "github.com/fxamacker/cbor/v2"
2222)
2323
24- // FakeAttestor produces structurally valid COSE Sign1 attestation documents
24+ // Attestor produces structurally valid COSE Sign1 attestation documents
2525// that pass nitrite.Verify with a custom CA root.
26- type FakeAttestor struct {
26+ type Attestor struct {
2727 rootKey * ecdsa.PrivateKey
2828 rootCert * x509.Certificate
2929 rootCertDER []byte
@@ -33,9 +33,9 @@ type FakeAttestor struct {
3333 pcrs map [uint ][]byte
3434}
3535
36- // NewFakeAttestor generates a self-signed P-384 root CA, a leaf cert signed
36+ // NewAttestor generates a self-signed P-384 root CA, a leaf cert signed
3737// by that root, and deterministic 48-byte fake PCR values.
38- func NewFakeAttestor () (* FakeAttestor , error ) {
38+ func NewAttestor () (* Attestor , error ) {
3939 rootKey , err := ecdsa .GenerateKey (elliptic .P384 (), rand .Reader )
4040 if err != nil {
4141 return nil , fmt .Errorf ("generate root key: %w" , err )
@@ -86,7 +86,7 @@ func NewFakeAttestor() (*FakeAttestor, error) {
8686 2 : sha384Sum ([]byte ("fake-pcr-2" )),
8787 }
8888
89- return & FakeAttestor {
89+ return & Attestor {
9090 rootKey : rootKey ,
9191 rootCert : rootCert ,
9292 rootCertDER : rootCertDER ,
@@ -99,10 +99,10 @@ func NewFakeAttestor() (*FakeAttestor, error) {
9999
100100// CreateAttestation builds a COSE Sign1 document encoding a Nitro-like
101101// attestation with the given userData.
102- func (f * FakeAttestor ) CreateAttestation (userData []byte ) ([]byte , error ) {
102+ func (f * Attestor ) CreateAttestation (userData []byte ) ([]byte , error ) {
103103 doc := attestationDocument {
104104 ModuleID : "fake-enclave-module" ,
105- Timestamp : uint64 (time .Now ().UnixMilli ()),
105+ Timestamp : uint64 (time .Now ().UnixMilli ()), //nolint:gosec // timestamp is always positive
106106 Digest : "SHA384" ,
107107 PCRs : f .pcrs ,
108108 Certificate : f .leafCertDER ,
@@ -157,14 +157,14 @@ func (f *FakeAttestor) CreateAttestation(userData []byte) ([]byte, error) {
157157}
158158
159159// CARoots returns an x509.CertPool containing the fake root CA certificate.
160- func (f * FakeAttestor ) CARoots () * x509.CertPool {
160+ func (f * Attestor ) CARoots () * x509.CertPool {
161161 pool := x509 .NewCertPool ()
162162 pool .AddCert (f .rootCert )
163163 return pool
164164}
165165
166166// CARootsPEM returns the root CA certificate in PEM format.
167- func (f * FakeAttestor ) CARootsPEM () string {
167+ func (f * Attestor ) CARootsPEM () string {
168168 return string (pem .EncodeToMemory (& pem.Block {
169169 Type : "CERTIFICATE" ,
170170 Bytes : f .rootCertDER ,
@@ -173,7 +173,7 @@ func (f *FakeAttestor) CARootsPEM() string {
173173
174174// TrustedPCRsJSON returns the PCR values as a JSON object matching the
175175// format expected by the attestation validator.
176- func (f * FakeAttestor ) TrustedPCRsJSON () []byte {
176+ func (f * Attestor ) TrustedPCRsJSON () []byte {
177177 m := map [string ]string {
178178 "pcr0" : hex .EncodeToString (f .pcrs [0 ]),
179179 "pcr1" : hex .EncodeToString (f .pcrs [1 ]),
@@ -206,15 +206,15 @@ type coseHeader struct {
206206}
207207
208208type cosePayload struct {
209- _ struct {} `cbor:",toarray"`
209+ _ struct {} `cbor:",toarray"` //nolint:revive // idiomatic CBOR array encoding
210210 Protected []byte
211211 Unprotected cbor.RawMessage
212212 Payload []byte
213213 Signature []byte
214214}
215215
216216type coseSignature struct {
217- _ struct {} `cbor:",toarray"`
217+ _ struct {} `cbor:",toarray"` //nolint:revive // idiomatic CBOR array encoding
218218 Context string
219219 Protected []byte
220220 ExternalAAD []byte
0 commit comments