Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c54bbaa

Browse files
committed
PHPC-1499: Declare class constants for encryption algorithms
1 parent 47fb81c commit c54bbaa

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

‎src/MongoDB/ClientEncryption.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ void php_phongo_clientencryption_init_ce(INIT_FUNC_ARGS) /* {{{ */
193193
php_phongo_handler_clientencryption.free_obj = php_phongo_clientencryption_free_object;
194194
php_phongo_handler_clientencryption.offset = XtOffsetOf(php_phongo_clientencryption_t, std);
195195
#endif
196+
197+
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 TSRMLS_CC);
198+
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 TSRMLS_CC);
196199
} /* }}} */
197200

198201
/*
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
MongoDB\Driver\ClientEncryption constants
3+
--FILE--
4+
<?php
5+
6+
var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC);
7+
var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM);
8+
9+
?>
10+
===DONE===
11+
<?php exit(0); ?>
12+
--EXPECT--
13+
string(43) "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
14+
string(36) "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
15+
===DONE===

‎tests/clientEncryption/clientEncryption-decrypt-001.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $clientEncryption = $manager->createClientEncryption(['keyVaultNamespace' => 'de
1616

1717
$key = $clientEncryption->createDataKey('local');
1818

19-
$encrypted = $clientEncryption->encrypt('top-secret', ['keyId' => $key, 'algorithm' => 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic']);
19+
$encrypted = $clientEncryption->encrypt('top-secret', ['keyId' => $key, 'algorithm' => MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC]);
2020
var_dump($clientEncryption->decrypt($encrypted));
2121

2222
?>

‎tests/clientEncryption/clientEncryption-encrypt-001.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $clientEncryption = $manager->createClientEncryption(['keyVaultNamespace' => 'de
1616

1717
$key = $clientEncryption->createDataKey('local');
1818

19-
var_dump($clientEncryption->encrypt('top-secret', ['keyId' => $key, 'algorithm' => 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic']));
19+
var_dump($clientEncryption->encrypt('top-secret', ['keyId' => $key, 'algorithm' => MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC]));
2020

2121
?>
2222
===DONE===

‎tests/manager/manager-ctor-auto_encryption-001.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $tests = [
2828
],
2929
],
3030
'bsonType' => 'objectId',
31-
'algorithm' => 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic',
31+
'algorithm' => MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC,
3232
],
3333
],
3434
],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /