1 /* 2 * Copyright (C) 2020-2021 Bareos GmbH & Co. KG 3 * Copyright (C) 2010 SCALITY SA. All rights reserved. 4 * http://www.scality.com 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY SCALITY SA ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL SCALITY SA OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * The views and conclusions contained in the software and documentation 30 * are those of the authors and should not be interpreted as representing 31 * official policies, either expressed or implied, of SCALITY SA. 32 * 33 * https://github.com/scality/Droplet 34 */ 35 #ifndef BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_UKS_UKS_H_ 36 #define BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_UKS_UKS_H_ 37 38 #define DPL_UKS_CLASS_NBITS 4 39 #define DPL_UKS_REPLICA_NBITS 4 40 #define DPL_UKS_EXTRA_NBITS (DPL_UKS_CLASS_NBITS + DPL_UKS_REPLICA_NBITS) 41 42 #define DPL_UKS_SPECIFIC_NBITS 24 43 #define DPL_UKS_SERVICEID_NBITS 8 44 #define DPL_UKS_VOLID_NBITS 32 45 #define DPL_UKS_OID_NBITS 64 46 #define DPL_UKS_HASH_NBITS 24 /*!< dispersion */ 47 48 #define DPL_UKS_PAYLOAD_NBITS \ 49 (DPL_UKS_SPECIFIC_NBITS + DPL_UKS_SERVICEID_NBITS + DPL_UKS_VOLID_NBITS \ 50 + DPL_UKS_OID_NBITS) 51 52 #define DPL_UKS_NBITS 160 53 #define DPL_UKS_BCH_LEN 40 54 55 typedef enum 56 { 57 DPL_UKS_MASK_OID = (1u << 0), 58 DPL_UKS_MASK_VOLID = (1u << 1), 59 DPL_UKS_MASK_SERVICEID = (1u << 2), 60 DPL_UKS_MASK_SPECIFIC = (1u << 3), 61 } dpl_uks_mask_t; 62 63 dpl_status_t dpl_uks_gen_key_raw(BIGNUM* id, 64 uint32_t hash, 65 uint64_t oid, 66 uint32_t volid, 67 uint8_t serviceid, 68 uint32_t specific); 69 dpl_status_t dpl_uks_gen_key_ext(BIGNUM* id, 70 dpl_uks_mask_t mask, 71 uint64_t oid, 72 uint32_t volid, 73 uint8_t serviceid, 74 uint32_t specific); 75 dpl_status_t dpl_uks_gen_key(BIGNUM* id, 76 uint64_t oid, 77 uint32_t volid, 78 uint8_t serviceid, 79 uint32_t specific); 80 uint32_t dpl_uks_hash_get(BIGNUM* k); 81 dpl_status_t dpl_uks_hash_set(BIGNUM* k, uint32_t hash); 82 dpl_status_t dpl_uks_set_class(BIGNUM* k, int cl); 83 dpl_status_t dpl_uks_set_replica(BIGNUM* k, int replica); 84 dpl_status_t dpl_uks_bn2hex(const BIGNUM* id, char* id_str); 85 86 extern dpl_id_scheme_t dpl_id_scheme_uks; 87 88 #endif // BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_UKS_UKS_H_ 89