Skip to content

Commit 58158d3

Browse files
feat: Added support for signed container image and custom audience and nonce requests (#11525)
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 5ad269d commit 58158d3

File tree

12 files changed

+204
-20
lines changed

12 files changed

+204
-20
lines changed

packages/google-cloud-confidentialcomputing/.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2020 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

packages/google-cloud-confidentialcomputing/CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ We support:
236236

237237
Supported versions can be found in our ``noxfile.py`` `config`_.
238238

239-
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/noxfile.py
239+
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-confidentialcomputing/noxfile.py
240240

241241

242242
**********

packages/google-cloud-confidentialcomputing/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2020 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

packages/google-cloud-confidentialcomputing/README.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,24 @@ In order to use this library, you first need to go through the following steps:
3636
Installation
3737
~~~~~~~~~~~~
3838

39-
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
40-
create isolated Python environments. The basic problem it addresses is one of
41-
dependencies and versions, and indirectly permissions.
39+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
40+
creates isolated Python environments. These isolated environments can have separate
41+
versions of Python packages, which allows you to isolate one project's dependencies
42+
from the dependencies of other projects.
4243

43-
With `virtualenv`_, it's possible to install this library without needing system
44+
With `venv`_, it's possible to install this library without needing system
4445
install permissions, and without clashing with the installed system
4546
dependencies.
4647

47-
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
48+
.. _`venv`: https://docs.python.org/3/library/venv.html
4849

4950

5051
Code samples and snippets
5152
~~~~~~~~~~~~~~~~~~~~~~~~~
5253

53-
Code samples and snippets live in the `samples/` folder.
54+
Code samples and snippets live in the `samples/`_ folder.
55+
56+
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-confidentialcomputing/samples
5457

5558

5659
Supported Python Versions
@@ -77,21 +80,19 @@ Mac/Linux
7780

7881
.. code-block:: console
7982
80-
pip install virtualenv
81-
virtualenv <your-env>
83+
python3 -m venv <your-env>
8284
source <your-env>/bin/activate
83-
<your-env>/bin/pip install google-cloud-confidentialcomputing
85+
pip install google-cloud-confidentialcomputing
8486
8587
8688
Windows
8789
^^^^^^^
8890

8991
.. code-block:: console
9092
91-
pip install virtualenv
92-
virtualenv <your-env>
93-
<your-env>\Scripts\activate
94-
<your-env>\Scripts\pip.exe install google-cloud-confidentialcomputing
93+
py -m venv <your-env>
94+
.\<your-env>\Scripts\activate
95+
pip install google-cloud-confidentialcomputing
9596
9697
Next Steps
9798
~~~~~~~~~~

packages/google-cloud-confidentialcomputing/docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2021 Google LLC
2+
# Copyright 2023 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-confidentialcomputing/google/cloud/confidentialcomputing/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
)
2727
from google.cloud.confidentialcomputing_v1.types.service import (
2828
Challenge,
29+
ConfidentialSpaceInfo,
30+
ContainerImageSignature,
2931
CreateChallengeRequest,
3032
GcpCredentials,
33+
SignedEntity,
34+
SigningAlgorithm,
35+
TokenOptions,
3136
TpmAttestation,
3237
VerifyAttestationRequest,
3338
VerifyAttestationResponse,
@@ -37,9 +42,14 @@
3742
"ConfidentialComputingClient",
3843
"ConfidentialComputingAsyncClient",
3944
"Challenge",
45+
"ConfidentialSpaceInfo",
46+
"ContainerImageSignature",
4047
"CreateChallengeRequest",
4148
"GcpCredentials",
49+
"SignedEntity",
50+
"TokenOptions",
4251
"TpmAttestation",
4352
"VerifyAttestationRequest",
4453
"VerifyAttestationResponse",
54+
"SigningAlgorithm",
4555
)

