aws_sdk_paymentcryptography/operation/export_key/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::export_key::_export_key_output::ExportKeyOutputBuilder;
3
4pub use crate::operation::export_key::_export_key_input::ExportKeyInputBuilder;
5
6impl crate::operation::export_key::builders::ExportKeyInputBuilder {
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::export_key::ExportKeyOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::export_key::ExportKeyError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.export_key();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `ExportKey`.
24///
25/// <p>Exports a key from Amazon Web Services Payment Cryptography.</p>
26/// <p>Amazon Web Services Payment Cryptography simplifies key exchange by replacing the existing paper-based approach with a modern electronic approach. With <code>ExportKey</code> you can export symmetric keys using either symmetric and asymmetric key exchange mechanisms. Using this operation, you can share your Amazon Web Services Payment Cryptography generated keys with other service partners to perform cryptographic operations outside of Amazon Web Services Payment Cryptography</p>
27/// <p>For symmetric key exchange, Amazon Web Services Payment Cryptography uses the ANSI X9 TR-31 norm in accordance with PCI PIN guidelines. And for asymmetric key exchange, Amazon Web Services Payment Cryptography supports ANSI X9 TR-34 norm, RSA unwrap, and ECDH (Elliptic Curve Diffie-Hellman) key exchange mechanisms. Asymmetric key exchange methods are typically used to establish bi-directional trust between the two parties exhanging keys and are used for initial key exchange such as Key Encryption Key (KEK). After which you can export working keys using symmetric method to perform various cryptographic operations within Amazon Web Services Payment Cryptography.</p>
28/// <p>PCI requires specific minimum key strength of wrapping keys used to protect the keys being exchanged electronically. These requirements can change when PCI standards are revised. The rules specify that wrapping keys used for transport must be at least as strong as the key being protected. For more information on recommended key strength of wrapping keys and key exchange mechanism, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-importexport.html">Importing and exporting keys</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>.</p>
29/// <p>You can also use <code>ExportKey</code> functionality to generate and export an IPEK (Initial Pin Encryption Key) from Amazon Web Services Payment Cryptography using either TR-31 or TR-34 export key exchange. IPEK is generated from BDK (Base Derivation Key) and <code>ExportDukptInitialKey</code> attribute KSN (<code>KeySerialNumber</code>). The generated IPEK does not persist within Amazon Web Services Payment Cryptography and has to be re-generated each time during export.</p>
30/// <p>For key exchange using TR-31 or TR-34 key blocks, you can also export optional blocks within the key block header which contain additional attribute information about the key. The <code>KeyVersion</code> within <code>KeyBlockHeaders</code> indicates the version of the key within the key block. Furthermore, <code>KeyExportability</code> within <code>KeyBlockHeaders</code> can be used to further restrict exportability of the key after export from Amazon Web Services Payment Cryptography.</p>
31/// <p>The <code>OptionalBlocks</code> contain the additional data related to the key. For information on data type that can be included within optional blocks, refer to <a href="https://webstore.ansi.org/standards/ascx9/ansix91432022">ASC X9.143-2022</a>.</p><note>
32/// <p>Data included in key block headers is signed but transmitted in clear text. Sensitive or confidential information should not be included in optional blocks. Refer to ASC X9.143-2022 standard for information on allowed data type.</p>
33/// </note>
34/// <p><b>To export initial keys (KEK) or IPEK using TR-34</b></p>
35/// <p>Using this operation, you can export initial key using TR-34 asymmetric key exchange. You can only export KEK generated within Amazon Web Services Payment Cryptography. In TR-34 terminology, the sending party of the key is called Key Distribution Host (KDH) and the receiving party of the key is called Key Receiving Device (KRD). During key export process, KDH is Amazon Web Services Payment Cryptography which initiates key export and KRD is the user receiving the key.</p>
36/// <p>To initiate TR-34 key export, the KRD must obtain an export token by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_GetParametersForExport.html">GetParametersForExport</a>. This operation also generates a key pair for the purpose of key export, signs the key and returns back the signing public key certificate (also known as KDH signing certificate) and root certificate chain. The KDH uses the private key to sign the the export payload and the signing public key certificate is provided to KRD to verify the signature. The KRD can import the root certificate into its Hardware Security Module (HSM), as required. The export token and the associated KDH signing certificate expires after 30 days.</p>
37/// <p>Next the KRD generates a key pair for the the purpose of encrypting the KDH key and provides the public key cerificate (also known as KRD wrapping certificate) back to KDH. The KRD will also import the root cerificate chain into Amazon Web Services Payment Cryptography by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a> for <code>RootCertificatePublicKey</code>. The KDH, Amazon Web Services Payment Cryptography, will use the KRD wrapping cerificate to encrypt (wrap) the key under export and signs it with signing private key to generate a TR-34 WrappedKeyBlock. For more information on TR-34 key export, see section <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-export.html">Exporting symmetric keys</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>.</p>
38/// <p>Set the following parameters:</p>
39/// <ul>
40/// <li>
41/// <p><code>ExportAttributes</code>: Specify export attributes in case of IPEK export. This parameter is optional for KEK export.</p></li>
42/// <li>
43/// <p><code>ExportKeyIdentifier</code>: The <code>KeyARN</code> of the KEK or BDK (in case of IPEK) under export.</p></li>
44/// <li>
45/// <p><code>KeyMaterial</code>: Use <code>Tr34KeyBlock</code> parameters.</p></li>
46/// <li>
47/// <p><code>CertificateAuthorityPublicKeyIdentifier</code>: The <code>KeyARN</code> of the certificate chain that signed the KRD wrapping key certificate.</p></li>
48/// <li>
49/// <p><code>ExportToken</code>: Obtained from KDH by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_GetParametersForImport.html">GetParametersForImport</a>.</p></li>
50/// <li>
51/// <p><code>WrappingKeyCertificate</code>: The public key certificate in PEM format (base64 encoded) of the KRD wrapping key Amazon Web Services Payment Cryptography uses for encryption of the TR-34 export payload. This certificate must be signed by the root certificate (CertificateAuthorityPublicKeyIdentifier) imported into Amazon Web Services Payment Cryptography.</p></li>
52/// </ul>
53/// <p>When this operation is successful, Amazon Web Services Payment Cryptography returns the KEK or IPEK as a TR-34 WrappedKeyBlock.</p>
54/// <p><b>To export initial keys (KEK) or IPEK using RSA Wrap and Unwrap</b></p>
55/// <p>Using this operation, you can export initial key using asymmetric RSA wrap and unwrap key exchange method. To initiate export, generate an asymmetric key pair on the receiving HSM and obtain the public key certificate in PEM format (base64 encoded) for the purpose of wrapping and the root certifiate chain. Import the root certificate into Amazon Web Services Payment Cryptography by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a> for <code>RootCertificatePublicKey</code>.</p>
56/// <p>Next call <code>ExportKey</code> and set the following parameters:</p>
57/// <ul>
58/// <li>
59/// <p><code>CertificateAuthorityPublicKeyIdentifier</code>: The <code>KeyARN</code> of the certificate chain that signed wrapping key certificate.</p></li>
60/// <li>
61/// <p><code>KeyMaterial</code>: Set to <code>KeyCryptogram</code>.</p></li>
62/// <li>
63/// <p><code>WrappingKeyCertificate</code>: The public key certificate in PEM format (base64 encoded) obtained by the receiving HSM and signed by the root certificate (CertificateAuthorityPublicKeyIdentifier) imported into Amazon Web Services Payment Cryptography. The receiving HSM uses its private key component to unwrap the WrappedKeyCryptogram.</p></li>
64/// </ul>
65/// <p>When this operation is successful, Amazon Web Services Payment Cryptography returns the WrappedKeyCryptogram.</p>
66/// <p><b>To export working keys or IPEK using TR-31</b></p>
67/// <p>Using this operation, you can export working keys or IPEK using TR-31 symmetric key exchange. In TR-31, you must use an initial key such as KEK to encrypt or wrap the key under export. To establish a KEK, you can use <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a> or <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a>.</p>
68/// <p>Set the following parameters:</p>
69/// <ul>
70/// <li>
71/// <p><code>ExportAttributes</code>: Specify export attributes in case of IPEK export. This parameter is optional for KEK export.</p></li>
72/// <li>
73/// <p><code>ExportKeyIdentifier</code>: The <code>KeyARN</code> of the KEK or BDK (in case of IPEK) under export.</p></li>
74/// <li>
75/// <p><code>KeyMaterial</code>: Use <code>Tr31KeyBlock</code> parameters.</p></li>
76/// </ul>
77/// <p><b>To export working keys using ECDH</b></p>
78/// <p>You can also use ECDH key agreement to export working keys in a TR-31 keyblock, where the wrapping key is an ECDH derived key.</p>
79/// <p>To initiate a TR-31 key export using ECDH, both sides must create an ECC key pair with key usage K3 and exchange public key certificates. In Amazon Web Services Payment Cryptography, you can do this by calling <code>CreateKey</code>. If you have not already done so, you must import the CA chain that issued the receiving public key certificate by calling <code>ImportKey</code> with input <code>RootCertificatePublicKey</code> for root CA or <code>TrustedPublicKey</code> for intermediate CA. You can then complete a TR-31 key export by deriving a shared wrapping key using the service ECC key pair, public certificate of your ECC key pair outside of Amazon Web Services Payment Cryptography, and the key derivation parameters including key derivation function, hash algorithm, derivation data, key algorithm.</p>
80/// <ul>
81/// <li>
82/// <p><code>KeyMaterial</code>: Use <code>DiffieHellmanTr31KeyBlock</code> parameters.</p></li>
83/// <li>
84/// <p><code>PrivateKeyIdentifier</code>: The <code>KeyArn</code> of the ECC key pair created within Amazon Web Services Payment Cryptography to derive a shared KEK.</p></li>
85/// <li>
86/// <p><code>PublicKeyCertificate</code>: The public key certificate of the receiving ECC key pair in PEM format (base64 encoded) to derive a shared KEK.</p></li>
87/// <li>
88/// <p><code>CertificateAuthorityPublicKeyIdentifier</code>: The <code>keyARN</code> of the CA that signed the public key certificate of the receiving ECC key pair.</p></li>
89/// </ul>
90/// <p>When this operation is successful, Amazon Web Services Payment Cryptography returns the working key as a TR-31 WrappedKeyBlock, where the wrapping key is the ECDH derived key.</p>
91/// <p><b>Cross-account use:</b> This operation can't be used across different Amazon Web Services accounts.</p>
92/// <p><b>Related operations:</b></p>
93/// <ul>
94/// <li>
95/// <p><a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_GetParametersForExport.html">GetParametersForExport</a></p></li>
96/// <li>
97/// <p><a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a></p></li>
98/// </ul>
99#[derive(::std::clone::Clone, ::std::fmt::Debug)]
100pub struct ExportKeyFluentBuilder {
101    handle: ::std::sync::Arc<crate::client::Handle>,
102    inner: crate::operation::export_key::builders::ExportKeyInputBuilder,
103    config_override: ::std::option::Option<crate::config::Builder>,
104}
105impl crate::client::customize::internal::CustomizableSend<crate::operation::export_key::ExportKeyOutput, crate::operation::export_key::ExportKeyError>
106    for ExportKeyFluentBuilder
107{
108    fn send(
109        self,
110        config_override: crate::config::Builder,
111    ) -> crate::client::customize::internal::BoxFuture<
112        crate::client::customize::internal::SendResult<crate::operation::export_key::ExportKeyOutput, crate::operation::export_key::ExportKeyError>,
113    > {
114        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
115    }
116}
117impl ExportKeyFluentBuilder {
118    /// Creates a new `ExportKeyFluentBuilder`.
119    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
120        Self {
121            handle,
122            inner: ::std::default::Default::default(),
123            config_override: ::std::option::Option::None,
124        }
125    }
126    /// Access the ExportKey as a reference.
127    pub fn as_input(&self) -> &crate::operation::export_key::builders::ExportKeyInputBuilder {
128        &self.inner
129    }
130    /// Sends the request and returns the response.
131    ///
132    /// If an error occurs, an `SdkError` will be returned with additional details that
133    /// can be matched against.
134    ///
135    /// By default, any retryable failures will be retried twice. Retry behavior
136    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
137    /// set when configuring the client.
138    pub async fn send(
139        self,
140    ) -> ::std::result::Result<
141        crate::operation::export_key::ExportKeyOutput,
142        ::aws_smithy_runtime_api::client::result::SdkError<
143            crate::operation::export_key::ExportKeyError,
144            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
145        >,
146    > {
147        let input = self
148            .inner
149            .build()
150            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
151        let runtime_plugins = crate::operation::export_key::ExportKey::operation_runtime_plugins(
152            self.handle.runtime_plugins.clone(),
153            &self.handle.conf,
154            self.config_override,
155        );
156        crate::operation::export_key::ExportKey::orchestrate(&runtime_plugins, input).await
157    }
158
159    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
160    pub fn customize(
161        self,
162    ) -> crate::client::customize::CustomizableOperation<
163        crate::operation::export_key::ExportKeyOutput,
164        crate::operation::export_key::ExportKeyError,
165        Self,
166    > {
167        crate::client::customize::CustomizableOperation::new(self)
168    }
169    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
170        self.set_config_override(::std::option::Option::Some(config_override.into()));
171        self
172    }
173
174    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
175        self.config_override = config_override;
176        self
177    }
178    /// <p>The key block format type, for example, TR-34 or TR-31, to use during key material export.</p>
179    pub fn key_material(mut self, input: crate::types::ExportKeyMaterial) -> Self {
180        self.inner = self.inner.key_material(input);
181        self
182    }
183    /// <p>The key block format type, for example, TR-34 or TR-31, to use during key material export.</p>
184    pub fn set_key_material(mut self, input: ::std::option::Option<crate::types::ExportKeyMaterial>) -> Self {
185        self.inner = self.inner.set_key_material(input);
186        self
187    }
188    /// <p>The key block format type, for example, TR-34 or TR-31, to use during key material export.</p>
189    pub fn get_key_material(&self) -> &::std::option::Option<crate::types::ExportKeyMaterial> {
190        self.inner.get_key_material()
191    }
192    /// <p>The <code>KeyARN</code> of the key under export from Amazon Web Services Payment Cryptography.</p>
193    pub fn export_key_identifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
194        self.inner = self.inner.export_key_identifier(input.into());
195        self
196    }
197    /// <p>The <code>KeyARN</code> of the key under export from Amazon Web Services Payment Cryptography.</p>
198    pub fn set_export_key_identifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
199        self.inner = self.inner.set_export_key_identifier(input);
200        self
201    }
202    /// <p>The <code>KeyARN</code> of the key under export from Amazon Web Services Payment Cryptography.</p>
203    pub fn get_export_key_identifier(&self) -> &::std::option::Option<::std::string::String> {
204        self.inner.get_export_key_identifier()
205    }
206    /// <p>The attributes for IPEK generation during export.</p>
207    pub fn export_attributes(mut self, input: crate::types::ExportAttributes) -> Self {
208        self.inner = self.inner.export_attributes(input);
209        self
210    }
211    /// <p>The attributes for IPEK generation during export.</p>
212    pub fn set_export_attributes(mut self, input: ::std::option::Option<crate::types::ExportAttributes>) -> Self {
213        self.inner = self.inner.set_export_attributes(input);
214        self
215    }
216    /// <p>The attributes for IPEK generation during export.</p>
217    pub fn get_export_attributes(&self) -> &::std::option::Option<crate::types::ExportAttributes> {
218        self.inner.get_export_attributes()
219    }
220}