1+ # -*- coding: utf-8 -*-
2+ #
13# Copyright 2018 Google LLC
24#
35# Licensed under the Apache License, Version 2.0 (the "License");
1618import enum
1719
1820
21+ class ProtectionLevel (enum .IntEnum ):
22+ """
23+ ``ProtectionLevel`` specifies how cryptographic operations are performed.
24+
25+ Attributes:
26+ PROTECTION_LEVEL_UNSPECIFIED (int): Not specified.
27+ SOFTWARE (int): Crypto operations are performed in software.
28+ HSM (int): Crypto operations are performed in a Hardware Security Module.
29+ """
30+ PROTECTION_LEVEL_UNSPECIFIED = 0
31+ SOFTWARE = 1
32+ HSM = 2
33+
34+
1935class CryptoKey (object ):
2036 class CryptoKeyPurpose (enum .IntEnum ):
2137 """
22- ``CryptoKeyPurpose`` describes the capabilities of a ``CryptoKey``. Two
23- keys with the same purpose may use different underlying algorithms, but
24- must support the same set of operations .
38+ ``CryptoKeyPurpose`` describes the cryptographic capabilities of a
39+ ``CryptoKey``. A given key can only be used for the operations allowed by
40+ its purpose .
2541
2642 Attributes:
2743 CRYPTO_KEY_PURPOSE_UNSPECIFIED (int): Not specified.
2844 ENCRYPT_DECRYPT (int): ``CryptoKeys`` with this purpose may be used with
2945 ``Encrypt`` and
3046 ``Decrypt``.
47+ ASYMMETRIC_SIGN (int): ``CryptoKeys`` with this purpose may be used with
48+ ``AsymmetricSign`` and
49+ ``GetPublicKey``.
50+ ASYMMETRIC_DECRYPT (int): ``CryptoKeys`` with this purpose may be used with
51+ ``AsymmetricDecrypt`` and
52+ ``GetPublicKey``.
3153 """
3254 CRYPTO_KEY_PURPOSE_UNSPECIFIED = 0
3355 ENCRYPT_DECRYPT = 1
56+ ASYMMETRIC_SIGN = 5
57+ ASYMMETRIC_DECRYPT = 6
58+
59+
60+ class KeyOperationAttestation (object ):
61+ class AttestationFormat (enum .IntEnum ):
62+ """
63+ Attestion formats provided by the HSM.
64+
65+ Attributes:
66+ ATTESTATION_FORMAT_UNSPECIFIED (int)
67+ CAVIUM_V1_COMPRESSED (int): Cavium HSM attestation compressed with gzip. Note that this format is
68+ defined by Cavium and subject to change at any time.
69+ """
70+ ATTESTATION_FORMAT_UNSPECIFIED = 0
71+ CAVIUM_V1_COMPRESSED = 3
3472
3573
3674class CryptoKeyVersion (object ):
75+ class CryptoKeyVersionAlgorithm (enum .IntEnum ):
76+ """
77+ The algorithm of the ``CryptoKeyVersion``, indicating what
78+ parameters must be used for each cryptographic operation.
79+
80+ The
81+ ``GOOGLE_SYMMETRIC_ENCRYPTION``
82+ algorithm is usable with ``CryptoKey.purpose``
83+ ``ENCRYPT_DECRYPT``.
84+
85+ Algorithms beginning with \" RSA_SIGN_\" are usable with ``CryptoKey.purpose``
86+ ``ASYMMETRIC_SIGN``.
87+
88+ The fields in the name after \" RSA_SIGN_\" correspond to the following
89+ parameters: padding algorithm, modulus bit length, and digest algorithm.
90+
91+ For PSS, the salt length used is equal to the length of digest
92+ algorithm. For example,
93+ ``RSA_SIGN_PSS_2048_SHA256``
94+ will use PSS with a salt length of 256 bits or 32 bytes.
95+
96+ Algorithms beginning with \" RSA_DECRYPT_\" are usable with
97+ ``CryptoKey.purpose``
98+ ``ASYMMETRIC_DECRYPT``.
99+
100+ The fields in the name after \" RSA_DECRYPT_\" correspond to the following
101+ parameters: padding algorithm, modulus bit length, and digest algorithm.
102+
103+ Algorithms beginning with \" EC_SIGN_\" are usable with ``CryptoKey.purpose``
104+ ``ASYMMETRIC_SIGN``.
105+
106+ The fields in the name after \" EC_SIGN_\" correspond to the following
107+ parameters: elliptic curve, digest algorithm.
108+
109+ Attributes:
110+ CRYPTO_KEY_VERSION_ALGORITHM_UNSPECIFIED (int): Not specified.
111+ GOOGLE_SYMMETRIC_ENCRYPTION (int): Creates symmetric encryption keys.
112+ RSA_SIGN_PSS_2048_SHA256 (int): RSASSA-PSS 2048 bit key with a SHA256 digest.
113+ RSA_SIGN_PSS_3072_SHA256 (int): RSASSA-PSS 3072 bit key with a SHA256 digest.
114+ RSA_SIGN_PSS_4096_SHA256 (int): RSASSA-PSS 4096 bit key with a SHA256 digest.
115+ RSA_SIGN_PKCS1_2048_SHA256 (int): RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest.
116+ RSA_SIGN_PKCS1_3072_SHA256 (int): RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest.
117+ RSA_SIGN_PKCS1_4096_SHA256 (int): RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest.
118+ RSA_DECRYPT_OAEP_2048_SHA256 (int): RSAES-OAEP 2048 bit key with a SHA256 digest.
119+ RSA_DECRYPT_OAEP_3072_SHA256 (int): RSAES-OAEP 3072 bit key with a SHA256 digest.
120+ RSA_DECRYPT_OAEP_4096_SHA256 (int): RSAES-OAEP 4096 bit key with a SHA256 digest.
121+ EC_SIGN_P256_SHA256 (int): ECDSA on the NIST P-256 curve with a SHA256 digest.
122+ EC_SIGN_P384_SHA384 (int): ECDSA on the NIST P-384 curve with a SHA384 digest.
123+ """
124+ CRYPTO_KEY_VERSION_ALGORITHM_UNSPECIFIED = 0
125+ GOOGLE_SYMMETRIC_ENCRYPTION = 1
126+ RSA_SIGN_PSS_2048_SHA256 = 2
127+ RSA_SIGN_PSS_3072_SHA256 = 3
128+ RSA_SIGN_PSS_4096_SHA256 = 4
129+ RSA_SIGN_PKCS1_2048_SHA256 = 5
130+ RSA_SIGN_PKCS1_3072_SHA256 = 6
131+ RSA_SIGN_PKCS1_4096_SHA256 = 7
132+ RSA_DECRYPT_OAEP_2048_SHA256 = 8
133+ RSA_DECRYPT_OAEP_3072_SHA256 = 9
134+ RSA_DECRYPT_OAEP_4096_SHA256 = 10
135+ EC_SIGN_P256_SHA256 = 12
136+ EC_SIGN_P384_SHA384 = 13
137+
37138 class CryptoKeyVersionState (enum .IntEnum ):
38139 """
39140 The state of a ``CryptoKeyVersion``, indicating if it can be used.
40141
41142 Attributes:
42143 CRYPTO_KEY_VERSION_STATE_UNSPECIFIED (int): Not specified.
43- ENABLED (int): This version may be used in ``Encrypt`` and
44- ``Decrypt`` requests.
144+ PENDING_GENERATION (int): This version is still being generated. It may not be used, enabled,
145+ disabled, or destroyed yet. Cloud KMS will automatically mark this
146+ version ``ENABLED`` as soon as the version is ready.
147+ ENABLED (int): This version may be used for cryptographic operations.
45148 DISABLED (int): This version may not be used, but the key material is still available,
46149 and the version can be placed back into the ``ENABLED`` state.
47150 DESTROYED (int): This version is destroyed, and the key material is no longer stored.
@@ -52,7 +155,24 @@ class CryptoKeyVersionState(enum.IntEnum):
52155 to put it back into the ``DISABLED`` state.
53156 """
54157 CRYPTO_KEY_VERSION_STATE_UNSPECIFIED = 0
158+ PENDING_GENERATION = 5
55159 ENABLED = 1
56160 DISABLED = 2
57161 DESTROYED = 3
58162 DESTROY_SCHEDULED = 4
163+
164+ class CryptoKeyVersionView (enum .IntEnum ):
165+ """
166+ A view for ``CryptoKeyVersion``s. Controls the level of detail returned
167+ for ``CryptoKeyVersions`` in
168+ ``KeyManagementService.ListCryptoKeyVersions`` and
169+ ``KeyManagementService.ListCryptoKeys``.
170+
171+ Attributes:
172+ CRYPTO_KEY_VERSION_VIEW_UNSPECIFIED (int): Default view for each ``CryptoKeyVersion``. Does not include
173+ the ``attestation`` field.
174+ FULL (int): Provides all fields in each ``CryptoKeyVersion``, including the
175+ ``attestation``.
176+ """
177+ CRYPTO_KEY_VERSION_VIEW_UNSPECIFIED = 0
178+ FULL = 1
0 commit comments