google-cloud-kms-v1 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,7 +256,7 @@ module Google
256
256
  credentials = @config.credentials
257
257
  # Use self-signed JWT if the endpoint is unchanged from default,
258
258
  # but only if the default endpoint does not have a region prefix.
259
- enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
259
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
260
260
  !@config.endpoint.split(".").first.include?("-")
261
261
  credentials ||= Credentials.default scope: @config.scope,
262
262
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -2033,6 +2033,286 @@ module Google
2033
2033
  raise ::Google::Cloud::Error.from_error(e)
2034
2034
  end
2035
2035
 
2036
+ ##
2037
+ # Encrypts data using portable cryptographic primitives. Most users should
2038
+ # choose {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client#encrypt Encrypt} and
2039
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client#decrypt Decrypt} rather than
2040
+ # their raw counterparts. The
2041
+ # {::Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose} must be
2042
+ # {::Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::RAW_ENCRYPT_DECRYPT RAW_ENCRYPT_DECRYPT}.
2043
+ #
2044
+ # @overload raw_encrypt(request, options = nil)
2045
+ # Pass arguments to `raw_encrypt` via a request object, either of type
2046
+ # {::Google::Cloud::Kms::V1::RawEncryptRequest} or an equivalent Hash.
2047
+ #
2048
+ # @param request [::Google::Cloud::Kms::V1::RawEncryptRequest, ::Hash]
2049
+ # A request object representing the call parameters. Required. To specify no
2050
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2051
+ # @param options [::Gapic::CallOptions, ::Hash]
2052
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2053
+ #
2054
+ # @overload raw_encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil, plaintext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector: nil, initialization_vector_crc32c: nil)
2055
+ # Pass arguments to `raw_encrypt` via keyword arguments. Note that at
2056
+ # least one keyword argument is required. To specify no parameters, or to keep all
2057
+ # the default parameter values, pass an empty Hash as a request object (see above).
2058
+ #
2059
+ # @param name [::String]
2060
+ # Required. The resource name of the
2061
+ # {::Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for
2062
+ # encryption.
2063
+ # @param plaintext [::String]
2064
+ # Required. The data to encrypt. Must be no larger than 64KiB.
2065
+ #
2066
+ # The maximum size depends on the key version's
2067
+ # {::Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}.
2068
+ # For {::Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the
2069
+ # plaintext must be no larger than 64KiB. For
2070
+ # {::Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of
2071
+ # the plaintext and additional_authenticated_data fields must be no larger
2072
+ # than 8KiB.
2073
+ # @param additional_authenticated_data [::String]
2074
+ # Optional. Optional data that, if specified, must also be provided during
2075
+ # decryption through
2076
+ # {::Google::Cloud::Kms::V1::RawDecryptRequest#additional_authenticated_data RawDecryptRequest.additional_authenticated_data}.
2077
+ #
2078
+ # This field may only be used in conjunction with an
2079
+ # {::Google::Cloud::Kms::V1::CryptoKeyVersion#algorithm algorithm} that accepts
2080
+ # additional authenticated data (for example, AES-GCM).
2081
+ #
2082
+ # The maximum size depends on the key version's
2083
+ # {::Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}.
2084
+ # For {::Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the
2085
+ # plaintext must be no larger than 64KiB. For
2086
+ # {::Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of
2087
+ # the plaintext and additional_authenticated_data fields must be no larger
2088
+ # than 8KiB.
2089
+ # @param plaintext_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2090
+ # Optional. An optional CRC32C checksum of the
2091
+ # {::Google::Cloud::Kms::V1::RawEncryptRequest#plaintext RawEncryptRequest.plaintext}.
2092
+ # If specified,
2093
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2094
+ # verify the integrity of the received plaintext using this checksum.
2095
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2096
+ # report an error if the checksum verification fails. If you receive a
2097
+ # checksum error, your client should verify that CRC32C(plaintext) is equal
2098
+ # to plaintext_crc32c, and if so, perform a limited number of retries. A
2099
+ # persistent mismatch may indicate an issue in your computation of the CRC32C
2100
+ # checksum. Note: This field is defined as int64 for reasons of compatibility
2101
+ # across different languages. However, it is a non-negative integer, which
2102
+ # will never exceed 2^32-1, and can be safely downconverted to uint32 in
2103
+ # languages that support this type.
2104
+ # @param additional_authenticated_data_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2105
+ # Optional. An optional CRC32C checksum of the
2106
+ # {::Google::Cloud::Kms::V1::RawEncryptRequest#additional_authenticated_data RawEncryptRequest.additional_authenticated_data}.
2107
+ # If specified,
2108
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2109
+ # verify the integrity of the received additional_authenticated_data using
2110
+ # this checksum.
2111
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2112
+ # report an error if the checksum verification fails. If you receive a
2113
+ # checksum error, your client should verify that
2114
+ # CRC32C(additional_authenticated_data) is equal to
2115
+ # additional_authenticated_data_crc32c, and if so, perform
2116
+ # a limited number of retries. A persistent mismatch may indicate an issue in
2117
+ # your computation of the CRC32C checksum.
2118
+ # Note: This field is defined as int64 for reasons of compatibility across
2119
+ # different languages. However, it is a non-negative integer, which will
2120
+ # never exceed 2^32-1, and can be safely downconverted to uint32 in languages
2121
+ # that support this type.
2122
+ # @param initialization_vector [::String]
2123
+ # Optional. A customer-supplied initialization vector that will be used for
2124
+ # encryption. If it is not provided for AES-CBC and AES-CTR, one will be
2125
+ # generated. It will be returned in
2126
+ # {::Google::Cloud::Kms::V1::RawEncryptResponse#initialization_vector RawEncryptResponse.initialization_vector}.
2127
+ # @param initialization_vector_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2128
+ # Optional. An optional CRC32C checksum of the
2129
+ # {::Google::Cloud::Kms::V1::RawEncryptRequest#initialization_vector RawEncryptRequest.initialization_vector}.
2130
+ # If specified,
2131
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2132
+ # verify the integrity of the received initialization_vector using this
2133
+ # checksum. {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService}
2134
+ # will report an error if the checksum verification fails. If you receive a
2135
+ # checksum error, your client should verify that
2136
+ # CRC32C(initialization_vector) is equal to
2137
+ # initialization_vector_crc32c, and if so, perform
2138
+ # a limited number of retries. A persistent mismatch may indicate an issue in
2139
+ # your computation of the CRC32C checksum.
2140
+ # Note: This field is defined as int64 for reasons of compatibility across
2141
+ # different languages. However, it is a non-negative integer, which will
2142
+ # never exceed 2^32-1, and can be safely downconverted to uint32 in languages
2143
+ # that support this type.
2144
+ # @yield [result, operation] Access the result along with the TransportOperation object
2145
+ # @yieldparam result [::Google::Cloud::Kms::V1::RawEncryptResponse]
2146
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
2147
+ #
2148
+ # @return [::Google::Cloud::Kms::V1::RawEncryptResponse]
2149
+ #
2150
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
2151
+ def raw_encrypt request, options = nil
2152
+ raise ::ArgumentError, "request must be provided" if request.nil?
2153
+
2154
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::RawEncryptRequest
2155
+
2156
+ # Converts hash and nil to an options object
2157
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2158
+
2159
+ # Customize the options with defaults
2160
+ call_metadata = @config.rpcs.raw_encrypt.metadata.to_h
2161
+
2162
+ # Set x-goog-api-client and x-goog-user-project headers
2163
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2164
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2165
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION,
2166
+ transports_version_send: [:rest]
2167
+
2168
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2169
+
2170
+ options.apply_defaults timeout: @config.rpcs.raw_encrypt.timeout,
2171
+ metadata: call_metadata,
2172
+ retry_policy: @config.rpcs.raw_encrypt.retry_policy
2173
+
2174
+ options.apply_defaults timeout: @config.timeout,
2175
+ metadata: @config.metadata,
2176
+ retry_policy: @config.retry_policy
2177
+
2178
+ @key_management_service_stub.raw_encrypt request, options do |result, operation|
2179
+ yield result, operation if block_given?
2180
+ return result
2181
+ end
2182
+ rescue ::Gapic::Rest::Error => e
2183
+ raise ::Google::Cloud::Error.from_error(e)
2184
+ end
2185
+
2186
+ ##
2187
+ # Decrypts data that was originally encrypted using a raw cryptographic
2188
+ # mechanism. The {::Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose}
2189
+ # must be
2190
+ # {::Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::RAW_ENCRYPT_DECRYPT RAW_ENCRYPT_DECRYPT}.
2191
+ #
2192
+ # @overload raw_decrypt(request, options = nil)
2193
+ # Pass arguments to `raw_decrypt` via a request object, either of type
2194
+ # {::Google::Cloud::Kms::V1::RawDecryptRequest} or an equivalent Hash.
2195
+ #
2196
+ # @param request [::Google::Cloud::Kms::V1::RawDecryptRequest, ::Hash]
2197
+ # A request object representing the call parameters. Required. To specify no
2198
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2199
+ # @param options [::Gapic::CallOptions, ::Hash]
2200
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2201
+ #
2202
+ # @overload raw_decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil, initialization_vector: nil, tag_length: nil, ciphertext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector_crc32c: nil)
2203
+ # Pass arguments to `raw_decrypt` via keyword arguments. Note that at
2204
+ # least one keyword argument is required. To specify no parameters, or to keep all
2205
+ # the default parameter values, pass an empty Hash as a request object (see above).
2206
+ #
2207
+ # @param name [::String]
2208
+ # Required. The resource name of the
2209
+ # {::Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for
2210
+ # decryption.
2211
+ # @param ciphertext [::String]
2212
+ # Required. The encrypted data originally returned in
2213
+ # {::Google::Cloud::Kms::V1::RawEncryptResponse#ciphertext RawEncryptResponse.ciphertext}.
2214
+ # @param additional_authenticated_data [::String]
2215
+ # Optional. Optional data that must match the data originally supplied in
2216
+ # {::Google::Cloud::Kms::V1::RawEncryptRequest#additional_authenticated_data RawEncryptRequest.additional_authenticated_data}.
2217
+ # @param initialization_vector [::String]
2218
+ # Required. The initialization vector (IV) used during encryption, which must
2219
+ # match the data originally provided in
2220
+ # {::Google::Cloud::Kms::V1::RawEncryptResponse#initialization_vector RawEncryptResponse.initialization_vector}.
2221
+ # @param tag_length [::Integer]
2222
+ # The length of the authentication tag that is appended to the end of
2223
+ # the ciphertext. If unspecified (0), the default value for the key's
2224
+ # algorithm will be used (for AES-GCM, the default value is 16).
2225
+ # @param ciphertext_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2226
+ # Optional. An optional CRC32C checksum of the
2227
+ # {::Google::Cloud::Kms::V1::RawDecryptRequest#ciphertext RawDecryptRequest.ciphertext}.
2228
+ # If specified,
2229
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2230
+ # verify the integrity of the received ciphertext using this checksum.
2231
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2232
+ # report an error if the checksum verification fails. If you receive a
2233
+ # checksum error, your client should verify that CRC32C(ciphertext) is equal
2234
+ # to ciphertext_crc32c, and if so, perform a limited number of retries. A
2235
+ # persistent mismatch may indicate an issue in your computation of the CRC32C
2236
+ # checksum. Note: This field is defined as int64 for reasons of compatibility
2237
+ # across different languages. However, it is a non-negative integer, which
2238
+ # will never exceed 2^32-1, and can be safely downconverted to uint32 in
2239
+ # languages that support this type.
2240
+ # @param additional_authenticated_data_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2241
+ # Optional. An optional CRC32C checksum of the
2242
+ # {::Google::Cloud::Kms::V1::RawDecryptRequest#additional_authenticated_data RawDecryptRequest.additional_authenticated_data}.
2243
+ # If specified,
2244
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2245
+ # verify the integrity of the received additional_authenticated_data using
2246
+ # this checksum.
2247
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2248
+ # report an error if the checksum verification fails. If you receive a
2249
+ # checksum error, your client should verify that
2250
+ # CRC32C(additional_authenticated_data) is equal to
2251
+ # additional_authenticated_data_crc32c, and if so, perform
2252
+ # a limited number of retries. A persistent mismatch may indicate an issue in
2253
+ # your computation of the CRC32C checksum.
2254
+ # Note: This field is defined as int64 for reasons of compatibility across
2255
+ # different languages. However, it is a non-negative integer, which will
2256
+ # never exceed 2^32-1, and can be safely downconverted to uint32 in languages
2257
+ # that support this type.
2258
+ # @param initialization_vector_crc32c [::Google::Protobuf::Int64Value, ::Hash]
2259
+ # Optional. An optional CRC32C checksum of the
2260
+ # {::Google::Cloud::Kms::V1::RawDecryptRequest#initialization_vector RawDecryptRequest.initialization_vector}.
2261
+ # If specified,
2262
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService} will
2263
+ # verify the integrity of the received initialization_vector using this
2264
+ # checksum. {::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client KeyManagementService}
2265
+ # will report an error if the checksum verification fails. If you receive a
2266
+ # checksum error, your client should verify that
2267
+ # CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and
2268
+ # if so, perform a limited number of retries. A persistent mismatch may
2269
+ # indicate an issue in your computation of the CRC32C checksum.
2270
+ # Note: This field is defined as int64 for reasons of compatibility across
2271
+ # different languages. However, it is a non-negative integer, which will
2272
+ # never exceed 2^32-1, and can be safely downconverted to uint32 in languages
2273
+ # that support this type.
2274
+ # @yield [result, operation] Access the result along with the TransportOperation object
2275
+ # @yieldparam result [::Google::Cloud::Kms::V1::RawDecryptResponse]
2276
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
2277
+ #
2278
+ # @return [::Google::Cloud::Kms::V1::RawDecryptResponse]
2279
+ #
2280
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
2281
+ def raw_decrypt request, options = nil
2282
+ raise ::ArgumentError, "request must be provided" if request.nil?
2283
+
2284
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::RawDecryptRequest
2285
+
2286
+ # Converts hash and nil to an options object
2287
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2288
+
2289
+ # Customize the options with defaults
2290
+ call_metadata = @config.rpcs.raw_decrypt.metadata.to_h
2291
+
2292
+ # Set x-goog-api-client and x-goog-user-project headers
2293
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2294
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2295
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION,
2296
+ transports_version_send: [:rest]
2297
+
2298
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2299
+
2300
+ options.apply_defaults timeout: @config.rpcs.raw_decrypt.timeout,
2301
+ metadata: call_metadata,
2302
+ retry_policy: @config.rpcs.raw_decrypt.retry_policy
2303
+
2304
+ options.apply_defaults timeout: @config.timeout,
2305
+ metadata: @config.metadata,
2306
+ retry_policy: @config.retry_policy
2307
+
2308
+ @key_management_service_stub.raw_decrypt request, options do |result, operation|
2309
+ yield result, operation if block_given?
2310
+ return result
2311
+ end
2312
+ rescue ::Gapic::Rest::Error => e
2313
+ raise ::Google::Cloud::Error.from_error(e)
2314
+ end
2315
+
2036
2316
  ##
