Skip to content

Commit da1e387

Browse files
author
awstools
committed
feat(client-payment-cryptography-data): Adding support for dynamic keys for encrypt, decrypt, re-encrypt and translate pin functions. With this change, customers can use one-time TR-31 keys directly in dataplane operations without the need to first import them into the service.
1 parent e40b474 commit da1e387

File tree

7 files changed

+311
-33
lines changed

7 files changed

+311
-33
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ export interface DecryptDataCommandOutput extends DecryptDataOutput, __MetadataB
9898
* InitializationVector: "STRING_VALUE",
9999
* },
100100
* },
101+
* WrappedKey: { // WrappedKey
102+
* WrappedKeyMaterial: { // WrappedKeyMaterial Union: only one key present
103+
* Tr31KeyBlock: "STRING_VALUE",
104+
* },
105+
* KeyCheckValueAlgorithm: "STRING_VALUE",
106+
* },
101107
* };
102108
* const command = new DecryptDataCommand(input);
103109
* const response = await client.send(command);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ export interface EncryptDataCommandOutput extends EncryptDataOutput, __MetadataB
104104
* InitializationVector: "STRING_VALUE",
105105
* },
106106
* },
107+
* WrappedKey: { // WrappedKey
108+
* WrappedKeyMaterial: { // WrappedKeyMaterial Union: only one key present
109+
* Tr31KeyBlock: "STRING_VALUE",
110+
* },
111+
* KeyCheckValueAlgorithm: "STRING_VALUE",
112+
* },
107113
* };
108114
* const command = new EncryptDataCommand(input);
109115
* const response = await client.send(command);

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export interface ReEncryptDataCommandInput extends ReEncryptDataInput {}
3737
export interface ReEncryptDataCommandOutput extends ReEncryptDataOutput, __MetadataBearer {}
3838

