libmongocrypt
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 
70 typedef struct {
71  _mongocrypt_buffer_t edcDerivedToken; // d
72  _mongocrypt_buffer_t escDerivedToken; // s
73  _mongocrypt_buffer_t encryptedTokens; // p
74  _mongocrypt_buffer_t indexKeyId; // u
75  bson_type_t valueType; // t
76  _mongocrypt_buffer_t value; // v
77  _mongocrypt_buffer_t serverEncryptionToken; // e
78  _mongocrypt_buffer_t serverDerivedFromDataToken; // l
79  int64_t contentionFactor; // k
80  mc_array_t edgeTokenSetArray; // g
81  mc_optional_int64_t sparsity; // sp
82  mc_optional_int32_t precision; // pn
83  mc_optional_int32_t trimFactor; // tf
84  bson_value_t indexMin; // mn
85  bson_value_t indexMax; // mx
86  _mongocrypt_buffer_t plaintext;
87  _mongocrypt_buffer_t userKeyId;
89 
101 typedef struct {
102  _mongocrypt_buffer_t edcDerivedToken; // d
103  _mongocrypt_buffer_t escDerivedToken; // s
104  _mongocrypt_buffer_t serverDerivedFromDataToken; // l
105  _mongocrypt_buffer_t encryptedTokens; // p
107 
108 void mc_FLE2InsertUpdatePayloadV2_init(mc_FLE2InsertUpdatePayloadV2_t *payload);
109 
110 bool mc_FLE2InsertUpdatePayloadV2_parse(mc_FLE2InsertUpdatePayloadV2_t *out,
111  const _mongocrypt_buffer_t *in,
112  mongocrypt_status_t *status);
113 
114 /* mc_FLE2InsertUpdatePayloadV2_decrypt decrypts ciphertext.
115  * Returns NULL and sets @status on error. It is an error to call before
116  * mc_FLE2InsertUpdatePayloadV2_parse. */
117 const _mongocrypt_buffer_t *mc_FLE2InsertUpdatePayloadV2_decrypt(_mongocrypt_crypto_t *crypto,
119  const _mongocrypt_buffer_t *user_key,
120  mongocrypt_status_t *status);
121 
122 bool mc_FLE2InsertUpdatePayloadV2_serialize(const mc_FLE2InsertUpdatePayloadV2_t *payload, bson_t *out);
123 
124 bool mc_FLE2InsertUpdatePayloadV2_serializeForRange(const mc_FLE2InsertUpdatePayloadV2_t *payload,
125  bson_t *out,
126  bool use_range_v2);
127 
128 void mc_FLE2InsertUpdatePayloadV2_cleanup(mc_FLE2InsertUpdatePayloadV2_t *payload);
129 
130 #endif /* MC_FLE2_INSERT_UPDATE_PAYLOAD_PRIVATE_V2_H */
Definition: mc-fle2-insert-update-payload-private-v2.h:70
struct _mongocrypt_status_t mongocrypt_status_t
Definition: mongocrypt.h:152
Definition: mc-fle2-insert-update-payload-private-v2.h:101