aws_sdk_kms/operation/verify/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::verify::_verify_output::VerifyOutputBuilder;
3
4pub use crate::operation::verify::_verify_input::VerifyInputBuilder;
5
6impl crate::operation::verify::builders::VerifyInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::verify::VerifyOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::verify::VerifyError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.verify();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `Verify`.
24///
25/// <p>Verifies a digital signature that was generated by the <code>Sign</code> operation.</p>
26/// <p></p>
27/// <p>Verification confirms that an authorized user signed the message with the specified KMS key and signing algorithm, and the message hasn't changed since it was signed. If the signature is verified, the value of the <code>SignatureValid</code> field in the response is <code>True</code>. If the signature verification fails, the <code>Verify</code> operation fails with an <code>KMSInvalidSignatureException</code> exception.</p>
28/// <p>A digital signature is generated by using the private key in an asymmetric KMS key. The signature is verified by using the public key in the same asymmetric KMS key. For information about asymmetric KMS keys, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric KMS keys</a> in the <i>Key Management Service Developer Guide</i>.</p>
29/// <p>To use the <code>Verify</code> operation, specify the same asymmetric KMS key, message, and signing algorithm that were used to produce the signature. The message type does not need to be the same as the one used for signing, but it must indicate whether the value of the <code>Message</code> parameter should be hashed as part of the verification process.</p>
30/// <p>You can also verify the digital signature by using the public key of the KMS key outside of KMS. Use the <code>GetPublicKey</code> operation to download the public key in the asymmetric KMS key and then use the public key to verify the signature outside of KMS. The advantage of using the <code>Verify</code> operation is that it is performed within KMS. As a result, it's easy to call, the operation is performed within the FIPS boundary, it is logged in CloudTrail, and you can use key policy and IAM policy to determine who is authorized to use the KMS key to verify signatures.</p>
31/// <p>To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses <code>1234567812345678</code> as the distinguishing ID. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-sm-offline-verification">Offline verification with SM2 key pairs</a>.</p>
32/// <p>The KMS key that you use for this operation must be in a compatible key state. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">Key states of KMS keys</a> in the <i>Key Management Service Developer Guide</i>.</p>
33/// <p><b>Cross-account use</b>: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the <code>KeyId</code> parameter.</p>
34/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:Verify</a> (key policy)</p>
35/// <p><b>Related operations</b>: <code>Sign</code></p>
36/// <p><b>Eventual consistency</b>: The KMS API follows an eventual consistency model. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-eventual-consistency.html">KMS eventual consistency</a>.</p>
37#[derive(::std::clone::Clone, ::std::fmt::Debug)]
38pub struct VerifyFluentBuilder {
39 handle: ::std::sync::Arc<crate::client::Handle>,
40 inner: crate::operation::verify::builders::VerifyInputBuilder,
41 config_override: ::std::option::Option<crate::config::Builder>,
42}
43impl crate::client::customize::internal::CustomizableSend<crate::operation::verify::VerifyOutput, crate::operation::verify::VerifyError>
44 for VerifyFluentBuilder
45{
46 fn send(
47 self,
48 config_override: crate::config::Builder,
49 ) -> crate::client::customize::internal::BoxFuture<
50 crate::client::customize::internal::SendResult<crate::operation::verify::VerifyOutput, crate::operation::verify::VerifyError>,
51 > {
52 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
53 }
54}
55impl VerifyFluentBuilder {
56 /// Creates a new `VerifyFluentBuilder`.
57 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
58 Self {
59 handle,
60 inner: ::std::default::Default::default(),
61 config_override: ::std::option::Option::None,
62 }
63 }
64 /// Access the Verify as a reference.
65 pub fn as_input(&self) -> &crate::operation::verify::builders::VerifyInputBuilder {
66 &self.inner
67 }
68 /// Sends the request and returns the response.
69 ///
70 /// If an error occurs, an `SdkError` will be returned with additional details that
71 /// can be matched against.
72 ///
73 /// By default, any retryable failures will be retried twice. Retry behavior
74 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
75 /// set when configuring the client.
76 pub async fn send(
77 self,
78 ) -> ::std::result::Result<
79 crate::operation::verify::VerifyOutput,
80 ::aws_smithy_runtime_api::client::result::SdkError<
81 crate::operation::verify::VerifyError,
82 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
83 >,
84 > {
85 let input = self
86 .inner
87 .build()
88 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
89 let runtime_plugins =
90 crate::operation::verify::Verify::operation_runtime_plugins(self.handle.runtime_plugins.clone(), &self.handle.conf, self.config_override);
91 crate::operation::verify::Verify::orchestrate(&runtime_plugins, input).await
92 }
93
94 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
95 pub fn customize(
96 self,
97 ) -> crate::client::customize::CustomizableOperation<crate::operation::verify::VerifyOutput, crate::operation::verify::VerifyError, Self> {
98 crate::client::customize::CustomizableOperation::new(self)
99 }
100 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
101 self.set_config_override(::std::option::Option::Some(config_override.into()));
102 self
103 }
104
105 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
106 self.config_override = config_override;
107 self
108 }
109 /// <p>Identifies the asymmetric KMS key that will be used to verify the signature. This must be the same KMS key that was used to generate the signature. If you specify a different KMS key, the signature verification fails.</p>
110 /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
111 /// <p>For example:</p>
112 /// <ul>
113 /// <li>
114 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
115 /// <li>
116 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
117 /// <li>
118 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
119 /// <li>
120 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
121 /// </ul>
122 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
123 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
124 self.inner = self.inner.key_id(input.into());
125 self
126 }
127 /// <p>Identifies the asymmetric KMS key that will be used to verify the signature. This must be the same KMS key that was used to generate the signature. If you specify a different KMS key, the signature verification fails.</p>
128 /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
129 /// <p>For example:</p>
130 /// <ul>
131 /// <li>
132 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
133 /// <li>
134 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
135 /// <li>
136 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
137 /// <li>
138 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
139 /// </ul>
140 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
141 pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
142 self.inner = self.inner.set_key_id(input);
143 self
144 }
145 /// <p>Identifies the asymmetric KMS key that will be used to verify the signature. This must be the same KMS key that was used to generate the signature. If you specify a different KMS key, the signature verification fails.</p>
146 /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
147 /// <p>For example:</p>
148 /// <ul>
149 /// <li>
150 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
151 /// <li>
152 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
153 /// <li>
154 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
155 /// <li>
156 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
157 /// </ul>
158 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
159 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
160 self.inner.get_key_id()
161 }
162 /// <p>Specifies the message that was signed. You can submit a raw message of up to 4096 bytes, or a hash digest of the message. If you submit a digest, use the <code>MessageType</code> parameter with a value of <code>DIGEST</code>.</p>
163 /// <p>If the message specified here is different from the message that was signed, the signature verification fails. A message and its hash digest are considered to be the same message.</p>
164 pub fn message(mut self, input: ::aws_smithy_types::Blob) -> Self {
165 self.inner = self.inner.message(input);
166 self
167 }
168 /// <p>Specifies the message that was signed. You can submit a raw message of up to 4096 bytes, or a hash digest of the message. If you submit a digest, use the <code>MessageType</code> parameter with a value of <code>DIGEST</code>.</p>
169 /// <p>If the message specified here is different from the message that was signed, the signature verification fails. A message and its hash digest are considered to be the same message.</p>
170 pub fn set_message(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
171 self.inner = self.inner.set_message(input);
172 self
173 }
174 /// <p>Specifies the message that was signed. You can submit a raw message of up to 4096 bytes, or a hash digest of the message. If you submit a digest, use the <code>MessageType</code> parameter with a value of <code>DIGEST</code>.</p>
175 /// <p>If the message specified here is different from the message that was signed, the signature verification fails. A message and its hash digest are considered to be the same message.</p>
176 pub fn get_message(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
177 self.inner.get_message()
178 }
179 /// <p>Tells KMS whether the value of the <code>Message</code> parameter should be hashed as part of the signing algorithm. Use <code>RAW</code> for unhashed messages; use <code>DIGEST</code> for message digests, which are already hashed.</p>
180 /// <p>When the value of <code>MessageType</code> is <code>RAW</code>, KMS uses the standard signing algorithm, which begins with a hash function. When the value is <code>DIGEST</code>, KMS skips the hashing step in the signing algorithm.</p><important>
181 /// <p>Use the <code>DIGEST</code> value only when the value of the <code>Message</code> parameter is a message digest. If you use the <code>DIGEST</code> value with an unhashed message, the security of the verification operation can be compromised.</p>
182 /// </important>
183 /// <p>When the value of <code>MessageType</code>is <code>DIGEST</code>, the length of the <code>Message</code> value must match the length of hashed messages for the specified signing algorithm.</p>
184 /// <p>You can submit a message digest and omit the <code>MessageType</code> or specify <code>RAW</code> so the digest is hashed again while signing. However, if the signed message is hashed once while signing, but twice while verifying, verification fails, even when the message hasn't changed.</p>
185 /// <p>The hashing algorithm in that <code>Verify</code> uses is based on the <code>SigningAlgorithm</code> value.</p>
186 /// <ul>
187 /// <li>
188 /// <p>Signing algorithms that end in SHA_256 use the SHA_256 hashing algorithm.</p></li>
189 /// <li>
190 /// <p>Signing algorithms that end in SHA_384 use the SHA_384 hashing algorithm.</p></li>
191 /// <li>
192 /// <p>Signing algorithms that end in SHA_512 use the SHA_512 hashing algorithm.</p></li>
193 /// <li>
194 /// <p>SM2DSA uses the SM3 hashing algorithm. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-sm-offline-verification">Offline verification with SM2 key pairs</a>.</p></li>
195 /// </ul>
196 pub fn message_type(mut self, input: crate::types::MessageType) -> Self {
197 self.inner = self.inner.message_type(input);
198 self
199 }
200 /// <p>Tells KMS whether the value of the <code>Message</code> parameter should be hashed as part of the signing algorithm. Use <code>RAW</code> for unhashed messages; use <code>DIGEST</code> for message digests, which are already hashed.</p>
201 /// <p>When the value of <code>MessageType</code> is <code>RAW</code>, KMS uses the standard signing algorithm, which begins with a hash function. When the value is <code>DIGEST</code>, KMS skips the hashing step in the signing algorithm.</p><important>
202 /// <p>Use the <code>DIGEST</code> value only when the value of the <code>Message</code> parameter is a message digest. If you use the <code>DIGEST</code> value with an unhashed message, the security of the verification operation can be compromised.</p>
203 /// </important>
204 /// <p>When the value of <code>MessageType</code>is <code>DIGEST</code>, the length of the <code>Message</code> value must match the length of hashed messages for the specified signing algorithm.</p>
205 /// <p>You can submit a message digest and omit the <code>MessageType</code> or specify <code>RAW</code> so the digest is hashed again while signing. However, if the signed message is hashed once while signing, but twice while verifying, verification fails, even when the message hasn't changed.</p>
206 /// <p>The hashing algorithm in that <code>Verify</code> uses is based on the <code>SigningAlgorithm</code> value.</p>
207 /// <ul>
208 /// <li>
209 /// <p>Signing algorithms that end in SHA_256 use the SHA_256 hashing algorithm.</p></li>
210 /// <li>
211 /// <p>Signing algorithms that end in SHA_384 use the SHA_384 hashing algorithm.</p></li>
212 /// <li>
213 /// <p>Signing algorithms that end in SHA_512 use the SHA_512 hashing algorithm.</p></li>
214 /// <li>
215 /// <p>SM2DSA uses the SM3 hashing algorithm. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-sm-offline-verification">Offline verification with SM2 key pairs</a>.</p></li>
216 /// </ul>
217 pub fn set_message_type(mut self, input: ::std::option::Option<crate::types::MessageType>) -> Self {
218 self.inner = self.inner.set_message_type(input);
219 self
220 }
221 /// <p>Tells KMS whether the value of the <code>Message</code> parameter should be hashed as part of the signing algorithm. Use <code>RAW</code> for unhashed messages; use <code>DIGEST</code> for message digests, which are already hashed.</p>
222 /// <p>When the value of <code>MessageType</code> is <code>RAW</code>, KMS uses the standard signing algorithm, which begins with a hash function. When the value is <code>DIGEST</code>, KMS skips the hashing step in the signing algorithm.</p><important>
223 /// <p>Use the <code>DIGEST</code> value only when the value of the <code>Message</code> parameter is a message digest. If you use the <code>DIGEST</code> value with an unhashed message, the security of the verification operation can be compromised.</p>
224 /// </important>
225 /// <p>When the value of <code>MessageType</code>is <code>DIGEST</code>, the length of the <code>Message</code> value must match the length of hashed messages for the specified signing algorithm.</p>
226 /// <p>You can submit a message digest and omit the <code>MessageType</code> or specify <code>RAW</code> so the digest is hashed again while signing. However, if the signed message is hashed once while signing, but twice while verifying, verification fails, even when the message hasn't changed.</p>
227 /// <p>The hashing algorithm in that <code>Verify</code> uses is based on the <code>SigningAlgorithm</code> value.</p>
228 /// <ul>
229 /// <li>
230 /// <p>Signing algorithms that end in SHA_256 use the SHA_256 hashing algorithm.</p></li>
231 /// <li>
232 /// <p>Signing algorithms that end in SHA_384 use the SHA_384 hashing algorithm.</p></li>
233 /// <li>
234 /// <p>Signing algorithms that end in SHA_512 use the SHA_512 hashing algorithm.</p></li>
235 /// <li>
236 /// <p>SM2DSA uses the SM3 hashing algorithm. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-sm-offline-verification">Offline verification with SM2 key pairs</a>.</p></li>
237 /// </ul>
238 pub fn get_message_type(&self) -> &::std::option::Option<crate::types::MessageType> {
239 self.inner.get_message_type()
240 }
241 /// <p>The signature that the <code>Sign</code> operation generated.</p>
242 pub fn signature(mut self, input: ::aws_smithy_types::Blob) -> Self {
243 self.inner = self.inner.signature(input);
244 self
245 }
246 /// <p>The signature that the <code>Sign</code> operation generated.</p>
247 pub fn set_signature(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
248 self.inner = self.inner.set_signature(input);
249 self
250 }
251 /// <p>The signature that the <code>Sign</code> operation generated.</p>
252 pub fn get_signature(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
253 self.inner.get_signature()
254 }
255 /// <p>The signing algorithm that was used to sign the message. If you submit a different algorithm, the signature verification fails.</p>
256 pub fn signing_algorithm(mut self, input: crate::types::SigningAlgorithmSpec) -> Self {
257 self.inner = self.inner.signing_algorithm(input);
258 self
259 }
260 /// <p>The signing algorithm that was used to sign the message. If you submit a different algorithm, the signature verification fails.</p>
261 pub fn set_signing_algorithm(mut self, input: ::std::option::Option<crate::types::SigningAlgorithmSpec>) -> Self {
262 self.inner = self.inner.set_signing_algorithm(input);
263 self
264 }
265 /// <p>The signing algorithm that was used to sign the message. If you submit a different algorithm, the signature verification fails.</p>
266 pub fn get_signing_algorithm(&self) -> &::std::option::Option<crate::types::SigningAlgorithmSpec> {
267 self.inner.get_signing_algorithm()
268 }
269 ///
270 /// Appends an item to `GrantTokens`.
271 ///
272 /// To override the contents of this collection use [`set_grant_tokens`](Self::set_grant_tokens).
273 ///
274 /// <p>A list of grant tokens.</p>
275 /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
276 pub fn grant_tokens(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
277 self.inner = self.inner.grant_tokens(input.into());
278 self
279 }
280 /// <p>A list of grant tokens.</p>
281 /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
282 pub fn set_grant_tokens(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
283 self.inner = self.inner.set_grant_tokens(input);
284 self
285 }
286 /// <p>A list of grant tokens.</p>
287 /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
288 pub fn get_grant_tokens(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
289 self.inner.get_grant_tokens()
290 }
291 /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
292 /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-dryrun.html">Testing your KMS API calls</a> in the <i>Key Management Service Developer Guide</i>.</p>
293 pub fn dry_run(mut self, input: bool) -> Self {
294 self.inner = self.inner.dry_run(input);
295 self
296 }
297 /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
298 /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-dryrun.html">Testing your KMS API calls</a> in the <i>Key Management Service Developer Guide</i>.</p>
299 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
300 self.inner = self.inner.set_dry_run(input);
301 self
302 }
303 /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
304 /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-dryrun.html">Testing your KMS API calls</a> in the <i>Key Management Service Developer Guide</i>.</p>
305 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
306 self.inner.get_dry_run()
307 }
308}