libmongocrypt-helper 1.20.5.0.1001 → 1.21.0.0.1001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libmongocrypt/libmongocrypt/AGENTS.md +156 -0
  3. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +15 -2
  4. data/ext/libmongocrypt/libmongocrypt/CLAUDE.md +1 -0
  5. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +26 -1
  6. data/ext/libmongocrypt/libmongocrypt/CONTRIBUTING.md +1 -9
  7. data/ext/libmongocrypt/libmongocrypt/README.md +58 -88
  8. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +17 -0
  9. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +6 -4
  10. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +12 -6
  11. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -3
  12. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +8 -6
  13. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +6 -4
  14. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +1 -1
  15. data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +8 -8
  16. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/libmongocrypt-version.txt +1 -1
  17. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +116 -4
  18. data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +2 -6
  19. data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +1 -1
  20. data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +8 -8
  21. data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +1 -1
  22. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +2 -1
  23. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_libcrypto.c +10 -0
  24. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +2 -2
  25. data/ext/libmongocrypt/libmongocrypt/oss-fuzz/crash-kmip-parser-overflow.bin +0 -0
  26. data/ext/libmongocrypt/libmongocrypt/oss-fuzz/crash-kms-chunked-overflow-bof.bin +5 -0
  27. data/ext/libmongocrypt/libmongocrypt/oss-fuzz/crash-kms-chunked-overflow.bin +4 -0
  28. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +25 -2
  29. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +4 -4
  30. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +7 -11
  31. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +1 -1
  32. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/text-search/collinfo.json +1 -1
  33. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/text-search/encrypted-field-config-map.json +1 -1
  34. data/ext/libmongocrypt/libmongocrypt/test/data/compact/text-search/collinfo.json +1 -1
  35. data/ext/libmongocrypt/libmongocrypt/test/data/compact/text-search/encrypted-field-config-map.json +1 -1
  36. data/ext/libmongocrypt/libmongocrypt/test/data/compact/text-search/encrypted-payload.json +1 -1
  37. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields-badVersionSet.json +1 -1
  38. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields-goodVersionSet.json +1 -1
  39. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields.json +1 -1
  40. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/encrypted-field-map.json +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/encrypted-payload.json +1 -1
  42. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/mongocryptd-reply.json +1 -1
  43. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-preview/encrypted-field-map-substringPreview.json +24 -0
  44. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-with-str-encode-version/encrypted-field-map.json +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-with-str-encode-version/encrypted-payload.json +1 -1
  46. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-with-str-encode-version/mongocryptd-reply.json +1 -1
  47. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/cmd-to-mongocryptd.json +2 -2
  48. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/cmd.json +1 -1
  49. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/encrypted-field-config-map.json +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/encrypted-payload.json +1 -1
  51. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/mongocryptd-reply.json +2 -2
  52. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/cmd-to-mongocryptd.json +2 -2
  53. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/cmd.json +1 -1
  54. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/encrypted-field-config-map.json +1 -1
  55. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/encrypted-payload.json +1 -1
  56. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/mongocryptd-reply.json +2 -2
  57. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op0_encrypt_aggregate +0 -0
  58. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op0_encrypt_find +0 -0
  59. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op0_encrypt_insert +0 -0
  60. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op0_with_extra +0 -0
  61. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op1_decrypt_doc +0 -0
  62. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op1_decrypt_empty +0 -0
  63. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op1_with_extra +0 -0
  64. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op2_explicit_encrypt +0 -0
  65. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op2_explicit_encrypt_num +0 -0
  66. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op2_with_extra +0 -0
  67. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op3_explicit_decrypt +0 -0
  68. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op3_with_extra +0 -0
  69. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op4_datakey +0 -0
  70. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op4_with_extra +0 -0
  71. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op5_rewrap_empty_filter +0 -0
  72. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op5_rewrap_filter +0 -0
  73. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op5_with_extra +0 -0
  74. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op6_encrypt_expr +0 -0
  75. data/ext/libmongocrypt/libmongocrypt/test/data/fuzz_mongocrypt_corpus/op6_with_extra +0 -0
  76. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +4 -1
  77. data/ext/libmongocrypt/libmongocrypt/test/fuzz_mongocrypt.c +356 -0
  78. data/ext/libmongocrypt/libmongocrypt/test/gen_fuzz_corpus.py +200 -0
  79. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +35 -68
  80. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +17 -6
  81. data/lib/libmongocrypt_helper/version.rb +2 -2
  82. metadata +28 -2
  83. data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b483fc7b479e693858209265fa305b4bd51e34592b452bbbd36c32c13f262802
4
- data.tar.gz: 352d1052b07f14081865b5c02fe8b33ce2b0a739550db43a6e57d6c26cd1a08b
3
+ metadata.gz: cfbe6382cb548a1982646c49a58ea796bf4dcfbc1c69279035744fea2863f799
4
+ data.tar.gz: 94417181701f8f1c02d4cdbc1120aefd3ffc8228195df488be240508403cae35
5
5
  SHA512:
