Skip to content

Commit efdc709

Browse files
author
awstools
committed
feat(client-payment-cryptography-data): Added a new API - translateKeyMaterial; allows keys wrapped by ECDH derived keys to be rewrapped under a static AES keyblock without first importing the key into the service.
1 parent 736bf07 commit efdc709

File tree

12 files changed

+833
-29
lines changed

12 files changed

+833
-29
lines changed

clients/client-payment-cryptography-data/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ ReEncryptData
258258

259259
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/payment-cryptography-data/command/ReEncryptDataCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-payment-cryptography-data/Interface/ReEncryptDataCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-payment-cryptography-data/Interface/ReEncryptDataCommandOutput/)
260260

261+
</details>
262+
<details>
263+
<summary>
264+
TranslateKeyMaterial
265+
</summary>
266+
267+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/payment-cryptography-data/command/TranslateKeyMaterialCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-payment-cryptography-data/Interface/TranslateKeyMaterialCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-payment-cryptography-data/Interface/TranslateKeyMaterialCommandOutput/)
268+
261269
</details>
262270
<details>
263271
<summary>

clients/client-payment-cryptography-data/src/PaymentCryptographyData.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import {
2525
ReEncryptDataCommandInput,
2626
ReEncryptDataCommandOutput,
2727
} from "./commands/ReEncryptDataCommand";
28+
import {
29+
TranslateKeyMaterialCommand,
30+
TranslateKeyMaterialCommandInput,
31+
TranslateKeyMaterialCommandOutput,
32+
} from "./commands/TranslateKeyMaterialCommand";
2833
import {
2934
TranslatePinDataCommand,
3035
TranslatePinDataCommandInput,
@@ -56,6 +61,7 @@ const commands = {
5661
GenerateMacEmvPinChangeCommand,
5762
GeneratePinDataCommand,
5863
ReEncryptDataCommand,
64+
TranslateKeyMaterialCommand,
5965
TranslatePinDataCommand,
6066
VerifyAuthRequestCryptogramCommand,
6167
VerifyCardValidationDataCommand,
@@ -156,6 +162,23 @@ export interface PaymentCryptographyData {
156162
cb: (err: any, data?: ReEncryptDataCommandOutput) => void
157163
): void;
158164

165+
/**
166+
* @see {@link TranslateKeyMaterialCommand}
167+
*/
168+
translateKeyMaterial(
169+
args: TranslateKeyMaterialCommandInput,
170+
options?: __HttpHandlerOptions
171+
): Promise<TranslateKeyMaterialCommandOutput>;
172+
translateKeyMaterial(
173+
args: TranslateKeyMaterialCommandInput,
174+
cb: (err: any, data?: TranslateKeyMaterialCommandOutput) => void
175+
): void;
176+
translateKeyMaterial(
177+
args: TranslateKeyMaterialCommandInput,
178+
options: __HttpHandlerOptions,
179+
cb: (err: any, data?: TranslateKeyMaterialCommandOutput) => void
180+
): void;
181+
159182
/**
160183
* @see {@link TranslatePinDataCommand}
161184
*/

clients/client-payment-cryptography-data/src/PaymentCryptographyDataClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ import {
6666
} from "./commands/GenerateMacEmvPinChangeCommand";
6767
import { GeneratePinDataCommandInput, GeneratePinDataCommandOutput } from "./commands/GeneratePinDataCommand";
6868
import { ReEncryptDataCommandInput, ReEncryptDataCommandOutput } from "./commands/ReEncryptDataCommand";
69+
import {
70+
TranslateKeyMaterialCommandInput,
71+
TranslateKeyMaterialCommandOutput,
72+
} from "./commands/TranslateKeyMaterialCommand";
6973
import { TranslatePinDataCommandInput, TranslatePinDataCommandOutput } from "./commands/TranslatePinDataCommand";
7074
import {
7175
VerifyAuthRequestCryptogramCommandInput,
@@ -99,6 +103,7 @@ export type ServiceInputTypes =
99103
| GenerateMacEmvPinChangeCommandInput
100104
| GeneratePinDataCommandInput
101105
| ReEncryptDataCommandInput
106+
| TranslateKeyMaterialCommandInput
102107
| TranslatePinDataCommandInput
103108
| VerifyAuthRequestCryptogramCommandInput
104109
| VerifyCardValidationDataCommandInput
@@ -116,6 +121,7 @@ export type ServiceOutputTypes =
116121
| GenerateMacEmvPinChangeCommandOutput
117122
| GeneratePinDataCommandOutput
118123
| ReEncryptDataCommandOutput
124+
| TranslateKeyMaterialCommandOutput
119125
| TranslatePinDataCommandOutput
120126
| VerifyAuthRequestCryptogramCommandOutput
121127
| VerifyCardValidationDataCommandOutput

clients/client-payment-cryptography-data/src/commands/GenerateMacCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface GenerateMacCommandInput extends GenerateMacInput {}
3737
export interface GenerateMacCommandOutput extends GenerateMacOutput, __MetadataBearer {}
3838

3939
/**
40-
* <p>Generates a Message Authentication Code (MAC) cryptogram within Amazon Web Services Payment Cryptography. </p> <p>You can use this operation to authenticate card-related data by using known data values to generate MAC for data validation between the sending and receiving parties. This operation uses message data, a secret encryption key and MAC algorithm to generate a unique MAC value for transmission. The receiving party of the MAC must use the same message data, secret encryption key and MAC algorithm to reproduce another MAC value for comparision.</p> <p>You can use this operation to generate a DUPKT, CMAC, HMAC or EMV MAC by setting generation attributes and algorithm to the associated values. The MAC generation encryption key must have valid values for <code>KeyUsage</code> such as <code>TR31_M7_HMAC_KEY</code> for HMAC generation, and they key must have <code>KeyModesOfUse</code> set to <code>Generate</code> and <code>Verify</code>.</p> <p>For information about valid keys for this operation, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-validattributes.html">Understanding key attributes</a> and <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/crypto-ops-validkeys-ops.html">Key types for specific data operations</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>. </p> <p> <b>Cross-account use</b>: This operation can't be used across different Amazon Web Services accounts.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>VerifyMac</a> </p> </li> </ul>
40+
* <p>Generates a Message Authentication Code (MAC) cryptogram within Amazon Web Services Payment Cryptography. </p> <p>You can use this operation to authenticate card-related data by using known data values to generate MAC for data validation between the sending and receiving parties. This operation uses message data, a secret encryption key and MAC algorithm to generate a unique MAC value for transmission. The receiving party of the MAC must use the same message data, secret encryption key and MAC algorithm to reproduce another MAC value for comparision.</p> <p>You can use this operation to generate a DUPKT, CMAC, HMAC or EMV MAC by setting generation attributes and algorithm to the associated values. The MAC generation encryption key must have valid values for <code>KeyUsage</code> such as <code>TR31_M7_HMAC_KEY</code> for HMAC generation, and the key must have <code>KeyModesOfUse</code> set to <code>Generate</code> and <code>Verify</code>.</p> <p>For information about valid keys for this operation, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-validattributes.html">Understanding key attributes</a> and <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/crypto-ops-validkeys-ops.html">Key types for specific data operations</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>. </p> <p> <b>Cross-account use</b>: This operation can't be used across different Amazon Web Services accounts.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>VerifyMac</a> </p> </li> </ul>
4141
* @example
4242
* Use a bare-bones client and the command you need to make an API call.
4343
* ```javascript

clients/client-payment-cryptography-data/src/commands/GeneratePinDataCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export interface GeneratePinDataCommandOutput extends GeneratePinDataOutput, __M
8181
* },
8282
* },
8383
* PinDataLength: Number("int"),
84-
* PrimaryAccountNumber: "STRING_VALUE", // required
85-
* PinBlockFormat: "ISO_FORMAT_0" || "ISO_FORMAT_3" || "ISO_FORMAT_4", // required
84+
* PrimaryAccountNumber: "STRING_VALUE",
85+
* PinBlockFormat: "ISO_FORMAT_0" || "ISO_FORMAT_1" || "ISO_FORMAT_3" || "ISO_FORMAT_4", // required
8686
* EncryptionWrappedKey: { // WrappedKey
8787
* WrappedKeyMaterial: { // WrappedKeyMaterial Union: only one key present
8888
* Tr31KeyBlock: "STRING_VALUE",
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { commonParams } from "../endpoint/EndpointParameters";
8+
import {
9+
TranslateKeyMaterialInput,
10+
TranslateKeyMaterialInputFilterSensitiveLog,
11+
TranslateKeyMaterialOutput,
12+
TranslateKeyMaterialOutputFilterSensitiveLog,
13+
} from "../models/models_0";
14+
import {
15+
PaymentCryptographyDataClientResolvedConfig,
16+
ServiceInputTypes,
17+
ServiceOutputTypes,
18+
} from "../PaymentCryptographyDataClient";
19+
import { de_TranslateKeyMaterialCommand, se_TranslateKeyMaterialCommand } from "../protocols/Aws_restJson1";
20+
21+
/**
22+
* @public
23+
*/
24+
export type { __MetadataBearer };
25+
export { $Command };
26+
/**
27+
* @public
28+
*
29+
* The input for {@link TranslateKeyMaterialCommand}.
30+
*/
31+
export interface TranslateKeyMaterialCommandInput extends TranslateKeyMaterialInput {}
32+
/**
33+
* @public
34+
*
35+
* The output of {@link TranslateKeyMaterialCommand}.
36+
*/
37+
export interface TranslateKeyMaterialCommandOutput extends TranslateKeyMaterialOutput, __MetadataBearer {}
38+
39+
/**
40+
* <p>Translates an encryption key between different wrapping keys without importing the key into Amazon Web Services Payment Cryptography.</p> <p>This operation can be used when key material is frequently rotated, such as during every card transaction, and there is a need to avoid importing short-lived keys into Amazon Web Services Payment Cryptography. It translates short-lived transaction keys such as Pin Encryption Key (PEK) generated for each transaction and wrapped with an ECDH (Elliptic Curve Diffie-Hellman) derived wrapping key to another KEK (Key Encryption Key) wrapping key. </p> <p>Before using this operation, you must first request the public key certificate of the ECC key pair generated within Amazon Web Services Payment Cryptography to establish an ECDH key agreement. In <code>TranslateKeyData</code>, the service uses its own ECC key pair, public certificate of receiving ECC key pair, and the key derivation parameters to generate a derived key. The service uses this derived key to unwrap the incoming transaction key received as a TR31WrappedKeyBlock and re-wrap using a user provided KEK to generate an outgoing Tr31WrappedKeyBlock. For more information on establishing ECDH derived keys, see the <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/create-keys.html">Creating keys</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>.</p> <p>For information about valid keys for this operation, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-validattributes.html">Understanding key attributes</a> and <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/crypto-ops-validkeys-ops.html">Key types for specific data operations</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>. </p> <p> <b>Cross-account use</b>: This operation can't be used across different Amazon Web Services accounts.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_GetPublicKeyCertificate.html">GetPublicCertificate</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a> </p> </li> </ul>
41+
* @example
42+
* Use a bare-bones client and the command you need to make an API call.
43+
* ```javascript
44+
* import { PaymentCryptographyDataClient, TranslateKeyMaterialCommand } from "@aws-sdk/client-payment-cryptography-data"; // ES Modules import
45+
* // const { PaymentCryptographyDataClient, TranslateKeyMaterialCommand } = require("@aws-sdk/client-payment-cryptography-data"); // CommonJS import
46+
* // import type { PaymentCryptographyDataClientConfig } from "@aws-sdk/client-payment-cryptography-data";
47+
* const config = {}; // type is PaymentCryptographyDataClientConfig
48+
* const client = new PaymentCryptographyDataClient(config);
49+
* const input = { // TranslateKeyMaterialInput
50+
* IncomingKeyMaterial: { // IncomingKeyMaterial Union: only one key present
51+
* DiffieHellmanTr31KeyBlock: { // IncomingDiffieHellmanTr31KeyBlock
52+
* PrivateKeyIdentifier: "STRING_VALUE", // required
53+
* CertificateAuthorityPublicKeyIdentifier: "STRING_VALUE", // required
54+
* PublicKeyCertificate: "STRING_VALUE", // required
55+
* DeriveKeyAlgorithm: "TDES_2KEY" || "TDES_3KEY" || "AES_128" || "AES_192" || "AES_256" || "HMAC_SHA256" || "HMAC_SHA384" || "HMAC_SHA512" || "HMAC_SHA224", // required
56+
* KeyDerivationFunction: "NIST_SP800" || "ANSI_X963", // required
57+
* KeyDerivationHashAlgorithm: "SHA_256" || "SHA_384" || "SHA_512", // required
58+
* DerivationData: { // DiffieHellmanDerivationData Union: only one key present
59+
* SharedInformation: "STRING_VALUE",
60+
* },
61+
* WrappedKeyBlock: "STRING_VALUE", // required
62+
* },
63+
* },
64+
* OutgoingKeyMaterial: { // OutgoingKeyMaterial Union: only one key present
65+
* Tr31KeyBlock: { // OutgoingTr31KeyBlock
66+
* WrappingKeyIdentifier: "STRING_VALUE", // required
67+
* },
68+
* },
69+
* KeyCheckValueAlgorithm: "STRING_VALUE",
70+
* };
71+
* const command = new TranslateKeyMaterialCommand(input);
72+
* const response = await client.send(command);
73+
* // { // TranslateKeyMaterialOutput
74+
* // WrappedKey: { // WrappedWorkingKey
75+
* // WrappedKeyMaterial: "STRING_VALUE", // required
76+
* // KeyCheckValue: "STRING_VALUE", // required
77+
* // WrappedKeyMaterialFormat: "STRING_VALUE", // required
78+
* // },
79+
* // };
80+
*
81+
* ```
82+
*
83+
* @param TranslateKeyMaterialCommandInput - {@link TranslateKeyMaterialCommandInput}
84+
* @returns {@link TranslateKeyMaterialCommandOutput}
85+
* @see {@link TranslateKeyMaterialCommandInput} for command's `input` shape.
86+
* @see {@link TranslateKeyMaterialCommandOutput} for command's `response` shape.
87+
* @see {@link PaymentCryptographyDataClientResolvedConfig | config} for PaymentCryptographyDataClient's `config` shape.
88+
*
89+
* @throws {@link AccessDeniedException} (client fault)
90+
* <p>You do not have sufficient access to perform this action.</p>
91+
*
92+
* @throws {@link InternalServerException} (server fault)
93+
* <p>The request processing has failed because of an unknown error, exception, or failure.</p>
94+
*
95+
* @throws {@link ResourceNotFoundException} (client fault)
96+
* <p>The request was denied due to an invalid resource error.</p>
97+
*
98+
* @throws {@link ThrottlingException} (client fault)
99+
* <p>The request was denied due to request throttling.</p>
100+
*
101+
* @throws {@link ValidationException} (client fault)
102+
* <p>The request was denied due to an invalid request error.</p>
103+
*
104+
* @throws {@link PaymentCryptographyDataServiceException}
105+
* <p>Base exception class for all service exceptions from PaymentCryptographyData service.</p>
106+
*
107+
*
108+
* @public
109+
*/
110+
export class TranslateKeyMaterialCommand extends $Command
111+
.classBuilder<
112+
TranslateKeyMaterialCommandInput,
113+
TranslateKeyMaterialCommandOutput,
114+
PaymentCryptographyDataClientResolvedConfig,
115+
ServiceInputTypes,
116+
ServiceOutputTypes
117+
>()
118+
.ep(commonParams)
119+
.m(function (this: any, Command: any, cs: any, config: PaymentCryptographyDataClientResolvedConfig, o: any) {
120+
return [
121+
getSerdePlugin(config, this.serialize, this.deserialize),
122+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
123+
];
124+
})
125+
.s("PaymentCryptographyDataPlane", "TranslateKeyMaterial", {})
126+
.n("PaymentCryptographyDataClient", "TranslateKeyMaterialCommand")
127+
.f(TranslateKeyMaterialInputFilterSensitiveLog, TranslateKeyMaterialOutputFilterSensitiveLog)
128+
.ser(se_TranslateKeyMaterialCommand)
129+
.de(de_TranslateKeyMaterialCommand)
130+
.build() {
131+
/** @internal type navigation helper, not in runtime. */
132+
protected declare static __types: {
133+
api: {
134+
input: TranslateKeyMaterialInput;
135+
output: TranslateKeyMaterialOutput;
136+
};
137+
sdk: {
138+
input: TranslateKeyMaterialCommandInput;
139+
output: TranslateKeyMaterialCommandOutput;
140+
};
141+
};
142+
}

0 commit comments

Comments
 (0)