Pauli 46a9cc9451 Fix NITs in comments and CHANGES for DEVRANDOM seeded check. 4 years ago
..
aes c2969ff6e7 Fix Typos 4 years ago
aria dd6b270618 Remove tab characters from C source files. 4 years ago
asn1 48102247ff Add missing EBCDIC strings 4 years ago
async cbfa5b0398 Regenerate mkerr files 4 years ago
bf 053d0b2226 Move bf_asm_src file information to build.info files 4 years ago
bio 91cb81d40a BIO_lookup_ex: Do not retry on EAI_MEMORY 4 years ago
blake2 55a0a117e7 Move BLAKE2 MACs to the providers 4 years ago
bn 00372d7551 crypto/bn/build.info: define OPENSL_IA32_SSE2 globally when needed 4 years ago
buffer a9612d6c03 Make the EC code available from inside the FIPS provider 4 years ago
camellia 94707b0b68 Move cmll_asm_src file information to build.info files 4 years ago
cast e698cfe445 Move cast_asm_src file information to build.info files 4 years ago
chacha bcb7afe18a Move chacha_asm_src file information to build.info files 4 years ago
cmac d5f8542913 Coverty fixes for MACs 4 years ago
cmp cbfa5b0398 Regenerate mkerr files 4 years ago
cms 8c00f267b8 CAdES : lowercase name for now internal methods. 4 years ago
comp cbfa5b0398 Regenerate mkerr files 4 years ago
conf ff988500c2 Replace FUNCerr with ERR_raise_data 4 years ago
crmf 703170d4b9 Get rid of the diversity of names for MAC parameters 4 years ago
ct cbfa5b0398 Regenerate mkerr files 4 years ago
des 4a42e26404 Cleanup ciphers and Add 3des ciphers. 4 years ago
dh 6de1fe9086 Enforce a minimum DH modulus size of 512 bits 4 years ago
dsa 7408f6759f make RSA and DSA operations throw MISSING_PRIVATE_KEY if needed, adapt ECDSA 4 years ago
dso 38f6f99cdf Cygwin: enable the use of Dl_info and dladdr() 4 years ago
ec 653b883b97 Fix 9bf682f which broke nistp224_method 4 years ago
engine 9f643f5423 crypto/engine/eng_openssl.c: define TEST_ENG_OPENSSL_RC4_P_INIT conditionally 4 years ago
err 51fe9b00d2 fix ERR_add_error_vdata() for use with multiple args/calls 4 years ago
ess cbfa5b0398 Regenerate mkerr files 4 years ago
evp 9a7846dfe5 Use ENGINE_get_id() instead of ENGINE_get_name() 4 years ago
hmac 5183ebdcf5 Move HMAC to providers 4 years ago
idea aa2d9a76b4 Following the license change, modify the boilerplates in crypto/idea/ 5 years ago
include 4a42e26404 Cleanup ciphers and Add 3des ciphers. 4 years ago
kdf 703170d4b9 Get rid of the diversity of names for MAC parameters 4 years ago
lhash c2969ff6e7 Fix Typos 4 years ago
md2 4911f55362 Following the license change, modify the boilerplates in crypto/mdN/ 5 years ago
md4 4911f55362 Following the license change, modify the boilerplates in crypto/mdN/ 5 years ago
md5 792ea008af Move md5_asm_src file information to build.info files 4 years ago
mdc2 2bcb0fc862 Following the license change, modify the boilerplates in crypto/mdc2/ 5 years ago
modes 703170d4b9 Get rid of the diversity of names for MAC parameters 4 years ago
objects 29dc6e00f2 Load the config file by default 4 years ago
ocsp cbfa5b0398 Regenerate mkerr files 4 years ago
pem 724339ff44 Fix SCA vulnerability when using PVK and MSBLOB key formats 4 years ago
perlasm 3062468b0a s390x assembly pack: update perlasm module 5 years ago
pkcs12 cbfa5b0398 Regenerate mkerr files 4 years ago
pkcs7 cbfa5b0398 Regenerate mkerr files 4 years ago
poly1305 ae0b6b9203 Move Poly1305 to providers 4 years ago
property 505f466020 Make sure we pre-initialise properties 4 years ago
rand 46a9cc9451 Fix NITs in comments and CHANGES for DEVRANDOM seeded check. 4 years ago
rc2 5e4435a760 Following the license change, modify the boilerplates in crypto/rcN/ 5 years ago
rc4 6b90902faf Move rc4_asm_src file information to build.info files 4 years ago
rc5 9a131ad747 Change RC5_32_set_key to return an int type 4 years ago
ripemd 2ffea44322 Move rmd160_asm_src file information to build.info files 4 years ago
rsa 9bcc9f973b Ensure RSA PSS correctly returns the right default digest 4 years ago
seed 39c44eee7f Following the license change, modify the boilerplates in crypto/seed/ 5 years ago
sha a890ef833d Directly return from final sha3/keccak_final if no bytes are requested 4 years ago
siphash 4657693d9e Move SipHash to providers 4 years ago
sm2 a45eb7e891 Support parsing of SM2 ID in hexdecimal 4 years ago
sm3 d5e5e2ffaf Move digests to providers 5 years ago
sm4 f9f859adc6 Following the license change, modify the boilerplates in crypto/smN/ 5 years ago
srp df4439186f Remove unnecessary trailing whitespace 5 years ago
stack 3593266d1c Make core code available within the FIPS module 5 years ago
store ff988500c2 Replace FUNCerr with ERR_raise_data 4 years ago
ts cbfa5b0398 Regenerate mkerr files 4 years ago
txt_db 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
ui dd6b270618 Remove tab characters from C source files. 4 years ago
whrlpool 0c789f59f1 Fix warning C4164 in MSVC. 4 years ago
x509 cae665dfa6 Fix error handling in X509_chain_up_ref 4 years ago
LPdir_nyi.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
LPdir_unix.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
LPdir_vms.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
LPdir_win.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
LPdir_win32.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
LPdir_wince.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
README.sparse_array c2969ff6e7 Fix Typos 4 years ago
alphacpuid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
arm64cpuid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
arm_arch.h 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
armcap.c 5f40dd158c crypto/armcap.c, crypto/ppccap.c: stricter use of getauxval() 5 years ago
armv4cpuid.pl 3405db97e5 ARM assembly pack: make it Windows-friendly. 5 years ago
asn1_dsa.c 0d03acea7a remove end of line whitespace 4 years ago
bsearch.c 5c3f1e34b5 ossl_bsearch(): New generic internal binary search utility function 5 years ago
build.info e23cda000e Move KMAC to providers 4 years ago
c64xpluscpuid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
context.c 505f466020 Make sure we pre-initialise properties 4 years ago
core_algorithm.c a883c02faa Add internal function ossl_algorithm_do_all() 4 years ago
core_fetch.c c1d56231ef Modify ossl_method_store_add() to accept an OSSL_PROVIDER and check for it 4 years ago
core_namemap.c a9550b74d3 OSSL_NAMEMAP: make names case insensitive 4 years ago
cpt_err.c 82bd7c2cbd Add OPENSSL_hexstr2buf_ex() and OPENSSL_buf2hexstr_ex() 4 years ago
cryptlib.c dd6b270618 Remove tab characters from C source files. 4 years ago
ctype.c 48102247ff Add missing EBCDIC strings 4 years ago
cversion.c 47ca833835 Add the possibility to display and use MODULESDIR 5 years ago
dllmain.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
ebcdic.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
ex_data.c aee6e29f0e Access data after obtaining the lock not before. 4 years ago
getenv.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
ia64cpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
info.c 096978f099 OPENSSL_info(): add the item OPENSSL_INFO_SEED_SOURCE and use it 4 years ago
init.c cf0932cdd9 prevent endless recursion when trace API is used within OPENSSL_init_crypto() 4 years ago
initthread.c 3b438ef95b Fix init_get_thread_local() 4 years ago
mem.c 9efa0ae0b6 Create a FIPS provider and put SHA256 in it 5 years ago
mem_clr.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
mem_dbg.c decdb980de Fix deprecation inconsisteny w.r.t. CRYPTO_mem_debug_{push,pop}() 4 years ago
mem_sec.c 61783db5b5 Use vxRandLib for VxWorks7 5 years ago
mips_arch.h 1b9c5f2e2f Fix compiling error for mips32r6 and mips64r6 5 years ago
o_dir.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
o_fips.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
o_fopen.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
o_init.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
o_str.c 82bd7c2cbd Add OPENSSL_hexstr2buf_ex() and OPENSSL_buf2hexstr_ex() 4 years ago
o_time.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
packet.c 15cb0f0958 Give WPACKET the ability to have a NULL buffer underneath it 4 years ago
param_build.c d32d304836 Fix ossl_param_bld_push_{utf8,octet}_string() / param_bld_convert() 4 years ago
params.c c04a9916d4 Fix windows compile errors in params.c 4 years ago
params_from_text.c 810a1d0320 OSSL_PARAM_construct_from_text(): handle non-hex octet string input 4 years ago
pariscid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
ppc_arch.h c8f370485c PPC: Try out if mftb works before using it 5 years ago
ppccap.c a9612d6c03 Make the EC code available from inside the FIPS provider 4 years ago
ppccpuid.pl c8f370485c PPC: Try out if mftb works before using it 5 years ago
provider.c dca97d0062 Rename provider and core get_param_types functions 4 years ago
provider_conf.c 29dc6e00f2 Load the config file by default 4 years ago
provider_core.c 25e601445a Add fips provider code for handling self test data 4 years ago
provider_local.h c41f3ae0d9 Replumbing: Add a mechanism to pre-populate the provider store 5 years ago
provider_predefined.c 3593266d1c Make core code available within the FIPS module 5 years ago
s390x_arch.h dd6b270618 Remove tab characters from C source files. 4 years ago
s390xcap.c 5d00f46e15 s390x assembly pack: use getauxval to detect hw capabilities 4 years ago
s390xcpuid.pl 9baa4d5f4c s390xcpuid.pl: fix comment 4 years ago
sparc_arch.h 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
sparccpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
sparcv9cap.c 41525ed628 Ensure we get all the right defines for AES assembler in FIPS module 5 years ago
sparse_array.c c2969ff6e7 Fix Typos 4 years ago
threads_none.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
threads_pthread.c d6dda392c1 use native atomic increment function on Solaris 4 years ago
threads_win.c 09305a7d0a Avoid linking error for InitializeCriticalSectionAndSpinCount(). 5 years ago
trace.c cf0932cdd9 prevent endless recursion when trace API is used within OPENSSL_init_crypto() 4 years ago
uid.c 6b10d29c1a Remove NextStep support 4 years ago
vms_rms.h 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
x86_64cpuid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago
x86cpuid.pl 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 years ago