packages/google-cloud-confidentialcomputing/google/cloud/confidentialcomputing_v1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
)
2525
from .types.service import (
2626
Challenge,
27+
ConfidentialSpaceInfo,
28+
ContainerImageSignature,
2729
CreateChallengeRequest,
2830
GcpCredentials,
31+
SignedEntity,
32+
SigningAlgorithm,
33+
TokenOptions,
2934
TpmAttestation,
3035
VerifyAttestationRequest,
3136
VerifyAttestationResponse,
@@ -35,8 +40,13 @@
3540
"ConfidentialComputingAsyncClient",
3641
"Challenge",
3742
"ConfidentialComputingClient",
43+
"ConfidentialSpaceInfo",
44+
"ContainerImageSignature",
3845
"CreateChallengeRequest",
3946
"GcpCredentials",
47+
"SignedEntity",
48+
"SigningAlgorithm",
49+
"TokenOptions",
4050
"TpmAttestation",
4151
"VerifyAttestationRequest",
4252
"VerifyAttestationResponse",

packages/google-cloud-confidentialcomputing/google/cloud/confidentialcomputing_v1/types/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,28 @@
1515
#
1616
from .service import (
1717
Challenge,
18+
ConfidentialSpaceInfo,
19+
ContainerImageSignature,
1820
CreateChallengeRequest,
1921
GcpCredentials,
22+
SignedEntity,
23+
SigningAlgorithm,
24+
TokenOptions,
2025
TpmAttestation,
2126
VerifyAttestationRequest,
2227
VerifyAttestationResponse,
2328
)
2429

2530
__all__ = (
2631
"Challenge",
32+
"ConfidentialSpaceInfo",
33+
"ContainerImageSignature",
2734
"CreateChallengeRequest",
2835
"GcpCredentials",
36+
"SignedEntity",
37+
"TokenOptions",
2938
"TpmAttestation",
3039
"VerifyAttestationRequest",
3140
"VerifyAttestationResponse",
41+
"SigningAlgorithm",
3242
)

packages/google-cloud-confidentialcomputing/google/cloud/confidentialcomputing_v1/types/service.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,42 @@
2323
__protobuf__ = proto.module(
2424
package="google.cloud.confidentialcomputing.v1",
2525
manifest={
26+
"SigningAlgorithm",
2627
"Challenge",
2728
"CreateChallengeRequest",
2829
"VerifyAttestationRequest",
2930
"VerifyAttestationResponse",
3031
"GcpCredentials",
32+
"TokenOptions",
3133
"TpmAttestation",
34+
"ConfidentialSpaceInfo",
35+
"SignedEntity",
36+
"ContainerImageSignature",
3237
},
3338
)
3439

3540

41+
class SigningAlgorithm(proto.Enum):
42+
r"""SigningAlgorithm enumerates all the supported signing
43+
algorithms.
44+
45+
Values:
46+
SIGNING_ALGORITHM_UNSPECIFIED (0):
47+
Unspecified signing algorithm.
48+
RSASSA_PSS_SHA256 (1):
49+
RSASSA-PSS with a SHA256 digest.
50+
RSASSA_PKCS1V15_SHA256 (2):
51+
RSASSA-PKCS1 v1.5 with a SHA256 digest.
52+
ECDSA_P256_SHA256 (3):
53+
ECDSA on the P-256 Curve with a SHA256
54+
digest.
55+
"""
56+
SIGNING_ALGORITHM_UNSPECIFIED = 0
57+
RSASSA_PSS_SHA256 = 1
58+
RSASSA_PKCS1V15_SHA256 = 2
59+
ECDSA_P256_SHA256 = 3
60+
61+
3662
class Challenge(proto.Message):
3763
r"""A Challenge from the server used to guarantee freshness of
3864
attestations
@@ -124,6 +150,13 @@ class VerifyAttestationRequest(proto.Message):
124150
Required. The TPM-specific data provided by
125151
the attesting platform, used to populate any of
126152
the claims regarding platform state.
153+
confidential_space_info (google.cloud.confidentialcomputing_v1.types.ConfidentialSpaceInfo):
154+
Optional. Optional information related to the
155+
Confidential Space TEE.
156+
token_options (google.cloud.confidentialcomputing_v1.types.TokenOptions):
157+
Optional. A collection of optional,
158+
workload-specified claims that modify the token
159+
output.
127160
"""
128161

129162
challenge: str = proto.Field(
@@ -140,6 +173,16 @@ class VerifyAttestationRequest(proto.Message):
140173
number=3,
141174
message="TpmAttestation",
142175
)
176+
confidential_space_info: "ConfidentialSpaceInfo" = proto.Field(
177+
proto.MESSAGE,
178+
number=4,
179+
message="ConfidentialSpaceInfo",
180+
)
181+
token_options: "TokenOptions" = proto.Field(
182+
proto.MESSAGE,
183+
number=5,
184+
message="TokenOptions",
185+
)
143186

144187

145188
class VerifyAttestationResponse(proto.Message):
@@ -173,6 +216,32 @@ class GcpCredentials(proto.Message):
173216
)
174217