3939
/**
40-
* <p>Re-encrypt ciphertext using DUKPT, Symmetric and Asymmetric Data Encryption Keys. </p>
41-
* <p>You can either generate an encryption key within Amazon Web Services Payment Cryptography by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a> or import your own encryption key by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a>. The <code>KeyArn</code> for use with this operation must be in a compatible key state with <code>KeyModesOfUse</code> set to <code>Encrypt</code>. In asymmetric encryption, ciphertext is encrypted using public component (imported by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a>) of the asymmetric key pair created outside of Amazon Web Services Payment Cryptography. </p>
42-
* <p>For symmetric and DUKPT encryption, Amazon Web Services Payment Cryptography supports <code>TDES</code> and <code>AES</code> algorithms. For asymmetric encryption, Amazon Web Services Payment Cryptography supports <code>RSA</code>. To encrypt using DUKPT, a DUKPT key must already exist within your account with <code>KeyModesOfUse</code> set to <code>DeriveKey</code> or a new DUKPT can be generated by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a>.</p>
40+
* <p>Re-encrypt ciphertext using DUKPT or Symmetric data encryption keys. </p>
41+
* <p>You can either generate an encryption key within Amazon Web Services Payment Cryptography by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a> or import your own encryption key by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html">ImportKey</a>. The <code>KeyArn</code> for use with this operation must be in a compatible key state with <code>KeyModesOfUse</code> set to <code>Encrypt</code>. </p>
42+
* <p>For symmetric and DUKPT encryption, Amazon Web Services Payment Cryptography supports <code>TDES</code> and <code>AES</code> algorithms. To encrypt using DUKPT, a DUKPT key must already exist within your account with <code>KeyModesOfUse</code> set to <code>DeriveKey</code> or a new DUKPT can be generated by calling <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a>.</p>
4343
* <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>
4444
* <p>
4545
* <b>Cross-account use</b>: This operation can't be used across different Amazon Web Services accounts.</p>
@@ -106,6 +106,18 @@ export interface ReEncryptDataCommandOutput extends ReEncryptDataOutput, __Metad
106106
* InitializationVector: "STRING_VALUE",
107107
* },
108108
* },
109+
* IncomingWrappedKey: { // WrappedKey
110+
* WrappedKeyMaterial: { // WrappedKeyMaterial Union: only one key present
111+
* Tr31KeyBlock: "STRING_VALUE",
112+
* },
113+
* KeyCheckValueAlgorithm: "STRING_VALUE",
114+
* },
115+
* OutgoingWrappedKey: {
116+
* WrappedKeyMaterial: {// Union: only one key present
117+
* Tr31KeyBlock: "STRING_VALUE",
118+
* },
119+
* KeyCheckValueAlgorithm: "STRING_VALUE",
120+
* },
109121
* };
110122
* const command = new ReEncryptDataCommand(input);
111123
* const response = await client.send(command);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ export interface TranslatePinDataCommandOutput extends TranslatePinDataOutput, _
102102
* DukptKeyDerivationType: "STRING_VALUE",
103103
* DukptKeyVariant: "STRING_VALUE",
104104
* },
105+
* IncomingWrappedKey: { // WrappedKey
106+
* WrappedKeyMaterial: { // WrappedKeyMaterial Union: only one key present
107+
* Tr31KeyBlock: "STRING_VALUE",
108+
* },
109+
* KeyCheckValueAlgorithm: "STRING_VALUE",
110+
* },
111+
* OutgoingWrappedKey: {
112+
* WrappedKeyMaterial: {// Union: only one key present
113+
* Tr31KeyBlock: "STRING_VALUE",
114+
* },
115+
* KeyCheckValueAlgorithm: "STRING_VALUE",
116+
* },
105117
* };
106118
* const command = new TranslatePinDataCommand(input);
107119
* const response = await client.send(command);

clients/client-payment-cryptography-data/src/models/models_0.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,12 +953,84 @@ export namespace EncryptionDecryptionAttributes {
953953
};
954954
}
955955

956+
/**
957+
* @public
958+
* @enum
959+
*/
960+
export const KeyCheckValueAlgorithm = {
961+
ANSI_X9_24: "ANSI_X9_24",
962+
CMAC: "CMAC",
963+
} as const;
964+
965+
/**
966+
* @public
967+
*/
968+
export type KeyCheckValueAlgorithm = (typeof KeyCheckValueAlgorithm)[keyof typeof KeyCheckValueAlgorithm];
969+
970+
/**
971+
* <p>Parameter information of a WrappedKeyBlock for encryption key exchange.</p>
972+
* @public
973+
*/
974+
export type WrappedKeyMaterial = WrappedKeyMaterial.Tr31KeyBlockMember | WrappedKeyMaterial.$UnknownMember;
975+
976+
/**
977+
* @public
978+
*/
979+
export namespace WrappedKeyMaterial {
980+
/**
981+
* <p>The TR-31 wrapped key block.</p>
982+
* @public
983+
*/
984+
export interface Tr31KeyBlockMember {
985+
Tr31KeyBlock: string;
986+
$unknown?: never;
987+
}
988+
989+
/**
990+
* @public
991+
*/
992+
export interface $UnknownMember {
993+
Tr31KeyBlock?: never;
994+
$unknown: [string, any];
995+
}
996+
997+
export interface Visitor<T> {
998+
Tr31KeyBlock: (value: string) => T;
999+
_: (name: string, value: any) => T;
1000+
}
1001+
1002+
export const visit = <T>(value: WrappedKeyMaterial, visitor: Visitor<T>): T => {
1003+
if (value.Tr31KeyBlock !== undefined) return visitor.Tr31KeyBlock(value.Tr31KeyBlock);
1004+
return visitor._(value.$unknown[0], value.$unknown[1]);
1005+
};
1006+
}
1007+
1008+
/**
1009+
* <p>Parameter information of a WrappedKeyBlock for encryption key exchange.</p>
1010+
* @public
1011+
*/
1012+
export interface WrappedKey {
1013+
/**
1014+
* <p>Parameter information of a WrappedKeyBlock for encryption key exchange.</p>
1015+
* @public
1016+
*/
1017+
WrappedKeyMaterial: WrappedKeyMaterial | undefined;
1018+
1019+
/**
1020+
* <p>The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). It is used to validate the key integrity.</p>
1021+
* <p>For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be checked and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is computed using a CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest order bytes of the encrypted result.</p>
1022+
* @public
1023+
*/
1024+
KeyCheckValueAlgorithm?: KeyCheckValueAlgorithm;
1025+
}
1026+
9561027
/**
9571028
* @public
9581029
*/
9591030
export interface DecryptDataInput {
9601031
/**
9611032
* <p>The <code>keyARN</code> of the encryption key that Amazon Web Services Payment Cryptography uses for ciphertext decryption.</p>
1033+
* <p>When a WrappedKeyBlock is provided, this value will be the identifier to the key wrapping key. Otherwise, it is the key identifier used to perform the operation.</p>
9621034
* @public
9631035
*/
9641036
KeyIdentifier: string | undefined;
@@ -974,6 +1046,12 @@ export interface DecryptDataInput {
9741046
* @public
9751047
*/
9761048
DecryptionAttributes: EncryptionDecryptionAttributes | undefined;
1049+
1050+
/**
1051+
* <p>The WrappedKeyBlock containing the encryption key for ciphertext decryption.</p>
1052+
* @public
1053+
*/
1054+
WrappedKey?: WrappedKey;
9771055
}
9781056

9791057
/**
@@ -1164,6 +1242,7 @@ export interface DukptDerivationAttributes {
11641242
export interface EncryptDataInput {
11651243
/**
11661244
* <p>The <code>keyARN</code> of the encryption key that Amazon Web Services Payment Cryptography uses for plaintext encryption.</p>
1245+
* <p>When a WrappedKeyBlock is provided, this value will be the identifier to the key wrapping key. Otherwise, it is the key identifier used to perform the operation.</p>
11671246
* @public
11681247
*/
11691248
KeyIdentifier: string | undefined;
@@ -1182,6 +1261,12 @@ export interface EncryptDataInput {
11821261
* @public
11831262
*/
11841263
EncryptionAttributes: EncryptionDecryptionAttributes | undefined;
1264+
1265+
/**
1266+
* <p>The WrappedKeyBlock containing the encryption key for plaintext encryption.</p>
1267+
* @public
1268+
*/
1269+
WrappedKey?: WrappedKey;
11851270
}
11861271

11871272
/**
@@ -2109,6 +2194,7 @@ export namespace ReEncryptionAttributes {
21092194
export interface ReEncryptDataInput {
21102195
/**
21112196
* <p>The <code>keyARN</code> of the encryption key of incoming ciphertext data.</p>
2197+
* <p>When a WrappedKeyBlock is provided, this value will be the identifier to the key wrapping key. Otherwise, it is the key identifier used to perform the operation.</p>
21122198
* @public
21132199
*/
21142200
IncomingKeyIdentifier: string | undefined;
@@ -2136,6 +2222,18 @@ export interface ReEncryptDataInput {
21362222
* @public
21372223
*/
21382224
OutgoingEncryptionAttributes: ReEncryptionAttributes | undefined;
2225+
2226+
/**
2227+
* <p>The WrappedKeyBlock containing the encryption key of incoming ciphertext data.</p>
2228+
* @public
2229+
*/
2230+
IncomingWrappedKey?: WrappedKey;
2231+
2232+
/**
2233+
* <p>The WrappedKeyBlock containing the encryption key of outgoing ciphertext data after encryption by Amazon Web Services Payment Cryptography.</p>
2234+
* @public
2235+
*/
2236+
OutgoingWrappedKey?: WrappedKey;
21392237
}
21402238

21412239
/**
@@ -2277,6 +2375,7 @@ export namespace TranslationIsoFormats {
22772375
export interface TranslatePinDataInput {
22782376
/**
22792377
* <p>The <code>keyARN</code> of the encryption key under which incoming PIN block data is encrypted. This key type can be PEK or BDK.</p>
2378+
* <p>When a WrappedKeyBlock is provided, this value will be the identifier to the key wrapping key for PIN block. Otherwise, it is the key identifier used to perform the operation.</p>
22802379
* @public
22812380
*/
22822381
IncomingKeyIdentifier: string | undefined;
@@ -2316,6 +2415,18 @@ export interface TranslatePinDataInput {
23162415
* @public
23172416
*/
23182417
OutgoingDukptAttributes?: DukptDerivationAttributes;
2418+
2419+
/**
2420+
* <p>The WrappedKeyBlock containing the encryption key under which incoming PIN block data is encrypted.</p>
2421+
* @public
2422+
*/
2423+
IncomingWrappedKey?: WrappedKey;
2424+
2425+
/**
2426+
* <p>The WrappedKeyBlock containing the encryption key for encrypting outgoing PIN block data.</p>
2427+
* @public
2428+
*/
2429+
OutgoingWrappedKey?: WrappedKey;
23192430
}
23202431

23212432
/**
@@ -2973,6 +3084,22 @@ export const EncryptionDecryptionAttributesFilterSensitiveLog = (obj: Encryption
29733084
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
29743085
};
29753086

3087+
/**
3088+
* @internal
3089+
*/
3090+
export const WrappedKeyMaterialFilterSensitiveLog = (obj: WrappedKeyMaterial): any => {
3091+
if (obj.Tr31KeyBlock !== undefined) return { Tr31KeyBlock: SENSITIVE_STRING };
3092+
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
3093+
};
3094+
3095+
/**
3096+
* @internal
3097+
*/
3098+
export const WrappedKeyFilterSensitiveLog = (obj: WrappedKey): any => ({
3099+
...obj,
3100+
...(obj.WrappedKeyMaterial && { WrappedKeyMaterial: WrappedKeyMaterialFilterSensitiveLog(obj.WrappedKeyMaterial) }),
3101+
});
3102+
29763103
/**
29773104
* @internal
29783105
*/
@@ -2982,6 +3109,7 @@ export const DecryptDataInputFilterSensitiveLog = (obj: DecryptDataInput): any =
29823109
...(obj.DecryptionAttributes && {
29833110
DecryptionAttributes: EncryptionDecryptionAttributesFilterSensitiveLog(obj.DecryptionAttributes),
29843111
}),
3112+
...(obj.WrappedKey && { WrappedKey: WrappedKeyFilterSensitiveLog(obj.WrappedKey) }),
29853113
});
29863114

