libcouchbase 1.3.0 → 1.3.2
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.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/ext/libcouchbase/CMakeLists.txt +51 -25
- data/ext/libcouchbase/CONTRIBUTING.md +46 -65
- data/ext/libcouchbase/RELEASE_NOTES.markdown +163 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +9 -11
- data/ext/libcouchbase/cmake/Modules/FindProfiler.cmake +16 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +6 -6
- data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
- data/ext/libcouchbase/cmake/configure +16 -0
- data/ext/libcouchbase/example/CMakeLists.txt +17 -2
- data/ext/libcouchbase/example/analytics/.gitignore +1 -0
- data/ext/libcouchbase/example/analytics/analytics.c +158 -0
- data/ext/libcouchbase/example/analytics/build-queries.rb +34 -0
- data/ext/libcouchbase/example/analytics/cJSON.c +1 -0
- data/ext/libcouchbase/example/analytics/cJSON.h +1 -0
- data/ext/libcouchbase/example/analytics/queries.h +113 -0
- data/ext/libcouchbase/example/analytics/queries/00-show-dataverse.json +5 -0
- data/ext/libcouchbase/example/analytics/queries/01-setup-dataset-breweries.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/02-setup-dataset-beers.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/03-initiate-shadow.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/04-list-datasets.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/05-count-breweries.json +5 -0
- data/ext/libcouchbase/example/analytics/queries/06-first-brewery.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/07-key-based-lookup.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/08-exact-match-lookup.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/09-exact-match-lookup-different-shape.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/10-other-query-filters.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/11-equijoin.json +9 -0
- data/ext/libcouchbase/example/analytics/queries/12-equijoin-select-star.json +10 -0
- data/ext/libcouchbase/example/analytics/queries/13-ansi-join.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/14-join-select-values.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/15-nested-outer-join.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/16-theta-join.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/17-existential-quantification.json +9 -0
- data/ext/libcouchbase/example/analytics/queries/18-universal-quantification.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/19-simple-aggregation.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/20-simple-aggregation-unwrapped-value.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/21-simple-aggregation-explicit.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/22-grouping-and-aggregation.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/23-grouping-and-aggregation-with-hint.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/24-grouping-and-limits.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/25-named-parameters.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/26-positional-parameters.json +7 -0
- data/ext/libcouchbase/example/crypto/common_provider.c +2 -0
- data/ext/libcouchbase/example/crypto/common_provider.h +2 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +5 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +0 -1
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +16 -26
- data/ext/libcouchbase/example/db/db.c +10 -6
- data/ext/libcouchbase/example/fts/.gitignore +1 -0
- data/ext/libcouchbase/example/fts/build-queries.rb +33 -0
- data/ext/libcouchbase/example/fts/fts.c +142 -0
- data/ext/libcouchbase/example/fts/queries.h +61 -0
- data/ext/libcouchbase/example/fts/queries/00-simple-text-query.json +12 -0
- data/ext/libcouchbase/example/fts/queries/01-simple-text-query-on-non-default-index.json +9 -0
- data/ext/libcouchbase/example/fts/queries/02-simple-text-query-on-stored-field.json +13 -0
- data/ext/libcouchbase/example/fts/queries/03-match-query-with-facet.json +19 -0
- data/ext/libcouchbase/example/fts/queries/04-docid-query.json +11 -0
- data/ext/libcouchbase/example/fts/queries/05-unanalyzed-term-query-with-fuzziness-level-of-0.json +13 -0
- data/ext/libcouchbase/example/fts/queries/06-unanalyzed-term-query-with-fuzziness-level-of-2.json +14 -0
- data/ext/libcouchbase/example/fts/queries/07-match-phrase-query.json +13 -0
- data/ext/libcouchbase/example/fts/queries/08-phrase-query.json +16 -0
- data/ext/libcouchbase/example/fts/queries/09-query-string-query.json +9 -0
- data/ext/libcouchbase/example/fts/queries/10-conjunction-query.json +21 -0
- data/ext/libcouchbase/example/fts/queries/11-wild-card-query.json +13 -0
- data/ext/libcouchbase/example/fts/queries/12-numeric-range-query.json +11 -0
- data/ext/libcouchbase/example/fts/queries/13-regexp-query.json +13 -0
- data/ext/libcouchbase/example/minimal/.gitignore +1 -0
- data/ext/libcouchbase/example/minimal/query.c +185 -0
- data/ext/libcouchbase/example/subdoc/subdoc-xattrs.c +2 -2
- data/ext/libcouchbase/example/tracing/cJSON.c +1 -1
- data/ext/libcouchbase/example/tracing/cJSON.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/cbft.h +38 -4
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +8 -97
- data/ext/libcouchbase/include/libcouchbase/cntl.h +288 -8
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +47 -10
- data/ext/libcouchbase/include/libcouchbase/crypto.h +214 -48
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +12 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +33 -2
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +87 -13
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +3 -7
- data/ext/libcouchbase/include/libcouchbase/tracing.h +174 -56
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +21 -1
- data/ext/libcouchbase/include/libcouchbase/views.h +49 -4
- data/ext/libcouchbase/packaging/deb/control +2 -3
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +7 -5
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +7 -5
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +14 -12
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +3 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +14 -6
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +7 -5
- data/ext/libcouchbase/src/bootstrap.cc +6 -1
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +2 -7
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +1 -1
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +4 -11
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +29 -36
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +4 -2
- data/ext/libcouchbase/src/cntl.cc +181 -151
- data/ext/libcouchbase/src/config_static.h +1 -1
- data/ext/libcouchbase/src/connspec.cc +5 -1
- data/ext/libcouchbase/src/connspec.h +3 -1
- data/ext/libcouchbase/src/crypto.cc +93 -80
- data/ext/libcouchbase/src/dns-srv.cc +1 -1
- data/ext/libcouchbase/src/handler.cc +0 -1
- data/ext/libcouchbase/src/http/http-priv.h +1 -0
- data/ext/libcouchbase/src/http/http.cc +1 -2
- data/ext/libcouchbase/src/instance.cc +21 -2
- data/ext/libcouchbase/src/internal.h +1 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +24 -3
- data/ext/libcouchbase/src/lcbio/ioutils.cc +1 -1
- data/ext/libcouchbase/src/lcbio/rw-inl.h +22 -1
- data/ext/libcouchbase/src/lcbio/ssl.h +2 -0
- data/ext/libcouchbase/src/mc/compress.cc +18 -11
- data/ext/libcouchbase/src/mc/mcreq.c +2 -0
- data/ext/libcouchbase/src/mc/mcreq.h +1 -1
- data/ext/libcouchbase/src/mcserver/mcserver.cc +163 -6
- data/ext/libcouchbase/src/mcserver/negotiate.cc +17 -7
- data/ext/libcouchbase/src/n1ql/n1ql.cc +12 -3
- data/ext/libcouchbase/src/newconfig.cc +4 -3
- data/ext/libcouchbase/src/nodeinfo.cc +1 -7
- data/ext/libcouchbase/src/operations/observe.cc +1 -0
- data/ext/libcouchbase/src/operations/ping.cc +5 -3
- data/ext/libcouchbase/src/retryq.cc +22 -0
- data/ext/libcouchbase/src/retryq.h +2 -1
- data/ext/libcouchbase/src/rnd.cc +5 -12
- data/ext/libcouchbase/src/settings.c +4 -7
- data/ext/libcouchbase/src/settings.h +6 -2
- data/ext/libcouchbase/src/strcodecs/base64.c +59 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +2 -0
- data/ext/libcouchbase/src/trace.h +2 -2
- data/ext/libcouchbase/src/tracing/span.cc +177 -45
- data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +70 -28
- data/ext/libcouchbase/src/tracing/tracing-internal.h +33 -48
- data/ext/libcouchbase/src/vbucket/vbucket.c +146 -30
- data/ext/libcouchbase/src/wait.cc +1 -1
- data/ext/libcouchbase/tests/CMakeLists.txt +13 -4
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_misc.cc +2 -2
- data/ext/libcouchbase/tests/iotests/t_views.cc +1 -1
- data/ext/libcouchbase/tests/iotests/testutil.cc +3 -2
- data/ext/libcouchbase/tests/vbucket/confdata/map_node_present_nodesext_missing_nodes.json +94 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +15 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +11 -6
- data/ext/libcouchbase/tools/cbc-handlers.h +9 -0
- data/ext/libcouchbase/tools/cbc-proxy.cc +1 -1
- data/ext/libcouchbase/tools/cbc.cc +33 -5
- data/ext/libcouchbase/tools/common/options.cc +1 -1
- data/ext/libcouchbase/tools/extract-packets.rb +110 -0
- data/lib/libcouchbase/connection.rb +13 -5
- data/lib/libcouchbase/ext/tasks.rb +1 -1
- data/lib/libcouchbase/version.rb +1 -1
- metadata +62 -7
|
@@ -57,6 +57,7 @@ typedef struct lcb_http_request_st *lcb_http_request_t;
|
|
|
57
57
|
#include <libcouchbase/auth.h>
|
|
58
58
|
#include <libcouchbase/tracing.h>
|
|
59
59
|
#include <libcouchbase/_cxxwrap.h>
|
|
60
|
+
#include <libcouchbase/cntl.h>
|
|
60
61
|
|
|
61
62
|
#ifdef __cplusplus
|
|
62
63
|
extern "C"{
|
|
@@ -275,7 +276,7 @@ struct lcb_create_st2 { LCB_CREATE_V2_FIELDS };
|
|
|
275
276
|
#endif
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
|
-
* @brief
|
|
279
|
+
* @brief Inner structure V3 for lcb_create().
|
|
279
280
|
*/
|
|
280
281
|
struct lcb_create_st3 {
|
|
281
282
|
const char *connstr; /**< Connection string */
|
|
@@ -296,6 +297,30 @@ struct lcb_create_st3 {
|
|
|
296
297
|
lcb_type_t type;
|
|
297
298
|
};
|
|
298
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @brief Inner structure V4 for lcb_create().
|
|
302
|
+
*
|
|
303
|
+
* Same as V3, but allows to supply logger (@see LCB_CNTL_LOGGER).
|
|
304
|
+
*/
|
|
305
|
+
struct lcb_create_st4 {
|
|
306
|
+
const char *connstr; /**< Connection string */
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Username to use for authentication. This should only be set when
|
|
310
|
+
* connecting to a server 5.0 or greater.
|
|
311
|
+
*/
|
|
312
|
+
const char *username;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Password for bucket. Can also be password for username on servers >= 5.0
|
|
316
|
+
*/
|
|
317
|
+
const char *passwd;
|
|
318
|
+
|
|
319
|
+
lcb_logprocs *logger; /**< Logger */
|
|
320
|
+
struct lcb_io_opt_st *io; /**< IO Options */
|
|
321
|
+
lcb_type_t type;
|
|
322
|
+
};
|
|
323
|
+
|
|
299
324
|
/**
|
|
300
325
|
* @brief Wrapper structure for lcb_create()
|
|
301
326
|
* @see lcb_create_st3
|
|
@@ -311,6 +336,7 @@ struct lcb_create_st {
|
|
|
311
336
|
struct lcb_create_st1 v1;
|
|
312
337
|
struct lcb_create_st2 v2;
|
|
313
338
|
struct lcb_create_st3 v3; /**< Use this field */
|
|
339
|
+
struct lcb_create_st4 v4;
|
|
314
340
|
} v;
|
|
315
341
|
LCB_DEPR_CTORS_CRST
|
|
316
342
|
};
|
|
@@ -2396,7 +2422,7 @@ typedef lcb_CMDBASE lcb_CMDNOOP;
|
|
|
2396
2422
|
typedef lcb_RESPSERVERBASE lcb_RESPNOOP;
|
|
2397
2423
|
|
|
2398
2424
|
/**
|
|
2399
|
-
* @
|
|
2425
|
+
* @committed
|
|
2400
2426
|
*
|
|
2401
2427
|
* Send NOOP to the node
|
|
2402
2428
|
*
|
|
@@ -2439,6 +2465,11 @@ lcb_noop3(lcb_t instance, const void *cookie, const lcb_CMDNOOP *cmd);
|
|
|
2439
2465
|
*/
|
|
2440
2466
|
#define LCB_PINGSVC_F_FTS 0x08
|
|
2441
2467
|
|
|
2468
|
+
/**
|
|
2469
|
+
* Ping Analytics for N1QL service. Used in lcb_CMDPING#services
|
|
2470
|
+
*/
|
|
2471
|
+
#define LCB_PINGSVC_F_ANALYTICS 0x10
|
|
2472
|
+
|
|
2442
2473
|
/**
|
|
2443
2474
|
* Do not record any metrics or status codes from ping responses.
|
|
2444
2475
|
* This might be useful to reduce overhead, when user-space
|
|
@@ -2467,7 +2498,7 @@ lcb_noop3(lcb_t instance, const void *cookie, const lcb_CMDNOOP *cmd);
|
|
|
2467
2498
|
/**
|
|
2468
2499
|
* Structure for PING requests.
|
|
2469
2500
|
*
|
|
2470
|
-
* @
|
|
2501
|
+
* @committed
|
|
2471
2502
|
*/
|
|
2472
2503
|
typedef struct {
|
|
2473
2504
|
LCB_CMD_BASE;
|
|
@@ -2479,7 +2510,7 @@ typedef struct {
|
|
|
2479
2510
|
/**
|
|
2480
2511
|
* Type of the service. This enumeration is used in PING responses.
|
|
2481
2512
|
*
|
|
2482
|
-
* @
|
|
2513
|
+
* @committed
|
|
2483
2514
|
*/
|
|
2484
2515
|
typedef enum {
|
|
2485
2516
|
LCB_PINGSVC_KV = 0,
|
|
@@ -2492,7 +2523,7 @@ typedef enum {
|
|
|
2492
2523
|
/**
|
|
2493
2524
|
* Status of the service
|
|
2494
2525
|
*
|
|
2495
|
-
* @
|
|
2526
|
+
* @committed
|
|
2496
2527
|
*/
|
|
2497
2528
|
typedef enum {
|
|
2498
2529
|
LCB_PINGSTATUS_OK = 0,
|
|
@@ -2505,7 +2536,7 @@ typedef enum {
|
|
|
2505
2536
|
* Entry describing the status of the service in the cluster.
|
|
2506
2537
|
* It is part of lcb_RESPING structure.
|
|
2507
2538
|
*
|
|
2508
|
-
* @
|
|
2539
|
+
* @committed
|
|
2509
2540
|
*/
|
|
2510
2541
|
typedef struct {
|
|
2511
2542
|
lcb_PINGSVCTYPE type; /**< type of the service */
|
|
@@ -2522,7 +2553,7 @@ typedef struct {
|
|
|
2522
2553
|
/**
|
|
2523
2554
|
* Structure for PING responses.
|
|
2524
2555
|
*
|
|
2525
|
-
* @
|
|
2556
|
+
* @committed
|
|
2526
2557
|
*/
|
|
2527
2558
|
typedef struct {
|
|
2528
2559
|
LCB_RESP_BASE
|
|
@@ -2536,7 +2567,7 @@ typedef struct {
|
|
|
2536
2567
|
/**
|
|
2537
2568
|
* @brief Check connections by sending NOOP-like messages to all services.
|
|
2538
2569
|
*
|
|
2539
|
-
* @
|
|
2570
|
+
* @committed
|
|
2540
2571
|
*
|
|
2541
2572
|
* When no metrics, required, it is possible to reduce memory overhead
|
|
2542
2573
|
* by turning off response contents using #LCB_PINGOPT_F_NOMETRICS.
|
|
@@ -2590,7 +2621,7 @@ typedef struct {
|
|
|
2590
2621
|
/**
|
|
2591
2622
|
* @brief Returns diagnostics report about network connections.
|
|
2592
2623
|
*
|
|
2593
|
-
* @
|
|
2624
|
+
* @committed
|
|
2594
2625
|
*
|
|
2595
2626
|
* @par Request
|
|
2596
2627
|
* @code{.c}
|
|
@@ -2669,6 +2700,13 @@ typedef enum {
|
|
|
2669
2700
|
/** Execute an Analytics Query */
|
|
2670
2701
|
LCB_HTTP_TYPE_CBAS = 5,
|
|
2671
2702
|
|
|
2703
|
+
/**
|
|
2704
|
+
* Special pseudo-type, for ping endpoints in various services.
|
|
2705
|
+
* Behaves like RAW (the lcb_ping3() function will setup custom path),
|
|
2706
|
+
* but supports Keep-Alive
|
|
2707
|
+
*/
|
|
2708
|
+
LCB_HTTP_TYPE_PING = 6,
|
|
2709
|
+
|
|
2672
2710
|
LCB_HTTP_TYPE_MAX
|
|
2673
2711
|
} lcb_http_type_t;
|
|
2674
2712
|
|
|
@@ -4046,7 +4084,6 @@ int lcb_is_redacting_logs(lcb_t instance);
|
|
|
4046
4084
|
}
|
|
4047
4085
|
#endif /* __cplusplus */
|
|
4048
4086
|
#include <libcouchbase/subdoc.h>
|
|
4049
|
-
#include <libcouchbase/cntl.h>
|
|
4050
4087
|
#include <libcouchbase/deprecated.h>
|
|
4051
4088
|
#include <libcouchbase/api-legacy.h>
|
|
4052
4089
|
#endif /* LIBCOUCHBASE_COUCHBASE_H */
|
|
@@ -29,110 +29,276 @@
|
|
|
29
29
|
extern "C" {
|
|
30
30
|
#endif
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @ingroup lcb-public-api
|
|
34
|
+
* @defgroup lcb-crypto-api Encryption
|
|
35
|
+
* @brief Register crypto-providers and working with encrypted fields of the documents.
|
|
36
|
+
* @details
|
|
37
|
+
* These routines contain functionality to define and hook crypto providers, as well as
|
|
38
|
+
* functions which should be used for portable (cross SDK) encoding of encrypted fields.
|
|
39
|
+
*/
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @addtogroup lcb-crypto-api
|
|
43
|
+
* @{
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* IOV-style structure for signing functions of crypto-provider.
|
|
48
|
+
*
|
|
49
|
+
* @committed
|
|
50
|
+
*/
|
|
40
51
|
typedef struct lcbcrypto_SIGV {
|
|
41
|
-
const uint8_t *data;
|
|
42
|
-
size_t len;
|
|
52
|
+
const uint8_t *data; /**< pointer to data */
|
|
53
|
+
size_t len; /**< length of the data in bytes */
|
|
43
54
|
} lcbcrypto_SIGV;
|
|
44
55
|
|
|
45
56
|
struct lcbcrypto_PROVIDER;
|
|
57
|
+
/**
|
|
58
|
+
* Crypto-provider interface.
|
|
59
|
+
*
|
|
60
|
+
* See full example in @ref example/crypto/openssl_symmetric_provider.c
|
|
61
|
+
*
|
|
62
|
+
* @see lcbcrypto_register
|
|
63
|
+
* @see lcbcrypto_unregister
|
|
64
|
+
*
|
|
65
|
+
* @committed
|
|
66
|
+
*/
|
|
46
67
|
typedef struct lcbcrypto_PROVIDER {
|
|
47
|
-
uint16_t version;
|
|
48
|
-
int16_t _refcnt;
|
|
49
|
-
uint64_t flags;
|
|
50
|
-
void *cookie;
|
|
51
|
-
void (*destructor)(struct lcbcrypto_PROVIDER *provider);
|
|
68
|
+
uint16_t version; /**< version of the structure, current value is 1 */
|
|
69
|
+
int16_t _refcnt; /**< reference counter */
|
|
70
|
+
uint64_t flags; /**< provider-specific flags */
|
|
71
|
+
void *cookie; /**< opaque pointer (e.g. pointer to wrapper instance) */
|
|
72
|
+
void (*destructor)(struct lcbcrypto_PROVIDER *provider); /**< destructor function, or NULL */
|
|
52
73
|
union {
|
|
74
|
+
LCB_DEPRECATED2(
|
|
75
|
+
struct {
|
|
76
|
+
void (*release_bytes)(struct lcbcrypto_PROVIDER * provider, void *bytes);
|
|
77
|
+
lcb_error_t (*load_key)(struct lcbcrypto_PROVIDER * provider, lcbcrypto_KEYTYPE type, const char *keyid,
|
|
78
|
+
uint8_t **key, size_t *key_len);
|
|
79
|
+
lcb_error_t (*generate_iv)(struct lcbcrypto_PROVIDER * provider, uint8_t * *iv, size_t * iv_len);
|
|
80
|
+
lcb_error_t (*sign)(struct lcbcrypto_PROVIDER * provider, const lcbcrypto_SIGV *inputs,
|
|
81
|
+
size_t input_num, uint8_t **sig, size_t *sig_len);
|
|
82
|
+
lcb_error_t (*verify_signature)(struct lcbcrypto_PROVIDER * provider, const lcbcrypto_SIGV *inputs,
|
|
83
|
+
size_t input_num, uint8_t *sig, size_t sig_len);
|
|
84
|
+
lcb_error_t (*encrypt)(struct lcbcrypto_PROVIDER * provider, const uint8_t *input, size_t input_len,
|
|
85
|
+
const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len,
|
|
86
|
+
uint8_t **output, size_t *output_len);
|
|
87
|
+
lcb_error_t (*decrypt)(struct lcbcrypto_PROVIDER * provider, const uint8_t *input, size_t input_len,
|
|
88
|
+
const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len,
|
|
89
|
+
uint8_t **output, size_t *output_len);
|
|
90
|
+
} v0,
|
|
91
|
+
"v0 crypto API has been deprecated, use v1");
|
|
53
92
|
struct {
|
|
93
|
+
/** function to use when the library wants to deallocate memory, returned by provider */
|
|
54
94
|
void (*release_bytes)(struct lcbcrypto_PROVIDER *provider, void *bytes);
|
|
55
|
-
|
|
56
|
-
uint8_t **key, size_t *key_len);
|
|
95
|
+
/** initialization vector (IV) generator */
|
|
57
96
|
lcb_error_t (*generate_iv)(struct lcbcrypto_PROVIDER *provider, uint8_t **iv, size_t *iv_len);
|
|
97
|
+
/** generate cryptographic signature for the data */
|
|
58
98
|
lcb_error_t (*sign)(struct lcbcrypto_PROVIDER *provider, const lcbcrypto_SIGV *inputs, size_t input_num,
|
|
59
99
|
uint8_t **sig, size_t *sig_len);
|
|
100
|
+
/** verify signature of the data */
|
|
60
101
|
lcb_error_t (*verify_signature)(struct lcbcrypto_PROVIDER *provider, const lcbcrypto_SIGV *inputs,
|
|
61
102
|
size_t input_num, uint8_t *sig, size_t sig_len);
|
|
103
|
+
/** encrypt data */
|
|
62
104
|
lcb_error_t (*encrypt)(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
|
|
63
|
-
const uint8_t *
|
|
64
|
-
|
|
105
|
+
const uint8_t *iv, size_t iv_len, uint8_t **output, size_t *output_len);
|
|
106
|
+
/** decrypt data */
|
|
65
107
|
lcb_error_t (*decrypt)(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
|
|
66
|
-
const uint8_t *
|
|
67
|
-
|
|
68
|
-
|
|
108
|
+
const uint8_t *iv, size_t iv_len, uint8_t **output, size_t *output_len);
|
|
109
|
+
/** returns key identifier, associated with the crypto-provider */
|
|
110
|
+
const char *(*get_key_id)(struct lcbcrypto_PROVIDER *provider);
|
|
111
|
+
} v1;
|
|
69
112
|
} v;
|
|
70
113
|
} lcbcrypto_PROVIDER;
|
|
71
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Structure for JSON field specification for encrypt/decrypt API.
|
|
117
|
+
*
|
|
118
|
+
* @see lcbcrypto_encrypt_fields
|
|
119
|
+
* @see lcbcrypto_decrypt_fields
|
|
120
|
+
*
|
|
121
|
+
* @committed
|
|
122
|
+
*/
|
|
72
123
|
typedef struct lcbcrypto_FIELDSPEC {
|
|
73
|
-
const char *name;
|
|
74
|
-
const char *alg;
|
|
75
|
-
const char *kid
|
|
124
|
+
const char *name; /**< field name (NUL-terminated) */
|
|
125
|
+
const char *alg; /**< crypto provider alias (NUL-terminated) */
|
|
126
|
+
LCB_DEPRECATED2(const char *kid,
|
|
127
|
+
"Do not use kid field. Encryption keys have to be part of the provider implementation");
|
|
76
128
|
} lcbcrypto_FIELDSPEC;
|
|
77
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Command to encrypt JSON fields.
|
|
132
|
+
*
|
|
133
|
+
* @see lcbcrypto_encrypt_fields
|
|
134
|
+
* @committed
|
|
135
|
+
*/
|
|
78
136
|
typedef struct lcbcrypto_CMDENCRYPT {
|
|
79
|
-
uint16_t version;
|
|
80
|
-
const char *prefix;
|
|
81
|
-
const char *doc;
|
|
82
|
-
size_t ndoc;
|
|
83
|
-
char *out;
|
|
84
|
-
size_t nout;
|
|
85
|
-
lcbcrypto_FIELDSPEC *fields;
|
|
86
|
-
size_t nfields;
|
|
137
|
+
uint16_t version; /**< version of the structure, currently valid value is 0 */
|
|
138
|
+
const char *prefix; /**< prefix to encrypted field. When NULL, it will use @ref LCBCRYPTO_DEFAULT_FIELD_PREFIX */
|
|
139
|
+
const char *doc; /**< pointer to the input JSON document */
|
|
140
|
+
size_t ndoc; /**< size of the input JSON document */
|
|
141
|
+
char *out; /**< pointer to output JSON document. When no changes were applied, this field will be set to NULL */
|
|
142
|
+
size_t nout; /**< size of the output JSON document */
|
|
143
|
+
lcbcrypto_FIELDSPEC *fields; /**< list of field specs */
|
|
144
|
+
size_t nfields; /**< number of field specs */
|
|
87
145
|
} lcbcrypto_CMDENCRYPT;
|
|
88
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Command to decrypt JSON fields.
|
|
149
|
+
*
|
|
150
|
+
* @see lcbcrypto_decrypt_fields
|
|
151
|
+
* @committed
|
|
152
|
+
*/
|
|
89
153
|
typedef struct lcbcrypto_CMDDECRYPT {
|
|
90
|
-
uint16_t version;
|
|
91
|
-
const char *prefix;
|
|
92
|
-
const char *doc;
|
|
93
|
-
size_t ndoc;
|
|
94
|
-
char *out;
|
|
95
|
-
size_t nout;
|
|
154
|
+
uint16_t version; /**< version of the structure, currently valid value is 0 */
|
|
155
|
+
const char *prefix; /**< prefix to encrypted field. When NULL, it will use @ref LCBCRYPTO_DEFAULT_FIELD_PREFIX */
|
|
156
|
+
const char *doc; /**< pointer to the input JSON document */
|
|
157
|
+
size_t ndoc; /**< size of the input JSON document */
|
|
158
|
+
char *out; /**< pointer to output JSON document. When no changes were applied, this field will be set to NULL */
|
|
159
|
+
size_t nout; /**< size of the output JSON document */
|
|
160
|
+
lcbcrypto_FIELDSPEC *fields; /**< list of field specs */
|
|
161
|
+
size_t nfields; /**< number of field specs */
|
|
96
162
|
} lcbcrypto_CMDDECRYPT;
|
|
97
163
|
|
|
98
164
|
/**
|
|
99
|
-
*
|
|
165
|
+
* Register crypto-provider for specified alias.
|
|
166
|
+
*
|
|
167
|
+
* See full example in @ref example/crypto/openssl_symmetric_provider.c
|
|
168
|
+
*
|
|
169
|
+
* @param instance the handle
|
|
170
|
+
* @param name provider alias, this will be recorded in JSON.
|
|
171
|
+
* @param provider implementation of the crypto-provider
|
|
172
|
+
*
|
|
173
|
+
* @par Register provider as "AES-256-HMAC-SHA256".
|
|
174
|
+
* @code{.c}
|
|
175
|
+
* lcbcrypto_PROVIDER *provider = calloc(1, sizeof(lcbcrypto_PROVIDER));
|
|
176
|
+
* provider->version = 1;
|
|
177
|
+
* provider->destructor = osp_free;
|
|
178
|
+
* provider->v.v1.release_bytes = osp_release_bytes;
|
|
179
|
+
* provider->v.v1.generate_iv = osp_generate_iv;
|
|
180
|
+
* provider->v.v1.sign = osp_sign;
|
|
181
|
+
* provider->v.v1.verify_signature = osp_verify_signature;
|
|
182
|
+
* provider->v.v1.encrypt = osp_encrypt;
|
|
183
|
+
* provider->v.v1.decrypt = osp_decrypt;
|
|
184
|
+
* provider->v.v1.get_key_id = osp_get_key_id;
|
|
185
|
+
* lcbcrypto_register(instance, "AES-256-HMAC-SHA256", provider);
|
|
186
|
+
* @endcode
|
|
100
187
|
*/
|
|
101
188
|
LIBCOUCHBASE_API void lcbcrypto_register(lcb_t instance, const char *name, lcbcrypto_PROVIDER *provider);
|
|
102
189
|
|
|
103
190
|
/**
|
|
104
|
-
*
|
|
191
|
+
* Unregister crypto-provider for specified alias.
|
|
192
|
+
*
|
|
193
|
+
* See full example in @ref example/crypto/openssl_symmetric_provider.c
|
|
194
|
+
*
|
|
195
|
+
* @param instance the handle
|
|
196
|
+
* @param name provider alias.
|
|
105
197
|
*/
|
|
106
198
|
LIBCOUCHBASE_API void lcbcrypto_unregister(lcb_t instance, const char *name);
|
|
107
199
|
|
|
108
200
|
/**
|
|
109
|
-
*
|
|
201
|
+
* Increment reference counter for crypto-provider.
|
|
202
|
+
*
|
|
203
|
+
* @param provider provider instance
|
|
110
204
|
*/
|
|
111
205
|
LIBCOUCHBASE_API void lcbcrypto_ref(lcbcrypto_PROVIDER *provider);
|
|
112
206
|
|
|
113
207
|
/**
|
|
114
|
-
*
|
|
208
|
+
* Decrement reference counter for crypto-provider.
|
|
209
|
+
*
|
|
210
|
+
* It calls destructor once counter reaches zero. The provider instance should not be used after calling this function.
|
|
211
|
+
*
|
|
212
|
+
* @param provider provider instance
|
|
115
213
|
*/
|
|
116
214
|
LIBCOUCHBASE_API void lcbcrypto_unref(lcbcrypto_PROVIDER *provider);
|
|
117
215
|
|
|
118
216
|
/**
|
|
119
|
-
*
|
|
217
|
+
* Default prefix for encrypted JSON fields.
|
|
218
|
+
*/
|
|
219
|
+
#define LCBCRYPTO_DEFAULT_FIELD_PREFIX "__crypt_"
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Encrypt all specified fields in the JSON encoded object.
|
|
120
223
|
*
|
|
121
|
-
*
|
|
224
|
+
* The function will remove original content of the field, and rename it using @ref LCBCRYPTO_DEFAULT_FIELD_PREFIX, or
|
|
225
|
+
* custom prefix, specified in the command.
|
|
226
|
+
*
|
|
227
|
+
* See full example in @ref example/crypto/openssl_symmetric_encrypt.c
|
|
228
|
+
*
|
|
229
|
+
* @param instance the handle
|
|
230
|
+
* @param cmd the command structure
|
|
231
|
+
* @return LCB_SUCCESS if successful, an error code otherwise
|
|
232
|
+
*
|
|
233
|
+
* @par Encrypt field "message" in the document using provider registered as "AES-256-HMAC-SHA256"
|
|
234
|
+
* @code{.c}
|
|
235
|
+
* lcbcrypto_CMDENCRYPT cmd = {};
|
|
236
|
+
* lcbcrypto_FIELDSPEC field = {};
|
|
237
|
+
* lcb_error_t err;
|
|
238
|
+
*
|
|
239
|
+
* cmd.version = 0;
|
|
240
|
+
* cmd.prefix = NULL;
|
|
241
|
+
* cmd.doc = "{\"message\":\"hello world\"}";
|
|
242
|
+
* cmd.ndoc = strlen(cmd.doc);
|
|
243
|
+
* cmd.nfields = 1;
|
|
244
|
+
* cmd.fields = &field;
|
|
245
|
+
* field.name = "message";
|
|
246
|
+
* field.alg = "AES-256-HMAC-SHA256";
|
|
247
|
+
*
|
|
248
|
+
* err = lcbcrypto_encrypt_fields(instance, &cmd);
|
|
249
|
+
* @endcode
|
|
250
|
+
*
|
|
251
|
+
* @committed
|
|
122
252
|
*/
|
|
123
253
|
LIBCOUCHBASE_API lcb_error_t lcbcrypto_encrypt_fields(lcb_t instance, lcbcrypto_CMDENCRYPT *cmd);
|
|
124
254
|
|
|
125
255
|
/**
|
|
126
|
-
*
|
|
256
|
+
* Decrypt all specified fields in the JSON encoded object.
|
|
257
|
+
*
|
|
258
|
+
* The function will remove original content of the field, and rename it using @ref LCBCRYPTO_DEFAULT_FIELD_PREFIX, or
|
|
259
|
+
* custom prefix, specified in the command.
|
|
260
|
+
*
|
|
261
|
+
* See full example in @ref example/crypto/openssl_symmetric_decrypt.c
|
|
262
|
+
*
|
|
263
|
+
* @param instance the handle
|
|
264
|
+
* @param cmd the command structure
|
|
265
|
+
* @return LCB_SUCCESS if successful, an error code otherwise
|
|
266
|
+
*
|
|
267
|
+
* @par Decrypt field "message" in the document using provider registered as "AES-256-HMAC-SHA256"
|
|
268
|
+
* @code{.c}
|
|
269
|
+
* lcbcrypto_CMDDECRYPT cmd = {};
|
|
270
|
+
* lcbcrypto_FIELDSPEC field = {};
|
|
271
|
+
* lcb_error_t err;
|
|
272
|
+
*
|
|
273
|
+
* cmd.version = 0;
|
|
274
|
+
* cmd.prefix = NULL;
|
|
275
|
+
* cmd.doc = "{\"__crypt_message\":{" \
|
|
276
|
+
* "\"alg\":\"AES-256-HMAC-SHA256\"," \
|
|
277
|
+
* "\"ciphertext\":\"gYuyEhf6S0AiMGZJZZV35Q==\"," \
|
|
278
|
+
* "\"iv\":\"ZedmvjWy0lIrLn6OmQmNqQ==\"," \
|
|
279
|
+
* "\"kid\":\"mykeyid\"," \
|
|
280
|
+
* "\"sig\":\"FgleInW3Iia04XqLbm5Hd3qVoa77Ocs7g2x4pOutEtY=\"}" \
|
|
281
|
+
* "}";
|
|
282
|
+
* cmd.ndoc = strlen(cmd.doc);
|
|
283
|
+
* cmd.nfields = 1;
|
|
284
|
+
* cmd.fields = &field;
|
|
285
|
+
* field.name = "message";
|
|
286
|
+
* field.alg = "AES-256-HMAC-SHA256";
|
|
287
|
+
*
|
|
288
|
+
* err = lcbcrypto_decrypt_fields(instance, &cmd);
|
|
289
|
+
* @endcode
|
|
127
290
|
*
|
|
128
|
-
*
|
|
291
|
+
* @committed
|
|
129
292
|
*/
|
|
130
293
|
LIBCOUCHBASE_API lcb_error_t lcbcrypto_decrypt_fields(lcb_t instance, lcbcrypto_CMDDECRYPT *cmd);
|
|
294
|
+
/**@}*/
|
|
131
295
|
|
|
132
296
|
/** @deprecated Use @ref lcbcrypto_encrypt_fields() */
|
|
133
|
-
LCB_DEPR_API2(lcb_error_t lcbcrypto_encrypt_document(lcb_t instance, lcbcrypto_CMDENCRYPT *cmd),
|
|
297
|
+
LCB_DEPR_API2(lcb_error_t lcbcrypto_encrypt_document(lcb_t instance, lcbcrypto_CMDENCRYPT *cmd),
|
|
298
|
+
"Use lcbcrypto_encrypt_fields");
|
|
134
299
|
/** @deprecated Use @ref lcbcrypto_decrypt_fields() */
|
|
135
|
-
LCB_DEPR_API2(lcb_error_t lcbcrypto_decrypt_document(lcb_t instance, lcbcrypto_CMDDECRYPT *cmd),
|
|
300
|
+
LCB_DEPR_API2(lcb_error_t lcbcrypto_decrypt_document(lcb_t instance, lcbcrypto_CMDDECRYPT *cmd),
|
|
301
|
+
"Use lcbcrypto_decrypt_fields");
|
|
136
302
|
|
|
137
303
|
#ifdef __cplusplus
|
|
138
304
|
}
|