175218

219+
class TokenOptions(proto.Message):
220+
r"""Options to modify claims in the token to generate
221+
custom-purpose tokens.
222+
223+
Attributes:
224+
audience (str):
225+
Optional. Optional string to issue the token
226+
with a custom audience claim. Required if one or
227+
more nonces are specified.
228+
nonce (MutableSequence[str]):
229+
Optional. Optional parameter to place one or more nonces in
230+
the eat_nonce claim in the output token. The minimum size
231+
for JSON-encoded EATs is 10 bytes and the maximum size is 74
232+
bytes.
233+
"""
234+
235+
audience: str = proto.Field(
236+
proto.STRING,
237+
number=1,
238+
)
239+
nonce: MutableSequence[str] = proto.RepeatedField(
240+
proto.STRING,
241+
number=2,
242+
)
243+
244+
176245
class TpmAttestation(proto.Message):
177246
r"""TPM2 data containing everything necessary to validate any
178247
platform state measured into the TPM.
@@ -260,4 +329,88 @@ class Quote(proto.Message):
260329
)
261330

262331

332+
class ConfidentialSpaceInfo(proto.Message):
333+
r"""ConfidentialSpaceInfo contains information related to the
334+
Confidential Space TEE.
335+
336+
Attributes:
337+
signed_entities (MutableSequence[google.cloud.confidentialcomputing_v1.types.SignedEntity]):
338+
Optional. A list of signed entities
339+
containing container image signatures that can
340+
be used for server-side signature verification.
341+
"""
342+
343+
signed_entities: MutableSequence["SignedEntity"] = proto.RepeatedField(
344+
proto.MESSAGE,
345+
number=1,
346+
message="SignedEntity",
347+
)
348+
349+
350+
class SignedEntity(proto.Message):
351+
r"""SignedEntity represents an OCI image object containing
352+
everything necessary to verify container image signatures.
353+
354+
Attributes:
355+
container_image_signatures (MutableSequence[google.cloud.confidentialcomputing_v1.types.ContainerImageSignature]):
356+
Optional. A list of container image
357+
signatures attached to an OCI image object.
358+
"""
359+
360+
container_image_signatures: MutableSequence[
361+
"ContainerImageSignature"
362+
] = proto.RepeatedField(
363+
proto.MESSAGE,
364+
number=1,
365+
message="ContainerImageSignature",
366+
)
367+
368+
369+
class ContainerImageSignature(proto.Message):
370+
r"""ContainerImageSignature holds necessary metadata to verify a
371+
container image signature.
372+
373+
Attributes:
374+
payload (bytes):
375+
Required. The binary signature payload following the
376+
SimpleSigning format
377+
https://github.com/sigstore/cosign/blob/main/specs/SIGNATURE_SPEC.md#simple-signing.
378+
This payload includes the container image digest.
379+
signature (bytes):
380+
Required. A signature over the payload. The container image
381+
digest is incorporated into the signature as follows:
382+
383+
1. Generate a SimpleSigning format payload that includes the
384+
container image digest.
385+
2. Generate a signature over SHA256 digest of the payload.
386+
The signature generation process can be represented as
387+
follows:
388+
``Sign(sha256(SimpleSigningPayload(sha256(Image Manifest))))``
389+
public_key (bytes):
390+
Required. An associated public key used to
391+
verify the signature.
392+
sig_alg (google.cloud.confidentialcomputing_v1.types.SigningAlgorithm):
393+
Required. The algorithm used to produce the
394+
container image signature.
395+
"""
396+
397+
payload: bytes = proto.Field(
398+
proto.BYTES,
399+
number=1,
400+
)
401+
signature: bytes = proto.Field(
402+
proto.BYTES,
403+
number=2,
404+
)
405+
public_key: bytes = proto.Field(
406+
proto.BYTES,
407+
number=3,
408+
)
409+
sig_alg: "SigningAlgorithm" = proto.Field(
410+
proto.ENUM,
411+
number=4,
412+
enum="SigningAlgorithm",
413+
)
414+
415+
263416
__all__ = tuple(sorted(__protobuf__.manifest))

packages/google-cloud-confidentialcomputing/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2018 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)