README.sparse_array

The sparse_array.c file contains an implementation of a sparse array that
attempts to be both space and time efficient.

The sparse array is represented using a tree structure. Each node in the
tree contains a block of pointers to either the user supplied leaf values or
to another node.

There are a number of parameters used to define the block size:

OPENSSL_SA_BLOCK_BITS Specifies the number of bits covered by each block
SA_BLOCK_MAX Specifies the number of pointers in each block
SA_BLOCK_MASK Specifies a bit mask to perform modulo block size
SA_BLOCK_MAX_LEVELS Indicates the maximum possible height of the tree

These constants are inter-related:
SA_BLOCK_MAX = 2 ^ OPENSSL_SA_BLOCK_BITS
SA_BLOCK_MASK = SA_BLOCK_MAX - 1
SA_BLOCK_MAX_LEVELS = number of bits in size_t divided by
OPENSSL_SA_BLOCK_BITS rounded up to the next multiple
of OPENSSL_SA_BLOCK_BITS

OPENSSL_SA_BLOCK_BITS can be defined at compile time and this overrides the
built in setting.

As a space and performance optimisation, the height of the tree is usually
less than the maximum possible height. Only sufficient height is allocated to
accommodate the largest index added to the data structure.

The largest index used to add a value to the array determines the tree height:

+----------------------+---------------------+
| Largest Added Index | Height of Tree |
+----------------------+---------------------+
| SA_BLOCK_MAX - 1 | 1 |
| SA_BLOCK_MAX ^ 2 - 1 | 2 |
| SA_BLOCK_MAX ^ 3 - 1 | 3 |
| ... | ... |
| size_t max | SA_BLOCK_MAX_LEVELS |
+----------------------+---------------------+

The tree height is dynamically increased as needed based on additions.

An empty tree is represented by a NULL root pointer. Inserting a value at
index 0 results in the allocation of a top level node full of null pointers
except for the single pointer to the user's data (N = SA_BLOCK_MAX for
brevity):

+----+
|Root|
|Node|
+-+--+
|
|
|
v
+-+-+---+---+---+---+
| 0 | 1 | 2 |...|N-1|
| |nil|nil|...|nil|
+-+-+---+---+---+---+
|
|
|
v
+-+--+
|User|
|Data|
+----+
Index 0


Inserting at element 2N+1 creates a new root node and pushes down the old root
node. It then creates a second second level node to hold the pointer to the
user's new data:

+----+
|Root|
|Node|
+-+--+
|
|
|
v
+-+-+---+---+---+---+
| 0 | 1 | 2 |...|N-1|
| |nil| |...|nil|
+-+-+---+-+-+---+---+
| |
| +------------------+
| |
v v
+-+-+---+---+---+---+ +-+-+---+---+---+---+
| 0 | 1 | 2 |...|N-1| | 0 | 1 | 2 |...|N-1|
|nil| |nil|...|nil| |nil| |nil|...|nil|
+-+-+---+---+---+---+ +---+-+-+---+---+---+
| |
| |
| |
v v
+-+--+ +-+--+
|User| |User|
|Data| |Data|
+----+ +----+
Index 0 Index 2N+1


