Skip to content

Commit 026cf91

Browse files
committed
Merge branch 'main' into av_add_auth_to_init_023
- Updating working branch with main.
2 parents 3262a9c + 44b2e79 commit 026cf91

24 files changed

Lines changed: 354 additions & 358 deletions

src/client/dbps_api_client.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ EncryptApiResponse DBPSApiClient::Encrypt(
188188
Type::type datatype,
189189
const std::optional<int>& datatype_length,
190190
CompressionCodec::type compression,
191-
Format::type format,
191+
Encoding::type encoding,
192192
const std::map<std::string, std::string>& encoding_attributes,
193193
CompressionCodec::type encrypted_compression,
194194
const std::string& key_id,
@@ -200,7 +200,7 @@ EncryptApiResponse DBPSApiClient::Encrypt(
200200
json_request.datatype_ = datatype;
201201
json_request.datatype_length_ = datatype_length;
202202
json_request.compression_ = compression;
203-
json_request.format_ = format;
203+
json_request.encoding_ = encoding;
204204
json_request.encoding_attributes_ = encoding_attributes;
205205
json_request.encrypted_compression_ = encrypted_compression;
206206
json_request.key_id_ = key_id;
@@ -270,7 +270,7 @@ DecryptApiResponse DBPSApiClient::Decrypt(
270270
Type::type datatype,
271271
const std::optional<int>& datatype_length,
272272
CompressionCodec::type compression,
273-
Format::type format,
273+
Encoding::type encoding,
274274
const std::map<std::string, std::string>& encoding_attributes,
275275
CompressionCodec::type encrypted_compression,
276276
const std::string& key_id,
@@ -283,7 +283,7 @@ DecryptApiResponse DBPSApiClient::Decrypt(
283283
json_request.datatype_ = datatype;
284284
json_request.datatype_length_ = datatype_length;
285285
json_request.compression_ = compression;
286-
json_request.format_ = format;
286+
json_request.encoding_ = encoding;
287287
json_request.encoding_attributes_ = encoding_attributes;
288288
json_request.encrypted_compression_ = encrypted_compression;
289289
json_request.key_id_ = key_id;

src/client/dbps_api_client.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class DBPSApiClient {
164164
* @param column_name Name of the database column for which this data is being encrypted
165165
* @param datatype The data type of the plaintext (e.g., BYTE_ARRAY, STRING, etc.)
166166
* @param compression Compression algorithm used to compress the plaintext before this call (format of the input)
167-
* @param format Data format specification (Parquet formats supported)
167+
* @param encoding Data encoding specification (Parquet encodings supported)
168168
* @param encoding_attributes Map of string key-value pairs containing encoding-specific attributes
169169
* @param encrypted_compression Compression algorithm to be used to compress the encrypted data (format of the output)
170170
* @param key_id Identifier for the encryption key to be used (not the key itself)
@@ -173,15 +173,15 @@ class DBPSApiClient {
173173
*
174174
* @return The encryption API response object containing comprehensive information about the call
175175
*
176-
* @note Data types, compression types, and formats as defined in the enums.h file are supported
176+
* @note Data types, compression types, and encodings as defined in the enums.h file are supported
177177
*/
178178
EncryptApiResponse Encrypt(
179179
span<const uint8_t> plaintext,
180180
const std::string& column_name,
181181
Type::type datatype,
182182
const std::optional<int>& datatype_length,
183183
CompressionCodec::type compression,
184-
Format::type format,
184+
Encoding::type encoding,
185185
const std::map<std::string, std::string>& encoding_attributes,
186186
CompressionCodec::type encrypted_compression,
187187
const std::string& key_id,
@@ -196,7 +196,7 @@ class DBPSApiClient {
196196
* @param column_name Name of the database column for which this data is being decrypted
197197
* @param datatype The data type of the original plaintext (e.g., BYTE_ARRAY, STRING, etc.)
198198
* @param compression Compression algorithm used to compress the encrypted data before this call (format of the input)
199-
* @param format Data format specification (Parquet formats supported)
199+
* @param encoding Data encoding specification (Parquet encodings supported)
200200
* @param encoding_attributes Map of string key-value pairs containing encoding-specific attributes
201201
* @param encrypted_compression Compression algorithm to be used to compress the decrypted data (format of the output)
202202
* @param key_id Identifier for the encryption key to be used for decryption (not the key itself)
@@ -205,15 +205,15 @@ class DBPSApiClient {
205205
*
206206
* @return The decryption API response object containing comprehensive information about the call
207207
*
208-
* @note Data types, compression types, and formats as defined in the enums.h file are supported
208+
* @note Data types, compression types, and encodings as defined in the enums.h file are supported
209209
*/
210210
DecryptApiResponse Decrypt(
211211
span<const uint8_t> ciphertext,
212212
const std::string& column_name,
213213
Type::type datatype,
214214
const std::optional<int>& datatype_length,
215215
CompressionCodec::type compression,
216-
Format::type format,
216+
Encoding::type encoding,
217217
const std::map<std::string, std::string>& encoding_attributes,
218218
CompressionCodec::type encrypted_compression,
219219
const std::string& key_id,

src/client/dbps_api_client_test.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ TEST(DBPSApiClient, DecryptApiResponseGetResponsePlaintextWithValidData) {
236236
json_response.decrypted_value_ = StringToBytes("test@example.com");
237237
json_response.datatype_ = Type::BYTE_ARRAY;
238238
json_response.compression_ = CompressionCodec::UNCOMPRESSED;
239-
json_response.format_ = Format::PLAIN;
239+
json_response.encoding_ = Encoding::PLAIN;
240240
json_response.user_id_ = "test_user";
241241
json_response.role_ = "test_role";
242242
json_response.access_control_ = "test_access";
@@ -280,7 +280,7 @@ TEST(DBPSApiClient, EncryptWithValidData) {
280280
"value": "dGVzdEBleGFtcGxlLmNvbQ==",
281281
"value_format": {
282282
"compression": "UNCOMPRESSED",
283-
"format": "PLAIN"
283+
"encoding": "PLAIN"
284284
}
285285
},
286286
"data_batch_encrypted": {
@@ -325,7 +325,7 @@ TEST(DBPSApiClient, EncryptWithValidData) {
325325
Type::BYTE_ARRAY, // datatype
326326
std::nullopt, // datatype_length
327327
CompressionCodec::UNCOMPRESSED, // compression
328-
Format::PLAIN, // format
328+
Encoding::PLAIN, // encoding
329329
std::map<std::string, std::string>{}, // encoding_attributes
330330
CompressionCodec::UNCOMPRESSED, // encrypted_compression
331331
"test_key_123", // key_id
@@ -366,7 +366,7 @@ TEST(DBPSApiClient, DecryptWithValidData) {
366366
},
367367
"value_format": {
368368
"compression": "UNCOMPRESSED",
369-
"format": "PLAIN"
369+
"encoding": "PLAIN"
370370
}
371371
},
372372
"data_batch_encrypted": {
@@ -388,7 +388,7 @@ TEST(DBPSApiClient, DecryptWithValidData) {
388388
"value": "dGVzdEBleGFtcGxlLmNvbQ==",
389389
"value_format": {
390390
"compression": "UNCOMPRESSED",
391-
"format": "PLAIN"
391+
"encoding": "PLAIN"
392392
}
393393
},
394394
"access": {
@@ -417,7 +417,7 @@ TEST(DBPSApiClient, DecryptWithValidData) {
417417
Type::BYTE_ARRAY, // datatype
418418
std::nullopt, // datatype_length
419419
CompressionCodec::UNCOMPRESSED, // compression
420-
Format::PLAIN, // format
420+
Encoding::PLAIN, // encoding
421421
std::map<std::string, std::string>{}, // encoding_attributes
422422
CompressionCodec::UNCOMPRESSED, // encrypted_compression
423423
"test_key_123", // key_id
@@ -464,7 +464,7 @@ TEST(DBPSApiClient, EncryptWithInvalidData) {
464464
Type::BYTE_ARRAY, // datatype
465465
std::nullopt, // datatype_length
466466
CompressionCodec::UNCOMPRESSED, // compression
467-
Format::PLAIN, // format
467+
Encoding::PLAIN, // encoding
468468
std::map<std::string, std::string>{}, // encoding_attributes
469469
CompressionCodec::UNCOMPRESSED, // encrypted_compression
470470
"test_key_123", // key_id
@@ -494,7 +494,7 @@ TEST(DBPSApiClient, DecryptWithInvalidData) {
494494
Type::BYTE_ARRAY, // datatype
495495
std::nullopt, // datatype_length
496496
CompressionCodec::UNCOMPRESSED, // compression
497-
Format::PLAIN, // format
497+
Encoding::PLAIN, // encoding
498498
std::map<std::string, std::string>{}, // encoding_attributes
499499
CompressionCodec::UNCOMPRESSED, // encrypted_compression
500500
"test_key_123", // key_id
@@ -521,7 +521,7 @@ TEST(DBPSApiClient, EncryptWithInvalidJsonResponse) {
521521
"value": "dGVzdEBleGFtcGxlLmNvbQ==",
522522
"value_format": {
523523
"compression": "UNCOMPRESSED",
524-
"format": "PLAIN"
524+
"encoding": "PLAIN"
525525
}
526526
},
527527
"data_batch_encrypted": {
@@ -560,7 +560,7 @@ TEST(DBPSApiClient, EncryptWithInvalidJsonResponse) {
560560
Type::BYTE_ARRAY, // datatype
561561
std::nullopt, // datatype_length
562562
CompressionCodec::UNCOMPRESSED, // compression
563-
Format::PLAIN, // format
563+
Encoding::PLAIN, // encoding
564564
std::map<std::string, std::string>{}, // encoding_attributes
565565
CompressionCodec::UNCOMPRESSED, // encrypted_compression
566566
"test_key_123", // key_id
@@ -585,7 +585,7 @@ TEST(DBPSApiClient, DecryptWithInvalidJsonResponse) {
585585
},
586586
"value_format": {
587587
"compression": "UNCOMPRESSED",
588-
"format": "PLAIN"
588+
"encoding": "PLAIN"
589589
}
590590
},
591591
"data_batch_encrypted": {
@@ -626,7 +626,7 @@ TEST(DBPSApiClient, DecryptWithInvalidJsonResponse) {
626626
Type::BYTE_ARRAY, // datatype
627627
std::nullopt, // datatype_length
628628
CompressionCodec::UNCOMPRESSED, // compression
629-
Format::PLAIN, // format
629+
Encoding::PLAIN, // encoding
630630
std::map<std::string, std::string>{}, // encoding_attributes
631631
CompressionCodec::UNCOMPRESSED, // encrypted_compression
632632
"test_key_123", // key_id
@@ -653,7 +653,7 @@ TEST(DBPSApiClient, EncryptWithEncodingAttributes) {
653653
"value": "dGVzdEBleGFtcGxlLmNvbQ==",
654654
"value_format": {
655655
"compression": "UNCOMPRESSED",
656-
"format": "PLAIN",
656+
"encoding": "PLAIN",
657657
"encoding_attributes": {
658658
"page_type": "DATA_PAGE",
659659
"page_encoding": "PLAIN",
@@ -709,7 +709,7 @@ TEST(DBPSApiClient, EncryptWithEncodingAttributes) {
709709
Type::BYTE_ARRAY, // datatype
710710
std::nullopt, // datatype_length
711711
CompressionCodec::UNCOMPRESSED, // compression
712-
Format::PLAIN, // format
712+
Encoding::PLAIN, // encoding
713713
encoding_attributes, // encoding_attributes
714714
CompressionCodec::UNCOMPRESSED, // encrypted_compression
715715
"test_key_123", // key_id

src/common/dbpa_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class DBPS_EXPORT DataBatchProtectionAgentInterface {
123123
* Encrypts the provided plaintext data using the configured encryption parameters.
124124
*
125125
* @param plaintext Binary data to be encrypted, provided as a span of bytes
126-
* @param encoding_attributes A map of string key-values. The plaintext is encoded with a type defined in enums.h Format::type.
126+
* @param encoding_attributes A map of string key-values. The plaintext is encoded with a type defined in enums.h Encoding::type.
127127
* Each encoding type requires additional attributes to be properly decoded. These attributes are specified in the map so an
128128
* implementation can properly interpret and process the input text.
129129
*

src/common/dbpa_interface_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TEST(DBPAInterface, AgentEncryptDecrypt) {
108108
MockAgent agent;
109109
std::vector<uint8_t> original = {10, 20, 30};
110110

111-
std::map<std::string, std::string> encoding_attributes = {{"format", "PLAIN"}};
111+
std::map<std::string, std::string> encoding_attributes = {{"page_encoding", "PLAIN"}};
112112
auto encrypted = agent.Encrypt(span<const uint8_t>(original.data(), original.size()), encoding_attributes);
113113
ASSERT_TRUE(encrypted->success());
114114

src/common/dbpa_local.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ std::unique_ptr<EncryptionResult> LocalDataBatchProtectionAgent::Encrypt(
179179
return std::make_unique<LocalEncryptionResult>("initialization", *initialized_);
180180
}
181181

182-
// Extract page_encoding from encoding_attributes and convert to Format::type
183-
auto format_opt = dbps::external::ExtractPageEncoding(encoding_attributes);
184-
if (!format_opt.has_value()) {
182+
// Extract page_encoding from encoding_attributes and convert to Encoding::type
183+
auto encoding_opt = dbps::external::ExtractPageEncoding(encoding_attributes);
184+
if (!encoding_opt.has_value()) {
185185
std::cerr << "ERROR: LocalDataBatchProtectionAgent::Encrypt() - page_encoding not found or invalid in encoding_attributes." << std::endl;
186186
return std::make_unique<LocalEncryptionResult>("parameter_validation", "page_encoding not found or invalid in encoding_attributes");
187187
}
@@ -192,7 +192,7 @@ std::unique_ptr<EncryptionResult> LocalDataBatchProtectionAgent::Encrypt(
192192
datatype_,
193193
datatype_length_,
194194
compression_type_,
195-
format_opt.value(),
195+
encoding_opt.value(),
196196
encoding_attributes,
197197
compression_type_,
198198
column_key_id_,
@@ -205,7 +205,7 @@ std::unique_ptr<EncryptionResult> LocalDataBatchProtectionAgent::Encrypt(
205205
std::vector<uint8_t> plaintext_vec(plaintext.begin(), plaintext.end());
206206

207207
// Call the sequencer to encrypt
208-
bool encrypt_result = sequencer.ConvertAndEncrypt(plaintext_vec);
208+
bool encrypt_result = sequencer.DecodeAndEncrypt(plaintext_vec);
209209
if (!encrypt_result) {
210210
std::cerr << "ERROR: LocalDataBatchProtectionAgent::Encrypt() - Encryption failed: "
211211
<< sequencer.error_stage_ << " - " << sequencer.error_message_ << std::endl;
@@ -230,9 +230,9 @@ std::unique_ptr<DecryptionResult> LocalDataBatchProtectionAgent::Decrypt(
230230
return std::make_unique<LocalDecryptionResult>("initialization", *initialized_);
231231
}
232232

233-
// Extract page_encoding from encoding_attributes and convert to Format::type
234-
auto format_opt = dbps::external::ExtractPageEncoding(encoding_attributes);
235-
if (!format_opt.has_value()) {
233+
// Extract page_encoding from encoding_attributes and convert to Encoding::type
234+
auto encoding_opt = dbps::external::ExtractPageEncoding(encoding_attributes);
235+
if (!encoding_opt.has_value()) {
236236
std::cerr << "ERROR: LocalDataBatchProtectionAgent::Decrypt() - page_encoding not found or invalid in encoding_attributes." << std::endl;
237237
return std::make_unique<LocalDecryptionResult>("parameter_validation", "page_encoding not found or invalid in encoding_attributes");
238238
}
@@ -243,7 +243,7 @@ std::unique_ptr<DecryptionResult> LocalDataBatchProtectionAgent::Decrypt(
243243
datatype_,
244244
datatype_length_,
245245
compression_type_,
246-
format_opt.value(),
246+
encoding_opt.value(),
247247
encoding_attributes,
248248
compression_type_,
249249
column_key_id_,
@@ -256,7 +256,7 @@ std::unique_ptr<DecryptionResult> LocalDataBatchProtectionAgent::Decrypt(
256256
std::vector<uint8_t> ciphertext_vec(ciphertext.begin(), ciphertext.end());
257257

258258
// Call the sequencer to decrypt
259-
bool decrypt_result = sequencer.ConvertAndDecrypt(ciphertext_vec);
259+
bool decrypt_result = sequencer.DecryptAndEncode(ciphertext_vec);
260260
if (!decrypt_result) {
261261
std::cerr << "ERROR: LocalDataBatchProtectionAgent::Decrypt() - Decryption failed: "
262262
<< sequencer.error_stage_ << " - " << sequencer.error_message_ << std::endl;

src/common/dbpa_remote.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ std::unique_ptr<EncryptionResult> RemoteDataBatchProtectionAgent::Encrypt(span<c
258258
return std::make_unique<RemoteEncryptionResult>(std::move(empty_response));
259259
}
260260

261-
// Extract page_encoding from encoding_attributes and convert to Format::type
262-
auto format_opt = ExtractPageEncoding(encoding_attributes);
263-
if (!format_opt.has_value()) {
261+
// Extract page_encoding from encoding_attributes and convert to Encoding::type
262+
auto encoding_opt = ExtractPageEncoding(encoding_attributes);
263+
if (!encoding_opt.has_value()) {
264264
std::cerr << "ERROR: RemoteDataBatchProtectionAgent::Encrypt() - page_encoding not found or invalid in encoding_attributes." << std::endl;
265265
auto empty_response = std::make_unique<EncryptApiResponse>();
266266
empty_response->SetApiClientError("page_encoding not found or invalid in encoding_attributes");
@@ -274,7 +274,7 @@ std::unique_ptr<EncryptionResult> RemoteDataBatchProtectionAgent::Encrypt(span<c
274274
datatype_,
275275
datatype_length_,
276276
compression_type_,
277-
format_opt.value(),
277+
encoding_opt.value(),
278278
encoding_attributes,
279279
compression_type_,
280280
column_key_id_,
@@ -314,9 +314,9 @@ std::unique_ptr<DecryptionResult> RemoteDataBatchProtectionAgent::Decrypt(span<c
314314
return std::make_unique<RemoteDecryptionResult>(std::move(empty_response));
315315
}
316316

317-
// Extract page_encoding from encoding_attributes and convert to Format::type
318-
auto format_opt = ExtractPageEncoding(encoding_attributes);
319-
if (!format_opt.has_value()) {
317+
// Extract page_encoding from encoding_attributes and convert to Encoding::type
318+
auto encoding_opt = ExtractPageEncoding(encoding_attributes);
319+
if (!encoding_opt.has_value()) {
320320
std::cerr << "ERROR: RemoteDataBatchProtectionAgent::Decrypt() - page_encoding not found or invalid in encoding_attributes." << std::endl;
321321
auto empty_response = std::make_unique<DecryptApiResponse>();
322322
empty_response->SetApiClientError("page_encoding not found or invalid in encoding_attributes");
@@ -330,7 +330,7 @@ std::unique_ptr<DecryptionResult> RemoteDataBatchProtectionAgent::Decrypt(span<c
330330
datatype_,
331331
datatype_length_,
332332
compression_type_,
333-
format_opt.value(),
333+
encoding_opt.value(),
334334
encoding_attributes,
335335
compression_type_,
336336
column_key_id_,
@@ -341,7 +341,7 @@ std::unique_ptr<DecryptionResult> RemoteDataBatchProtectionAgent::Decrypt(span<c
341341
);
342342

343343
// Validate that response fields match request fields
344-
// TODO: Add validation for format when these are expanded beyond PLAIN.
344+
// TODO: Add validation for encoding when these are expanded beyond PLAIN.
345345
if (response.Success()) {
346346
const auto& response_attrs = response.GetResponseAttributes();
347347

src/common/dbpa_remote_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ TEST_F(RemoteDataBatchProtectionAgentTest, SuccessfulDecryption) {
502502
"\"debug\":{\"reference_id\":\"123\"},"
503503
"\"data_batch\":{"
504504
"\"datatype_info\":{\"datatype\":\"BYTE_ARRAY\"},"
505-
"\"value_format\":{\"compression\":\"UNCOMPRESSED\",\"format\":\"PLAIN\"},"
505+
"\"value_format\":{\"compression\":\"UNCOMPRESSED\",\"encoding\":\"PLAIN\"},"
506506
"\"value\":\"dGVzdF9kYXRh\""
507507
"}}",
508508
""
@@ -551,7 +551,7 @@ TEST_F(RemoteDataBatchProtectionAgentTest, DecryptionFieldMismatch) {
551551
"\"debug\":{\"reference_id\":\"123\"},"
552552
"\"data_batch\":{"
553553
"\"datatype_info\":{\"datatype\":\"INT32\"},"
554-
"\"value_format\":{\"compression\":\"UNCOMPRESSED\",\"format\":\"PLAIN\"},"
554+
"\"value_format\":{\"compression\":\"UNCOMPRESSED\",\"encoding\":\"PLAIN\"},"
555555
"\"value\":\"dGVzdF9kYXRh\""
556556
"}}",
557557
"datatype mismatch",
@@ -564,7 +564,7 @@ TEST_F(RemoteDataBatchProtectionAgentTest, DecryptionFieldMismatch) {
564564
"\"debug\":{\"reference_id\":\"123\"},"
565565
"\"data_batch\":{"
566566
"\"datatype_info\":{\"datatype\":\"BYTE_ARRAY\"},"
567-
"\"value_format\":{\"compression\":\"GZIP\",\"format\":\"PLAIN\"},"
567+
"\"value_format\":{\"compression\":\"GZIP\",\"encoding\":\"PLAIN\"},"
568568
"\"value\":\"dGVzdF9kYXRh\""
569569
"}}",
570570
"compression mismatch",

0 commit comments

Comments
 (0)