2037
2317
  # Signs data using a {::Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
2038
2318
  # with {::Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose}
@@ -2587,7 +2867,9 @@ module Google
2587
2867
  class Configuration
2588
2868
  extend ::Gapic::Config
2589
2869
 
2590
- config_attr :endpoint, "cloudkms.googleapis.com", ::String
2870
+ DEFAULT_ENDPOINT = "cloudkms.googleapis.com"
2871
+
2872
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
2591
2873
  config_attr :credentials, nil do |value|
2592
2874
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2593
2875
  allowed.any? { |klass| klass === value }
@@ -2750,6 +3032,16 @@ module Google
2750
3032
  #
2751
3033
  attr_reader :decrypt
2752
3034
  ##
3035
+ # RPC-specific configuration for `raw_encrypt`
3036
+ # @return [::Gapic::Config::Method]
3037
+ #
3038
+ attr_reader :raw_encrypt
3039
+ ##
3040
+ # RPC-specific configuration for `raw_decrypt`
3041
+ # @return [::Gapic::Config::Method]
3042
+ #
3043
+ attr_reader :raw_decrypt
3044
+ ##
2753
3045
  # RPC-specific configuration for `asymmetric_sign`
2754
3046
  # @return [::Gapic::Config::Method]
2755
3047
  #
@@ -2819,6 +3111,10 @@ module Google
2819
3111
  @encrypt = ::Gapic::Config::Method.new encrypt_config
2820
3112
  decrypt_config = parent_rpcs.decrypt if parent_rpcs.respond_to? :decrypt
2821
3113
  @decrypt = ::Gapic::Config::Method.new decrypt_config
3114
+ raw_encrypt_config = parent_rpcs.raw_encrypt if parent_rpcs.respond_to? :raw_encrypt
3115
+ @raw_encrypt = ::Gapic::Config::Method.new raw_encrypt_config
3116
+ raw_decrypt_config = parent_rpcs.raw_decrypt if parent_rpcs.respond_to? :raw_decrypt
3117
+ @raw_decrypt = ::Gapic::Config::Method.new raw_decrypt_config
2822
3118
  asymmetric_sign_config = parent_rpcs.asymmetric_sign if parent_rpcs.respond_to? :asymmetric_sign
2823
3119
  @asymmetric_sign = ::Gapic::Config::Method.new asymmetric_sign_config
2824
3120
  asymmetric_decrypt_config = parent_rpcs.asymmetric_decrypt if parent_rpcs.respond_to? :asymmetric_decrypt