Skip to content

Commit 1b8543b

Browse files
committed
PHPC-2092: ClientEncryption options for queryable encryption
Several new constants for these options have been introduced.
1 parent 52f014b commit 1b8543b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/MongoDB/ClientEncryption.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ void php_phongo_clientencryption_init_ce(INIT_FUNC_ARGS) /* {{{ */
189189

190190
zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC"), MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC);
191191
zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM"), MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM);
192+
zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("ALGORITHM_INDEXED"), MONGOC_ENCRYPT_ALGORITHM_INDEXED);
193+
zend_declare_class_constant_string(php_phongo_clientencryption_ce, ZEND_STRL("ALGORITHM_UNINDEXED"), MONGOC_ENCRYPT_ALGORITHM_UNINDEXED);
194+
zend_declare_class_constant_long(php_phongo_clientencryption_ce, ZEND_STRL("QUERY_TYPE_EQUALITY"), MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY);
192195
} /* }}} */
193196

194197
#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION
@@ -463,6 +466,10 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
463466
return opts;
464467
}
465468

469+
if (php_array_existsc(options, "contentionFactor")) {
470+
mongoc_client_encryption_encrypt_opts_set_contention_factor(opts, php_array_fetch_long(options, "contentionFactor"));
471+
}
472+
466473
if (php_array_existsc(options, "keyId")) {
467474
bson_value_t keyid = { 0 };
468475

@@ -503,6 +510,10 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
503510
}
504511
}
505512

513+
if (php_array_existsc(options, "queryType")) {
514+
mongoc_client_encryption_encrypt_opts_set_query_type(opts, php_array_fetch_long(options, "queryType"));
515+
}
516+
506517
return opts;
507518

508519
cleanup:

tests/clientEncryption/clientEncryption-constants.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ MongoDB\Driver\ClientEncryption constants
55

66
var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC);
77
var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM);
8+
var_dump(MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED);
9+
var_dump(MongoDB\Driver\ClientEncryption::ALGORITHM_UNINDEXED);
10+
var_dump(MongoDB\Driver\ClientEncryption::QUERY_TYPE_EQUALITY);
811

912
?>
1013
===DONE===
1114
<?php exit(0); ?>
1215
--EXPECT--
1316
string(43) "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
1417
string(36) "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
18+
string(7) "Indexed"
19+
string(9) "Unindexed"
20+
int(0)
1521
===DONE===

0 commit comments

Comments
 (0)