6
- metadata.gz: 945910ccf2515b64cbd9dd1d97a9de2822562a2544533006e3aa5fa7837107697f6b38e5f43d0da1ce3218fa98d36362a9f883362d9e1efb16bb90fbee7d5236
7
- data.tar.gz: ef89918bdf09d579c60cce8aa5ecdd779a655edffc7223fef5a97fc00fa63ef787c3d5b360ce880812dc3d96562c1ebda7ca158ba4968377e1fd95fcb9c9a81c
6
+ metadata.gz: 6e25030a91d60887c6215da9ed953391c8ef5c2b7561bf7d2e4cb686b7efa3b646b036cc5d1d6ed574f6508f27a7b0a2fe078658a122ab12223d3eece7483a17
7
+ data.tar.gz: cfe9d46be634bd5c3a449d38539069e5e357811eac73dc6d34152b2e9e7fed573137cc9d5ac49c4de05c2cbac87236c1375af745efd6ba7dbd7d6bf23f716495
@@ -0,0 +1,156 @@
1
+ # AGENTS.md
2
+
3
+ This file provides guidance to AI coding agents working with code in this repository.
4
+
5
+ ## What this is
6
+
7
+ libmongocrypt is a C library that assists MongoDB Client Libraries in implementing **In-Use Encryption**. The Client Library behavior it helps support is defined by the Client-Side Encryption specification: <https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md>.
8
+
9
+ ### Naming (from the spec)
10
+
11
+ The public feature is **In-Use Encryption**, consisting of **Client-Side Field Level Encryption (CSFLE)** and **Queryable Encryption (QE)**. Internally, In-Use Encryption is sometimes called **Field Level Encryption (FLE)**; CSFLE is sometimes called Client Side Encryption (as in the spec title); and CSFLE and QE are sometimes called **FLE1** and **FLE2** respectively. So the `mc-fle2-*` payload files under `src/` implement **Queryable Encryption**, not CSFLE.
12
+
13
+ Separately (and confusingly), **`csfle`** is sometimes used within libmongocrypt to mean the **crypt_shared** library — an older name for it, unrelated to the CSFLE feature above. For example, `crypt->csfle` is the crypt_shared vtable.
14
+
15
+ ## Build System
16
+
17
+ This project uses CMake.
18
+
19
+ Use `cmake-build/` as the CMake binary directory unless otherwise specified by the user. When the user specifies a custom binary directory, always use that directory - do not fall back to `cmake-build/`.
20
+
21
+ > [!IMPORTANT]
22
+ > Despite `build/` being a common choice for a CMake binary directory name, that is not recommended in this repository because the `build/` directory is not ignored by Git.
23
+
24
+ The typical configure and build steps (for release and installation):
25
+
26
+ ```bash
27
+ cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -B cmake-build
28
+ cmake --build cmake-build
29
+ ```
30
+
31
+ The optional install step:
32
+
33
+ ```bash
34
+ cmake --install cmake-build
35
+ ```
36
+
37
+ Key CMake configuration options for this project (given `option=(default|alternatives...)`):
38
+
39
+ - `-D CMAKE_INSTALL_PREFIX:PATH=<install-prefix>`: install directory used by `install()`. Use `cmake-build/install/` when system modification is undesirable or disallowed by the user.
40
+ - `-D MONGOCRYPT_CRYPTO:STRING=(OpenSSL|CommonCrypto|CNG|none)`: crypto backend. Defaults to the platform native (OpenSSL on Linux, CommonCrypto on macOS, CNG on Windows).
41
+ - `-D DISABLE_NATIVE_CRYPTO:BOOL=(OFF|ON)`: shortcut for `MONGOCRYPT_CRYPTO=none` — build with no crypto backend; a driver then supplies crypto at runtime via `mongocrypt_setopt_crypto_hooks`.
42
+ - `-D OPENSSL_ROOT_DIR:PATH=<dir>`: OpenSSL location, if not on a default path.
43
+ - `-D USE_SHARED_LIBBSON:BOOL=(OFF|ON)`: link an installed libbson instead of the bundled static one.
44
+ - `-D ENABLE_STATIC:BOOL=(ON|OFF)`: build and install static libraries.
45
+ - `-D BUILD_TESTING:BOOL=(ON|OFF)`: required to enable test targets including `test-mongocrypt` (see [Running Tests](#running-tests)).
46
+ - `-D ENABLE_ONLINE_TESTS:BOOL=(ON|OFF)`: required to enable test targets requiring external servers and the `csfle` utility (requires libmongoc).
47
+
48
+ > [!NOTE]
49
+ > `.evergreen/build_all.sh` is the authoritative reference for CI configure-build-install routines. Consult for platform-specific options and flags.
50
+
51
+ > [!NOTE]
52
+ > For local development and testing, use the Debug configure in the [Running Tests](#running-tests) section instead of the release configure above.
53
+
54
+ ## Dependencies
55
+
56
+ - **libbson** (BSON support): *fetched* at configure time by `cmake/FetchMongoC.cmake`, which downloads the mongo-c-driver source archive at a pinned tag and builds libbson, statically linked into libmongocrypt by default. See comments in `cmake/FetchMongoC.cmake` to bump the pinned tag. Set `-D USE_SHARED_LIBBSON=ON` to instead link an installed libbson found via `find_package(bson)` (set `CMAKE_PREFIX_PATH`).
57
+ - **Intel DFP** (Decimal128 math; target `mongocrypt::intel_dfp`): built at configure time from a *vendored tarball* under `third-party/`. Enabled by `MONGOCRYPT_ENABLE_DECIMAL128` (default ON). Set `-D MONGOCRYPT_DFP_DIR=USE-SYSTEM` to instead use a system install.
58
+ - **kms-message** (KMS request/response): a separate subproject under `kms-message/`, statically compiled into libmongocrypt. The MongoDB C Driver also vendors kms-message.
59
+ - **Crypto backend**: OpenSSL / CommonCrypto / CNG, selected by `MONGOCRYPT_CRYPTO` (see above). On Linux the system OpenSSL is used by default; `DISABLE_NATIVE_CRYPTO=ON` removes the backend entirely.
60
+
61
+ ## Running Tests
62
+
63
+ The typical configure and build steps (for testing and development):
64
+
65
+ ```bash
66
+ cmake -D CMAKE_BUILD_TYPE=Debug -B cmake-build
67
+ cmake --build cmake-build
68
+ ```
69
+
70
+ > [!TIP]
71
+ > For development, prefer the Ninja generator (`-G Ninja`) when available: it builds in parallel across all cores by default, for the fastest edit-build-test loop.
72
+
73
+ Test targets build by default (`BUILD_TESTING=ON`). The suite is a single executable, `test-mongocrypt`, at the top of the binary directory. Run it **from the source root** (it reads `test/data` and `test/example` via relative paths):
74
+
75
+ ```bash
76
+ ./cmake-build/test-mongocrypt # whole suite
77
+ ./cmake-build/test-mongocrypt _test_setopt_kms_providers # a single test, by function name
78
+ ```
79
+
80
+ A few tests need a real crypt_shared library; download one with the `mongodl.py` script from drivers-evergreen-tools: <https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/mongodl.py>
81
+
82
+ ```bash
83
+ python /path/to/mongodl.py --component crypt_shared <out-dir>
84
+ ```
85
+
86
+ CI runs on Evergreen. Submit a patch build to test across supported platforms:
87
+
88
+ ```bash
89
+ evergreen patch --project=libmongocrypt --auto-description --yes --finalize \
90
+ --rv ".*" -t "build-and-test-and-upload"
91
+ ```
92
+
93
+ ### The kms-message subproject
94
+
95
+ `kms-message` is a self-contained subproject with its own tests, configured and built from its own directory:
96
+
97
+ ```bash
98
+ cd kms-message
99
+ ../cmake-build/kms-message/test_kms_request
100
+ ```
101
+
102
+ ## Adding a unit test
103
+
104
+ Tests are C files, not auto-discovered. Two steps are required:
105
+
106
+ 1. Add the file to the `TEST_MONGOCRYPT_SOURCES` list in `CMakeLists.txt`.
107
+ 2. In `test/test-mongocrypt.c`, add an `_mongocrypt_tester_install_*(&tester)` call in `main`, and register each test function inside that installer via `_mongocrypt_tester_install(tester, "_test_name", fn, CRYPTO_REQUIRED)` (or `CRYPTO_OPTIONAL`).
108
+
109
+ ## Architecture
110
+
111
+ ### Components
112
+
113
+ - Client Library (E.g. pymongo, sometimes referred to as a Driver)
114
+ - libmongocrypt acts as a **state machine** and does no I/O.
115
+ - libmongocrypt provides a C interface to the Client Library.
116
+ - Most APIs pass and returns BSON, most structs are opaque, and global init is lazy.
117
+ - See `integrating.md` and the public API in `src/mongocrypt.h`.
118
+ - MongoDB server (mongod / mongos)
119
+ - To send the final commands.
120
+ - To fetch remote schemas.
121
+ - KMS
122
+ - To encrypt/decrypt Data Encryption Keys (DEK) using a backing Key Encryption Key (KEK).
123
+ - mongocryptd / crypt_shared
124
+ - Required for automatic encryption only (not used by explicit encryption, explicit decryption, or automatic decryption)
125
+ - Interchangeable: both do query analysis for automatic encryption.
126
+ - mongocryptd is a daemon that libmongocrypt talks to via the Client Library over TCP using the same wire protocol as a MongoDB server.
127
+ - crypt_shared is a library libmongocrypt loads and calls directly.
128
+ - Only permitted for enterprise or Atlas. This makes automatic encryption an enterprise / Atlas feature.
129
+
130
+ ### Source layout & naming
131
+
132
+ `src/mongocrypt.h` is the only header consumers are expected to directly include. Any header that is not installed is private.
133
+
134
+ Public functions follow `mongocrypt_<type>_<method>` (e.g. `mongocrypt_ctx_id`). `mc_*` is a shorthand for internal components.
135
+
136
+ Other top-level areas: `kms-message/` (vendored KMS request/response library), `bindings/` (language bindings — currently only `python`/PyMongoCrypt, which is released separately from the C library), `etc/` (dev/release scripts), `.evergreen/` (CI), `doc/`.
137
+
138
+ ### C standard
139
+
140
+ Uses C99. Contributions shall not use features from newer standards.
141
+
142
+ ### Core objects & state machine
143
+
144
+ - **`mongocrypt_t`** — the top-level handle; **thread-safe**, and expected to be owned by a Client Library's `MongoClient` / `ClientEncryption` object.
145
+ - **`mongocrypt_ctx_t`** — a single operation (encrypt, decrypt, data-key creation, …); **not thread-safe**, and expected to handle one operation. The Client Library drives it as a state machine, performing the I/O the library requests at each state. See `integrating.md` for the state machine.
146
+ - **`mongocrypt_binary_t`** is a non-owning view; `_destroy` frees the view, not the underlying data.
147
+
148
+ ## Before Committing
149
+
150
+ Format with `./etc/format-all.sh` (requires `uv`; see `CONTRIBUTING.md`). The `kms-message` subproject is not auto-formatted — leave its style as-is.
151
+
152
+ ## Conventions
153
+
154
+ - SemVer. User-visible changes go in `CHANGELOG.md`.
155
+ - Bugs/features are tracked in the Jira **MONGOCRYPT** project; use `MONGOCRYPT-NNN <summary>` in PR titles.
156
+ - Develop test-first (red-green-refactor).
@@ -1,5 +1,14 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 1.21.0
4
+
5
+ ### Changed
6
+ - Bump downloaded libbson version from 2.3.3 to 2.5.6.
7
+
8
+ ### Removed
9
+ - Discontinue builds for EOL Debian releases (version 11, 10, and 9) and remove corresponding CI tasks.
10
+ - Remove support for the `prefixPreview`, `suffixPreview`, and `substringPreview` query types. Setting them with `mongocrypt_ctx_setopt_query_type` or using them in encryptedFields is now an error.
11
+
3
12
  ## 1.20.5
4
13
 
5
14
  ### Fixed
@@ -15,7 +24,8 @@
15
24
  ## 1.20.3
16
25
 
17
26
  ### Fixed
18
- - Validate database and collection name arguments against "." and NUL bytes
27
+ - Validate database and collection name arguments against "." and NUL bytes.
28
+
19
29
  ## 1.20.2
20
30
 
21
31
  ### Changed
@@ -23,7 +33,7 @@
23
33
 
24
34
  ## 1.20.1
25
35
 
26
- ## Changed
36
+ ### Changed
27
37
  - Bump downloaded libbson version from 2.3.0 to 2.3.3 to address configuration error with CMake 4.4.0.
28
38
 
29
39
  ## 1.20.0
@@ -31,6 +41,9 @@
31
41
  ### Added
32
42
  - Stable support for substring queries.
33
43
 
44
+ ### Removed
45
+ - RHEL 6.2 builds. Use the `linux-x86_64-glibc_2_7-nocrypto` build instead as it has an equivalent glibc requirement.
46
+
34
47
  ## 1.19.2
35
48
 
36
49
  ### Added
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -560,7 +560,7 @@ if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
560
560
  endif ()
561
561
 
562
562
  # Exclude example-state-machine since it requires native crypto.
563
- if (NOT MONGOCRYPT_CRYPTO STREQUAL none)
563
+ if (BUILD_TESTING AND NOT MONGOCRYPT_CRYPTO STREQUAL none)
564
564
  # Define example-state-machine
565
565
  add_executable (example-state-machine test/example-state-machine.c)
566
566
  target_link_libraries (example-state-machine PRIVATE mongocrypt _mongocrypt::libbson_for_shared)
@@ -592,6 +592,31 @@ if (NOT MONGOCRYPT_CRYPTO STREQUAL none)
592
592
  endif ()
593
593
  endif ()
594
594
 
595
+ option (ENABLE_FUZZING "Build fuzzing targets. Requires a compiler supporting -fsanitize=fuzzer." OFF)
596
+ if (ENABLE_FUZZING)
597
+ include (CheckCCompilerFlag)
598
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
599
+ check_c_compiler_flag ("-fsanitize=fuzzer-no-link" COMPILER_SUPPORTS_FUZZER)
600
+ unset (CMAKE_TRY_COMPILE_TARGET_TYPE)
601
+ if (NOT COMPILER_SUPPORTS_FUZZER)
602
+ message (FATAL_ERROR
603
+ "ENABLE_FUZZING is ON but the compiler does not support -fsanitize=fuzzer. "
604
+ )
605
+ endif ()
606
+
607
+ add_executable (fuzz_mongocrypt EXCLUDE_FROM_ALL test/fuzz_mongocrypt.c)
608
+ target_include_directories (fuzz_mongocrypt PRIVATE ./src)
609
+ target_link_libraries (fuzz_mongocrypt PRIVATE mongocrypt_static _mongocrypt::libbson_for_static)
610
+ target_compile_options (fuzz_mongocrypt PRIVATE -fsanitize=fuzzer)
611
+ target_link_options (fuzz_mongocrypt PRIVATE -fsanitize=fuzzer)
612
+
613
+ add_executable (fuzz_kms EXCLUDE_FROM_ALL test/fuzz_kms.c)
614
+ target_include_directories (fuzz_kms PRIVATE ./src ./kms-message ./kms-message/src)
615
+ target_link_libraries (fuzz_kms PRIVATE mongocrypt_static kms_message_static _mongocrypt::libbson_for_static)
616
+ target_compile_options (fuzz_kms PRIVATE -fsanitize=fuzzer)
617
+ target_link_options (fuzz_kms PRIVATE -fsanitize=fuzzer)
618
+ endif ()
619
+
595
620
  if (ENABLE_STATIC)
596
621
  set (TARGETS_TO_INSTALL mongocrypt mongocrypt_static)
597
622
  else ()
@@ -1,14 +1,6 @@
1
1
  # Formatting
2
2
 
3
- To format, install `pipx` and run:
3
+ To format, install [uv](https://docs.astral.sh/uv/) and run:
4
4
  ```bash
5
5
  ./etc/format-all.sh
6
6
  ```
7
-
8
- To use a specified python install, set `MONGOCRYPT_PYTHON`:
9
-
10
- ```bash
11
- # Set MONGOCRYPT_PYTHON to a python install with pipx installed.
12
- export MONGOCRYPT_PYTHON=python
13
- ./etc/format-all.sh
14
- ```
@@ -1,6 +1,6 @@
1
1
  # libmongocrypt #
2
2
 
3
- The companion C library for client side encryption in drivers.
3
+ The companion C library for driver support of [In-Use Encryption](https://www.mongodb.com/docs/manual/core/security-in-use-encryption/).
4
4
 
5
5
  This project uses [Semantic Versioning](https://semver.org/).
6
6
 
@@ -12,98 +12,42 @@ If you have encountered a bug, or would like to see a new feature in libmongocry
12
12
  - Navigate to [the MONGOCRYPT project](https://jira.mongodb.org/projects/MONGOCRYPT).
13
13
  - Click **Create Issue** - Please provide as much information as possible about the issue type and how to reproduce it.
14
14
 
15
- ## Documentation ##
16
- See [The Integration Guide](integrating.md) to integrate with your driver.
15
+ ## Security Vulnerabilities ##
17
16
 
18
- See [mongocrypt.h](src/mongocrypt.h) for the public API reference.
17
+ If you’ve identified a security vulnerability, please report it according to the [instructions here](https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report).
19
18
 
20
- ## Building libmongocrypt ##
19
+ # Installing #
21
20
 
22
- On Windows and macOS, libmongocrypt can use the platform's default encryption
23
- APIs as its encryption backend. On other systems, one will want to install the
24
- OpenSSL development libraries, which libmongocrypt will use as the default
25
- encryption backend.
21
+ ## Installing libmongocrypt from source ##
26
22
 
27
- Then build libmongocrypt:
23
+ To build:
28
24
 
25
+ ```bash
26
+ cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -B cmake-build
27
+ cmake --build cmake-build
29
28
  ```
30
- git clone https://github.com/mongodb/libmongocrypt
31
- cd libmongocrypt
32
- mkdir cmake-build && cd cmake-build
33
- cmake ../
34
- make
29
+
30
+ To install:
31
+
32
+ ```bash
33
+ cmake --install cmake-build
35
34
  ```
36
35
 
37
- This builds libmongocrypt.dylib and test-libmongocrypt, in the cmake-build
38
- directory.
36
+ libmongocrypt performs crypto by default with platform crypto APIs on macOS/Windows and OpenSSL on other platforms. Configure with `DISABLE_NATIVE_CRYPTO=ON` to disable the crypto dependency and supply runtime crypto hooks.
39
37
 
40
38
  ## Installing libmongocrypt on macOS ##
41
39
  Install the latest release of libmongocrypt with the following.
42
- ```
40
+ ```bash
43
41
  brew install mongodb/brew/libmongocrypt
44
42
  ```
45
43
 
46
44
  To install the latest unstable development version of libmongocrypt, use `brew install mongodb/brew/libmongocrypt --HEAD`. Do not use the unstable version of libmongocrypt in a production environment.
47
45
 
48
- ## Building libmongocrypt from source on macOS ##
49
-
50
- First install [Homebrew according to its own instructions](https://brew.sh/).
51
-
52
- Install the XCode Command Line Tools:
53
- ```
54
- xcode-select --install
55
- ```
56
-
57
- Then clone and build libmongocrypt:
58
- ```
59
- git clone https://github.com/mongodb/libmongocrypt.git
60
- cd libmongocrypt
61
- cmake .
62
- cmake --build . --target install
63
- ```
64
-
65
- Then, libmongocrypt can be used with pkg-config:
66
- ```
67
- pkg-config libmongocrypt --libs --cflags
68
- ```
69
-
70
- Or use cmake's `find_package`:
71
- ```
72
- find_package (mongocrypt)
73
- # Then link against mongo::mongocrypt
74
- ```
75
-
76
46
  ## Installing libmongocrypt on Windows ##
77
47
  A Windows DLL for x86_64 is available on the Github Releases page. See the [latest release](https://github.com/mongodb/libmongocrypt/releases/latest).
78
48
 
79
49
  Use `gpg` to verify the signature. The public key for `libmongocrypt` is available on https://pgp.mongodb.com/.
80
50
 
81
- ## Python Releases ##
82
- Python releases and tags are signed using the MongoDB Python driver PGP key. Use `gpg` to verify the signature. The public key is available at https://pgp.mongodb.com/python-driver.pub.
83
-
84
-
85
- ### Testing ###
86
- `test-mongocrypt` mocks all I/O with files stored in the `test/data` and `test/example` directories. Run `test-mongocrypt` from the source directory:
87
-
88
- ```
89
- cd libmongocrypt
90
- ./cmake-build/test-mongocrypt
91
- ```
92
-
93
- libmongocrypt is continuously built and published on evergreen. Submit patch builds to this evergreen project when making changes to test on supported platforms.
94
- The latest tarball containing libmongocrypt built on all supported variants is [published here](https://s3.amazonaws.com/mciuploads/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz).
95
-
96
- ### Troubleshooting ###
97
- If OpenSSL is installed in a non-default directory, pass `-DOPENSSL_ROOT_DIR=/path/to/openssl` to the cmake command for libmongocrypt.
98
-
99
- If there are errors with cmake configuration, send the set of steps you performed to the maintainers of this project.
100
-
101
- If there are compilation or linker errors, run `make` again, setting `VERBOSE=1` in the environment or on the command line (which shows exact compile and link commands), and send the output to the maintainers of this project.
102
-
103
- ### Releasing ###
104
-
105
- See [releasing](./doc/releasing.md).
106
-
107
51
  ## Installing libmongocrypt From Distribution Packages ##
108
52
  Distribution packages (i.e., .deb/.rpm) are built and published for several Linux distributions. The installation of these packages for supported platforms is documented here.
109
53
 
@@ -122,23 +66,23 @@ The repository containing the Debian and Ubuntu .deb packages can be configured
122
66
 
123
67
  #### Repository configuration with extrepo ####
124
68
 
125
- Extrepo is available on Debian 11 and newer, as well as Ubuntu 22.04 and newer.
69
+ Extrepo is available on Debian 13 and newer, as well as Ubuntu 22.04 and newer. Note that while extrepo in older Debian and Ubuntu releases may list the libmongocrypt PPA, the packages available for those older releases are most likely outdated and may contain security vulnerabilities.
126
70
 
127
71
  First, install the extrepo package:
128
72
 
129
- ```
73
+ ```bash
130
74
  sudo apt install extrepo
131
75
  ```
132
76
 
133
77
  If you would like to see the information about the repository, it can be viewed with the search command:
134
78
 
135
- ```
79
+ ```bash
136
80
  extrepo search libmongocrypt
137
81
  ```
138
82
 
139
83
  In order to enable the repository, execute this command:
140
84
 
141
- ```
85
+ ```bash
142
86
  sudo extrepo enable libmongocrypt-release
143
87
  ```
144
88
 
@@ -148,19 +92,19 @@ Once the repository is configured, continue with package installation.
148
92
 
149
93
  First, import the public key used to sign the package repositories:
150
94
 
151
- ```
95
+ ```bash
152
96
  sudo sh -c 'curl -s --location https://pgp.mongodb.com/libmongocrypt.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/libmongocrypt.gpg'
153
97
  ```
154
98
 
155
99
  Second, create a list entry for the repository. For Ubuntu systems (be sure to change `<release>` to `jammy` or `noble` as appropriate to your system):
156
100
 
157
- ```
101
+ ```bash
158
102
  echo "deb https://libmongocrypt.s3.amazonaws.com/apt/ubuntu <release>/libmongocrypt/<channel> universe" | sudo tee /etc/apt/sources.list.d/libmongocrypt.list
159
103
  ```
160
104
 
161
- For Debian systems (be sure to change `<release>` to `bullseye`, `bookworm`, or `trixie` as appropriate to your system):
105
+ For Debian systems (be sure to change `<release>` to `bookworm`, or `trixie` as appropriate to your system):
162
106
 
163
- ```
107
+ ```bash
164
108
  echo "deb https://libmongocrypt.s3.amazonaws.com/apt/debian <release>/libmongocrypt/<channel> main" | sudo tee /etc/apt/sources.list.d/libmongocrypt.list
165
109
  ```
166
110
 
@@ -168,7 +112,7 @@ echo "deb https://libmongocrypt.s3.amazonaws.com/apt/debian <release>/libmongocr
168
112
 
169
113
  Finally, update the package cache and install the libmongocrypt packages:
170
114
 
171
- ```
115
+ ```bash
172
116
  sudo apt-get update
173
117
  sudo apt-get install -y libmongocrypt-dev
174
118
  ```
@@ -192,7 +136,7 @@ gpgkey=https://pgp.mongodb.com/libmongocrypt.asc
192
136
 
193
137
  Then install the libmongocrypt packages:
194
138
 
195
- ```
139
+ ```bash
196
140
  sudo yum install -y libmongocrypt
197
141
  ```
198
142
 
@@ -211,7 +155,7 @@ gpgkey=https://pgp.mongodb.com/libmongocrypt.asc
211
155
 
212
156
  Then install the libmongocrypt packages:
213
157
 
214
- ```
158
+ ```bash
215
159
  sudo yum install -y libmongocrypt
216
160
  ```
217
161
 
@@ -230,7 +174,7 @@ gpgkey=https://pgp.mongodb.com/libmongocrypt.asc
230
174
 
231
175
  Then install the libmongocrypt packages:
232
176
 
233
- ```
177
+ ```bash
234
178
  sudo yum install -y libmongocrypt
235
179
  ```
236
180
 
@@ -249,7 +193,7 @@ gpgkey=https://pgp.mongodb.com/libmongocrypt.asc
249
193
 
250
194
  Then install the libmongocrypt packages:
251
195
 
252
- ```
196
+ ```bash
253
197
  sudo yum install -y libmongocrypt
254
198
  ```
255
199
 
@@ -257,18 +201,44 @@ sudo yum install -y libmongocrypt
257
201
 
258
202
  First, import the public key used to sign the package repositories:
259
203
 
260
- ```
204
+ ```bash
261
205
  sudo rpm --import https://pgp.mongodb.com/libmongocrypt.asc
262
206
  ```
263
207
 
264
208
  Second, add the repository (be sure to change `<release>` to `12` or `15`, as appropriate to your system):
265
209
 
266
- ```
210
+ ```bash
267
211
  sudo zypper addrepo --gpgcheck "https://libmongocrypt.s3.amazonaws.com/zypper/suse/<release>/libmongocrypt/<channel>/x86_64" libmongocrypt
268
212
  ```
269
213
 
270
214
  Finally, install the libmongocrypt packages:
271
215
 
272
- ```
216
+ ```bash
273
217
  sudo zypper -n install libmongocrypt
274
218
  ```
219
+
220
+ # Development #
221
+
222
+ ## Documentation ##
223
+
224
+ The [Client-Side Encryption](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md) driver specification.
225
+
226
+ See [The Integration Guide](integrating.md) to integrate with your driver.
227
+
228
+ See [mongocrypt.h](src/mongocrypt.h) for the public API reference.
229
+
230
+ ## Testing ##
231
+ `test-mongocrypt` mocks all I/O with files stored in the `test/data` and `test/example` directories. Run `test-mongocrypt` from the source directory:
232
+
233
+ ```bash
234
+ ./cmake-build/test-mongocrypt
235
+ ```
236
+
237
+ libmongocrypt is continuously built and published on evergreen. Submit patch builds to this evergreen project when making changes to test on supported platforms.
238
+
239
+ ## Releasing ##
240
+
241
+ See [releasing](./doc/releasing.md).
242
+
243
+ ### Python Releases ###
244
+ Python releases and tags are signed using the MongoDB Python driver PGP key. Use `gpg` to verify the signature. The public key is available at https://pgp.mongodb.com/python-driver.pub.
@@ -1,6 +1,23 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ Changes in Version 1.20.0
5
+ -------------------------
6
+
7
+ - Bundle libmongocrypt 1.20.5 in release wheels.
8
+
9
+ Changes in Version 1.19.0
10
+ -------------------------
11
+
12
+ - Bundle libmongocrypt 1.20.4 in release wheels.
13
+ - Renamed the ``text_opts`` parameter of ``ExplicitEncryptOpts`` and
14
+ ``ExplicitEncrypter.encrypt`` to ``string_opts``, matching the "string"
15
+ algorithm it configures. This is a breaking change.
16
+ - The "textPreview" algorithm has been removed. Use "string" instead.
17
+ - The "prefixPreview", "suffixPreview", and "substringPreview" query types are
18
+ now deprecated aliases of "prefix", "suffix", and "substring". Prefer the new
19
+ names, as a future release removes the aliases.
20
+
4
21
  Changes in Version 1.18.1
5
22
  -------------------------
6
23
 
@@ -93,7 +93,7 @@ class AsyncExplicitEncrypter:
93
93
  contention_factor=None,
94
94
  range_opts=None,
95
95
  is_expression=False,
96
- text_opts=None,
96
+ string_opts=None,
97
97
  ):
98
98
  """Encrypts a BSON value.
99
99
 
@@ -115,8 +115,8 @@ class AsyncExplicitEncrypter:
115
115
  with the "range" algorithm encoded as a BSON document.
116
116
  - `is_expression` (boolean): True if this is an encryptExpression()
117
117
  context. Defaults to False.
118
- - `text_opts` (bytes): Options for explicit encryption
119
- with the "textPreview" algorithm encoded as a BSON document.
118
+ - `string_opts` (bytes): Options for explicit encryption
119
+ with the "string" algorithm encoded as a BSON document.
120
120
 
121
121
  :Returns:
122
122
  The encrypted BSON value.
@@ -127,6 +127,8 @@ class AsyncExplicitEncrypter:
127
127
  Added the `range_opts` and `is_expression` parameters.
128
128
  .. versionchanged:: 1.16
129
129
  Added the `text_opts` parameter.
130
+ .. versionchanged:: 1.19
131
+ Renamed the `text_opts` parameter to `string_opts`.
130
132
  """
131
133
  # CDRIVER-3275 key_alt_name needs to be wrapped in a bson document.
132
134
  if key_alt_name is not None:
@@ -139,7 +141,7 @@ class AsyncExplicitEncrypter:
139
141
  contention_factor,
140
142
  range_opts,
141
143
  is_expression,
142
- text_opts,
144
+ string_opts,
143
145
  )
144
146
  with self.mongocrypt.explicit_encryption_context(value, opts) as ctx:
145
147
  return await run_state_machine(ctx, self.callback)
@@ -431,6 +431,10 @@ bool mongocrypt_setopt_encrypted_field_config_map(mongocrypt_t *crypt, mongocryp
431
431
  * the path string is literal "$SYSTEM", then libmongocrypt will defer to the
432
432
  * system's library resolution mechanism to find the crypt_shared library.
433
433
  *
434
+ * @warning Use of "$SYSTEM" will search system directories for the
435
+ * mongo_crypt_v1.(dll,so,dylib) following the search behavior of LoadLibrary
436
+ * on Windows and dlopen on Unix. Ensure secure deployment of the library.
437
+ *
434
438
  * @note If no crypt_shared dynamic library is found in any of the directories
435
439
  * specified by the search paths loaded here, @ref mongocrypt_init() will still
436
440
  * succeed and continue to operate without crypt_shared.
@@ -687,7 +691,8 @@ bool mongocrypt_ctx_setopt_algorithm(mongocrypt_ctx_t *ctx, const char *algorith
687
691
  /// String constant for setopt_algorithm "Indexed" explicit encryption
688
692
  /// String constant for setopt_algorithm "Unindexed" explicit encryption
689
693
  // DEPRECATED: support "RangePreview" has been removed in favor of "range".
690
- /// NOTE: "textPreview" is experimental only and may be removed in a future non-major release.
694
+ /// DEPRECATED: "textPreview" has been removed. Use "string".
695
+ // String constant for setopt_algorithm "string" explicit encryption.
691
696
 
692
697
  /**
693
698
  * Identify the AWS KMS master key to use for creating a data key.
@@ -1485,9 +1490,8 @@ bool mongocrypt_ctx_setopt_query_type(mongocrypt_ctx_t *ctx, const char *query_t
1485
1490
  bool mongocrypt_ctx_setopt_algorithm_range(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *opts);
1486
1491
 
1487
1492
  /**
1488
- * Set options for explicit encryption with the "textPreview" algorithm.
1493
+ * Set options for explicit encryption with the "string" algorithm.
1489
1494
  *
1490
- * NOTE: "textPreview" is experimental only and may be removed in a future non-major release.
1491
1495
  * @p opts is a BSON document of the form:
1492
1496
  * {
1493
1497
  * "caseSensitive": bool,
@@ -1508,6 +1512,8 @@ bool mongocrypt_ctx_setopt_algorithm_range(mongocrypt_ctx_t *ctx, mongocrypt_bin
1508
1512
  * }
1509
1513
  *
1510
1514
  * "prefix" and "suffix" can both be set.
1515
+ *
1516
+ * NOTE: Driver public APIs should use the name "string" rather than "text" to refer to options.
1511
1517
  */
1512
1518
  bool mongocrypt_ctx_setopt_algorithm_text(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *opts);
1513
1519
 
@@ -1522,9 +1528,9 @@ bool mongocrypt_setopt_key_expiration(mongocrypt_t *crypt, uint64_t cache_expira
1522
1528
 
1523
1529
  /// String constants for setopt_query_type
1524
1530
  // DEPRECATED: Support "rangePreview" has been removed in favor of "range".
1525
- /// NOTE: "substringPreview" is experimental and may be removed in a future non-major release.
1526
- /// NOTE: "suffixPreview" is experimental and may be removed in a future non-major release.
1527
- /// NOTE: "prefixPreview" is experimental and may be removed in a future non-major release.
1531
+ /// DEPRECATED: Support for "substringPreview" has been removed in favor of "substring"
1532
+ /// DEPRECATED: Support for "suffixPreview" has been removed in favor of "suffix"
1533
+ /// DEPRECATED: Support for "prefixPreview" has been removed in favor of "prefix"
1528
1534
 
1529
1535
  """
1530
1536
  )
@@ -501,9 +501,11 @@ class ExplicitEncryptionContext(MongoCryptContext):
501
501
  ):
502
502
  self._raise_from_status()
503
503
 
504
- if opts.text_opts is not None:
505
- with MongoCryptBinaryIn(opts.text_opts) as text_opts:
506
- if not lib.mongocrypt_ctx_setopt_algorithm_text(ctx, text_opts.bin):
504
+ if opts.string_opts is not None:
505
+ with MongoCryptBinaryIn(opts.string_opts) as string_opts:
506
+ if not lib.mongocrypt_ctx_setopt_algorithm_text(
507
+ ctx, string_opts.bin
508
+ ):
507
509
  self._raise_from_status()
508
510
 
509
511
  with MongoCryptBinaryIn(value) as binary: