libmongocrypt
Toggle main menu visibility
Loading...
Searching...
No Matches
src
mc-fle2-insert-update-payload-private-v2.h
1
/*
2
* Copyright 2022-present MongoDB, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef MC_FLE2_INSERT_UPDATE_PAYLOAD_PRIVATE_V2_H
18
#define MC_FLE2_INSERT_UPDATE_PAYLOAD_PRIVATE_V2_H
19
20
#include <bson/bson.h>
21
22
#include "mc-array-private.h"
23
#include "mc-optional-private.h"
24
#include "mongocrypt-buffer-private.h"
25
#include "mongocrypt-private.h"
26
#include "
mongocrypt.h
"
27
28
/*
29
* The *TokenSet types corresponds to the following BSON document:
30
* d: <binary> // EDC derived from data & contention factor token
31
* s: <binary> // ESC derived from data & contention factor token
32
* l: <binary> // server derived from data token
33
* p: <binary> // encrypted token for compaction
34
*/
35
#define DEF_TEXT_SEARCH_TOKEN_SET(Type) \
36
typedef struct { \
37
_mongocrypt_buffer_t edcDerivedToken;
/* d */
\
38
_mongocrypt_buffer_t escDerivedToken;
/* s */
\
39
_mongocrypt_buffer_t serverDerivedFromDataToken;
/* l */
\
40
_mongocrypt_buffer_t encryptedTokens;
/* p */
\
41
} mc_Text##Type##TokenSet_t; \
42
void mc_Text##Type##TokenSet_init(mc_Text##Type##TokenSet_t *); \
43
void mc_Text##Type##TokenSet_cleanup(mc_Text##Type##TokenSet_t *); \
44
void mc_Text##Type##TokenSet_shallow_copy(const mc_Text##Type##TokenSet_t *src, mc_Text##Type##TokenSet_t *dest)
45
46
DEF_TEXT_SEARCH_TOKEN_SET(Exact);
47
DEF_TEXT_SEARCH_TOKEN_SET(Substring);
48
DEF_TEXT_SEARCH_TOKEN_SET(Suffix);
49
DEF_TEXT_SEARCH_TOKEN_SET(Prefix);
50
59
typedef
struct
{
60
mc_TextExactTokenSet_t exact;
// e
61
mc_array_t substringArray;
// s
62
mc_array_t suffixArray;
// u
63
mc_array_t prefixArray;
// p
64
}
mc_TextSearchTokenSets_t
;
65
66
void
mc_TextSearchTokenSets_init(
mc_TextSearchTokenSets_t
*);
67
void
mc_TextSearchTokenSets_cleanup(
mc_TextSearchTokenSets_t
*);
68
111
112
typedef
struct
{
113
_mongocrypt_buffer_t edcDerivedToken;
// d
114
_mongocrypt_buffer_t escDerivedToken;
// s
115
_mongocrypt_buffer_t encryptedTokens;
// p
116
_mongocrypt_buffer_t indexKeyId;
// u
117
bson_type_t valueType;
// t
118
_mongocrypt_buffer_t value;
// v
119
_mongocrypt_buffer_t serverEncryptionToken;
// e
120
_mongocrypt_buffer_t serverDerivedFromDataToken;
// l
121
int64_t contentionFactor;
// k
122
mc_array_t edgeTokenSetArray;
// g
123
mc_optional_int64_t sparsity;
// sp
124
mc_optional_int32_t precision;
// pn
125
mc_optional_int32_t trimFactor;
// tf
126
bson_value_t indexMin;
// mn
127
bson_value_t indexMax;
// mx
128
129
struct
{
130
mc_TextSearchTokenSets_t
tsts;
131
bool
set;
132
} textSearchTokenSets;
// b
133
134
_mongocrypt_buffer_t plaintext;
135
_mongocrypt_buffer_t userKeyId;
136
}
mc_FLE2InsertUpdatePayloadV2_t
;
137
138
// `mc_FLE2InsertUpdatePayloadV2_t` inherits extended alignment from libbson. To dynamically allocate, use
139
// aligned allocation (e.g. BSON_ALIGNED_ALLOC)
140
BSON_STATIC_ASSERT2(alignof_mc_FLE2InsertUpdatePayloadV2_t,
141
BSON_ALIGNOF(
mc_FLE2InsertUpdatePayloadV2_t
) >= BSON_ALIGNOF(bson_value_t));
142
154
typedef
struct
{
155
_mongocrypt_buffer_t edcDerivedToken;
// d
156
_mongocrypt_buffer_t escDerivedToken;
// s
157
_mongocrypt_buffer_t serverDerivedFromDataToken;
// l
158
_mongocrypt_buffer_t encryptedTokens;
// p
159
}
mc_EdgeTokenSetV2_t
;
160
161
void
mc_FLE2InsertUpdatePayloadV2_init(
mc_FLE2InsertUpdatePayloadV2_t
*payload);
162
163
bool
mc_FLE2InsertUpdatePayloadV2_parse(
mc_FLE2InsertUpdatePayloadV2_t
*out,
164
const
_mongocrypt_buffer_t *in,
165
mongocrypt_status_t
*status);
166
167
/* mc_FLE2InsertUpdatePayloadV2_decrypt decrypts ciphertext.
168
* Returns NULL and sets @status on error. It is an error to call before
169
* mc_FLE2InsertUpdatePayloadV2_parse. */
170
const
_mongocrypt_buffer_t *mc_FLE2InsertUpdatePayloadV2_decrypt(_mongocrypt_crypto_t *crypto,
171
mc_FLE2InsertUpdatePayloadV2_t
*iup,
172
const
_mongocrypt_buffer_t *user_key,
173
mongocrypt_status_t
*status);
174
175
bool
mc_FLE2InsertUpdatePayloadV2_serialize(
const
mc_FLE2InsertUpdatePayloadV2_t
*payload, bson_t *out);
176
177
bool
mc_FLE2InsertUpdatePayloadV2_serializeForRange(
const
mc_FLE2InsertUpdatePayloadV2_t
*payload, bson_t *out);
178
179
bool
mc_FLE2InsertUpdatePayloadV2_serializeForTextSearch(
const
mc_FLE2InsertUpdatePayloadV2_t
*payload, bson_t *out);
180
181
void
mc_FLE2InsertUpdatePayloadV2_cleanup(
mc_FLE2InsertUpdatePayloadV2_t
*payload);
182
183
#endif
/* MC_FLE2_INSERT_UPDATE_PAYLOAD_PRIVATE_V2_H */
mongocrypt.h
mongocrypt_status_t
struct _mongocrypt_status_t mongocrypt_status_t
Definition
mongocrypt.h:152
mc_EdgeTokenSetV2_t
Definition
mc-fle2-insert-update-payload-private-v2.h:154
mc_FLE2InsertUpdatePayloadV2_t
Definition
mc-fle2-insert-update-payload-private-v2.h:112
mc_TextSearchTokenSets_t
Definition
mc-fle2-insert-update-payload-private-v2.h:59
Generated by
1.17.0