/src/openssl30/crypto/property/property_query.c
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | /* | 
| 2 |  |  * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. | 
| 3 |  |  * | 
| 4 |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
| 5 |  |  * this file except in compliance with the License.  You can obtain a copy | 
| 6 |  |  * in the file LICENSE in the source distribution or at | 
| 7 |  |  * https://www.openssl.org/source/license.html | 
| 8 |  |  */ | 
| 9 |  |  | 
| 10 |  | #include "internal/propertyerr.h" | 
| 11 |  | #include "internal/property.h" | 
| 12 |  | #include "property_local.h" | 
| 13 |  |  | 
| 14 |  | static int property_idx_cmp(const void *keyp, const void *compare) | 
| 15 | 12.1M | { | 
| 16 | 12.1M |     OSSL_PROPERTY_IDX key = *(const OSSL_PROPERTY_IDX *)keyp; | 
| 17 | 12.1M |     const OSSL_PROPERTY_DEFINITION *defn = | 
| 18 | 12.1M |             (const OSSL_PROPERTY_DEFINITION *)compare; | 
| 19 |  |  | 
| 20 | 12.1M |     return key - defn->name_idx; | 
| 21 | 12.1M | } | 
| 22 |  |  | 
| 23 |  | const OSSL_PROPERTY_DEFINITION * | 
| 24 |  | ossl_property_find_property(const OSSL_PROPERTY_LIST *list, | 
| 25 |  |                             OSSL_LIB_CTX *libctx, const char *name) | 
| 26 | 6.94M | { | 
| 27 | 6.94M |     OSSL_PROPERTY_IDX name_idx; | 
| 28 |  |  | 
| 29 | 6.94M |     if (list == NULL || name == NULL | 
| 30 | 6.94M |         || (name_idx = ossl_property_name(libctx, name, 0)) == 0) | 
| 31 | 0 |         return NULL; | 
| 32 |  |  | 
| 33 | 6.94M |     return ossl_bsearch(&name_idx, list->properties, list->num_properties, | 
| 34 | 6.94M |                         sizeof(*list->properties), &property_idx_cmp, 0); | 
| 35 | 6.94M | } | 
| 36 |  |  | 
| 37 |  | OSSL_PROPERTY_TYPE ossl_property_get_type(const OSSL_PROPERTY_DEFINITION *prop) | 
| 38 | 0 | { | 
| 39 | 0 |     return prop->type; | 
| 40 | 0 | } | 
| 41 |  |  | 
| 42 |  | const char *ossl_property_get_string_value(OSSL_LIB_CTX *libctx, | 
| 43 |  |                                            const OSSL_PROPERTY_DEFINITION *prop) | 
| 44 | 5.25M | { | 
| 45 | 5.25M |     const char *value = NULL; | 
| 46 |  |  | 
| 47 | 5.25M |     if (prop != NULL && prop->type == OSSL_PROPERTY_TYPE_STRING) | 
| 48 | 5.25M |         value = ossl_property_value_str(libctx, prop->v.str_val); | 
| 49 | 5.25M |     return value; | 
| 50 | 5.25M | } | 
| 51 |  |  | 
| 52 |  | int64_t ossl_property_get_number_value(const OSSL_PROPERTY_DEFINITION *prop) | 
| 53 | 0 | { | 
| 54 | 0 |     int64_t value = 0; | 
| 55 |  | 
 | 
| 56 | 0 |     if (prop != NULL && prop->type == OSSL_PROPERTY_TYPE_NUMBER) | 
| 57 | 0 |         value = prop->v.int_val; | 
| 58 | 0 |     return value; | 
| 59 | 0 | } | 
| 60 |  |  | 
| 61 |  | /* Does a property query have any optional clauses */ | 
| 62 |  | int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query) | 
| 63 | 289 | { | 
| 64 | 289 |     return query->has_optional ? 1 : 0; | 
| 65 | 289 | } | 
| 66 |  |  | 
| 67 |  | int ossl_property_is_enabled(OSSL_LIB_CTX *ctx,  const char *property_name, | 
| 68 |  |                              const OSSL_PROPERTY_LIST *prop_list) | 
| 69 | 0 | { | 
| 70 | 0 |     const OSSL_PROPERTY_DEFINITION *prop; | 
| 71 |  | 
 | 
| 72 | 0 |     prop = ossl_property_find_property(prop_list, ctx, property_name); | 
| 73 |  |     /* Do a separate check for override as it does not set type */ | 
| 74 | 0 |     if (prop == NULL || prop->optional || prop->oper == OSSL_PROPERTY_OVERRIDE) | 
| 75 | 0 |         return 0; | 
| 76 | 0 |     return (prop->type == OSSL_PROPERTY_TYPE_STRING | 
| 77 | 0 |             && ((prop->oper == OSSL_PROPERTY_OPER_EQ | 
| 78 | 0 |                      && prop->v.str_val == OSSL_PROPERTY_TRUE) | 
| 79 | 0 |                  || (prop->oper == OSSL_PROPERTY_OPER_NE | 
| 80 | 0 |                      && prop->v.str_val != OSSL_PROPERTY_TRUE))); | 
| 81 | 0 | } | 
| 82 |  |  |