The nodes themselves are allocated in a sparse manner. Only nodes which exist
along a path from the root of the tree to an added leaf will be allocated.
The complexity is hidden and nodes are allocated on an as needed basis.
Because the data is expected to be sparse this doesn't result in a large waste
of space.

Values can be removed from the sparse array by setting their index position to
NULL. The data structure does not attempt to reclaim nodes or reduce the
height of the tree on removal. For example, now setting index 0 to NULL would
result in:

+----+
|Root|
|Node|
+-+--+
|
|
|
v
+-+-+---+---+---+---+
| 0 | 1 | 2 |...|N-1|
| |nil| |...|nil|
+-+-+---+-+-+---+---+
| |
| +------------------+
| |
v v
+-+-+---+---+---+---+ +-+-+---+---+---+---+
| 0 | 1 | 2 |...|N-1| | 0 | 1 | 2 |...|N-1|
|nil|nil|nil|...|nil| |nil| |nil|...|nil|
+---+---+---+---+---+ +---+-+-+---+---+---+
|
|
|
v
+-+--+
|User|
|Data|
+----+
Index 2N+1


Accesses to elements in the sparse array take O(log n) time where n is the
largest element. The base of the logarithm is SA_BLOCK_MAX, so for moderately
small indices (e.g. NIDs), single level (constant time) access is achievable.
Space usage is O(minimum(m, n log(n)) where m is the number of elements in the
array.

Note: sparse arrays only include pointers to types. Thus, SPARSE_ARRAY_OF(char)
can be used to store a string.