29873115
/**
@@ -3001,6 +3129,7 @@ export const EncryptDataInputFilterSensitiveLog = (obj: EncryptDataInput): any =
30013129
...(obj.EncryptionAttributes && {
30023130
EncryptionAttributes: EncryptionDecryptionAttributesFilterSensitiveLog(obj.EncryptionAttributes),
30033131
}),
3132+
...(obj.WrappedKey && { WrappedKey: WrappedKeyFilterSensitiveLog(obj.WrappedKey) }),
30043133
});
30053134

30063135
/**
@@ -3080,6 +3209,8 @@ export const ReEncryptDataInputFilterSensitiveLog = (obj: ReEncryptDataInput): a
30803209
...(obj.OutgoingEncryptionAttributes && {
30813210
OutgoingEncryptionAttributes: ReEncryptionAttributesFilterSensitiveLog(obj.OutgoingEncryptionAttributes),
30823211
}),
3212+
...(obj.IncomingWrappedKey && { IncomingWrappedKey: WrappedKeyFilterSensitiveLog(obj.IncomingWrappedKey) }),
3213+
...(obj.OutgoingWrappedKey && { OutgoingWrappedKey: WrappedKeyFilterSensitiveLog(obj.OutgoingWrappedKey) }),
30833214
});
30843215

30853216
/**
@@ -3124,6 +3255,8 @@ export const TranslatePinDataInputFilterSensitiveLog = (obj: TranslatePinDataInp
31243255
OutgoingTranslationAttributes: TranslationIsoFormatsFilterSensitiveLog(obj.OutgoingTranslationAttributes),
31253256
}),
31263257
...(obj.EncryptedPinBlock && { EncryptedPinBlock: SENSITIVE_STRING }),
3258+
...(obj.IncomingWrappedKey && { IncomingWrappedKey: WrappedKeyFilterSensitiveLog(obj.IncomingWrappedKey) }),
3259+
...(obj.OutgoingWrappedKey && { OutgoingWrappedKey: WrappedKeyFilterSensitiveLog(obj.OutgoingWrappedKey) }),
31273260
});
31283261

31293262
/**

clients/client-payment-cryptography-data/src/protocols/Aws_restJson1.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ import {
9696
VisaPin,
9797
VisaPinVerification,
9898
VisaPinVerificationValue,
99+
WrappedKey,
100+
WrappedKeyMaterial,
99101
} from "../models/models_0";
100102
import { PaymentCryptographyDataServiceException as __BaseException } from "../models/PaymentCryptographyDataServiceException";
101103

@@ -117,6 +119,7 @@ export const se_DecryptDataCommand = async (
117119
take(input, {
118120
CipherText: [],
119121
DecryptionAttributes: (_) => _json(_),
122+
WrappedKey: (_) => _json(_),
120123
})
121124
);
122125
b.m("POST").h(headers).b(body);
@@ -141,6 +144,7 @@ export const se_EncryptDataCommand = async (
141144
take(input, {
142145
EncryptionAttributes: (_) => _json(_),
143146
PlainText: [],
147+
WrappedKey: (_) => _json(_),
144148
})
145149
);
146150
b.m("POST").h(headers).b(body);
@@ -242,8 +246,10 @@ export const se_ReEncryptDataCommand = async (
242246
take(input, {
243247
CipherText: [],
244248
IncomingEncryptionAttributes: (_) => _json(_),
249+
IncomingWrappedKey: (_) => _json(_),
245250
OutgoingEncryptionAttributes: (_) => _json(_),
246251
OutgoingKeyIdentifier: [],
252+
OutgoingWrappedKey: (_) => _json(_),
247253
})
248254
);
249255
b.m("POST").h(headers).b(body);
@@ -269,9 +275,11 @@ export const se_TranslatePinDataCommand = async (
269275
IncomingDukptAttributes: (_) => _json(_),
270276
IncomingKeyIdentifier: [],
271277
IncomingTranslationAttributes: (_) => _json(_),
278+
IncomingWrappedKey: (_) => _json(_),
272279
OutgoingDukptAttributes: (_) => _json(_),
273280
OutgoingKeyIdentifier: [],
274281
OutgoingTranslationAttributes: (_) => _json(_),
282+
OutgoingWrappedKey: (_) => _json(_),
275283
})
276284
);
277285
b.m("POST").h(headers).b(body);
@@ -883,6 +891,10 @@ const de_VerificationFailedExceptionRes = async (
883891

884892
// se_VisaPinVerificationValue omitted.
885893

894+
// se_WrappedKey omitted.
895+
896+
// se_WrappedKeyMaterial omitted.
897+
886898
// de_PinData omitted.
887899

888900
// de_ValidationExceptionField omitted.

0 commit comments

Comments
 (0)