A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Matt Caswell 7eeceeaab2 Avoid passing NULL to memcpy 3 years ago
..
aes Fix Typos 3 years ago
aria Remove tab characters from C source files. 3 years ago
asn1 [crypto/asn1] Fix multiple SCA vulnerabilities during RSA key validation. 3 years ago
async Regenerate mkerr files 3 years ago
bf Move bf_asm_src file information to build.info files 3 years ago
bio BIO_lookup_ex: Do not retry on EAI_MEMORY 3 years ago
blake2 Move BLAKE2 MACs to the providers 3 years ago
bn Uniform BN_bn2binpad() and BN_bn2lebinpad() implementations 3 years ago
buffer Make the EC code available from inside the FIPS provider 3 years ago
camellia Move cmll_asm_src file information to build.info files 3 years ago
cast Move cast_asm_src file information to build.info files 3 years ago
chacha Move chacha_asm_src file information to build.info files 3 years ago
cmac Coverty fixes for MACs 3 years ago
cmp Regenerate mkerr files 3 years ago
cms Fix a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey 3 years ago
comp Regenerate mkerr files 3 years ago
conf Replace FUNCerr with ERR_raise_data 3 years ago
crmf OSSL_PARAM_construct_utf8_string computes the string length. 3 years ago
ct Regenerate mkerr files 3 years ago
des Cleanup ciphers and Add 3des ciphers. 3 years ago
dh Usages of KDFs converted to use the name macros 3 years ago
dsa Implement DSA in the default provider 3 years ago
dso Cygwin: enable the use of Dl_info and dladdr() 3 years ago
ec Usages of KDFs converted to use the name macros 3 years ago
engine Remove extern declarations of OPENSSL_ia32cap_P 3 years ago
err KDF error codes reworked 3 years ago
ess Regenerate mkerr files 3 years ago
evp Avoid passing NULL to memcpy 3 years ago
hmac Move HMAC to providers 3 years ago
idea Following the license change, modify the boilerplates in crypto/idea/ 4 years ago
include/internal drbg: ensure fork-safety without using a pthread_atfork handler 3 years ago
lhash Fix Typos 3 years ago
md2 Following the license change, modify the boilerplates in crypto/mdN/ 4 years ago
md4 Following the license change, modify the boilerplates in crypto/mdN/ 4 years ago
md5 Move md5_asm_src file information to build.info files 3 years ago
mdc2 Following the license change, modify the boilerplates in crypto/mdc2/ 4 years ago
modes OSSL_PARAM_construct_utf8_string computes the string length. 3 years ago
objects Load the config file by default 3 years ago
ocsp Regenerate mkerr files 3 years ago
pem Fix SCA vulnerability when using PVK and MSBLOB key formats 3 years ago
perlasm s390x assembly pack: update perlasm module 3 years ago
pkcs7 Fix a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey 3 years ago
pkcs12 Regenerate mkerr files 3 years ago
poly1305 Move Poly1305 to providers 3 years ago
property Make sure we pre-initialise properties 3 years ago
rand drbg: fix issue where DRBG_CTR fails if NO_DF is used (2nd attempt) 3 years ago
rc2 Following the license change, modify the boilerplates in crypto/rcN/ 4 years ago
rc4 Move rc4_asm_src file information to build.info files 3 years ago
rc5 Change RC5_32_set_key to return an int type 3 years ago
ripemd Move rmd160_asm_src file information to build.info files 3 years ago
rsa Coverity 1453629 and 1453638: Error handling issues (NEGATIVE_RETURNS) 3 years ago
seed Following the license change, modify the boilerplates in crypto/seed/ 4 years ago
sha Directly return from final sha3/keccak_final if no bytes are requested 3 years ago
siphash Move SipHash to providers 3 years ago
sm2 Support parsing of SM2 ID in hexdecimal 3 years ago
sm3 Move digests to providers 3 years ago
sm4 Following the license change, modify the boilerplates in crypto/smN/ 4 years ago
srp Remove unnecessary trailing whitespace 3 years ago
stack Make core code available within the FIPS module 3 years ago
store Replace FUNCerr with ERR_raise_data 3 years ago
ts Regenerate mkerr files 3 years ago
txt_db Following the license change, modify the boilerplates in crypto/ 4 years ago
ui Remove tab characters from C source files. 3 years ago
whrlpool Remove extern declarations of OPENSSL_ia32cap_P 3 years ago
x509 Fix error handling in x509_lu.c 3 years ago
LPdir_nyi.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_unix.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_vms.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_win.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_win32.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_wince.c Following the license change, modify the boilerplates in crypto/ 4 years ago
README.sparse_array Fix Typos 3 years ago
alphacpuid.pl Following the license change, modify the boilerplates in crypto/ 4 years ago
arm64cpuid.pl Following the license change, modify the boilerplates in crypto/ 4 years ago
arm_arch.h Following the license change, modify the boilerplates in crypto/ 4 years ago
armcap.c crypto/armcap.c, crypto/ppccap.c: stricter use of getauxval() 3 years ago
armv4cpuid.pl ARM assembly pack: make it Windows-friendly. 3 years ago
asn1_dsa.c remove end of line whitespace 3 years ago
bsearch.c ossl_bsearch(): New generic internal binary search utility function 3 years ago
build.info Cleanse crypto/kdf directory 3 years ago
c64xpluscpuid.pl Following the license change, modify the boilerplates in crypto/ 4 years ago
context.c Make sure we pre-initialise properties 3 years ago
core_algorithm.c Add internal function ossl_algorithm_do_all() 3 years ago
core_fetch.c Modify ossl_method_store_add() to accept an OSSL_PROVIDER and check for it 3 years ago
core_namemap.c OSSL_NAMEMAP: make names case insensitive 3 years ago
cpt_err.c Add OPENSSL_hexstr2buf_ex() and OPENSSL_buf2hexstr_ex() 3 years ago
cryptlib.c Remove extern declarations of OPENSSL_ia32cap_P 3 years ago
ctype.c Add missing EBCDIC strings 3 years ago
cversion.c Undeprecate OpenSSL_version_num and OPENSSL_VERSION_NUMBER 3 years ago
dllmain.c Following the license change, modify the boilerplates in crypto/ 4 years ago
ebcdic.c Following the license change, modify the boilerplates in crypto/ 4 years ago
ex_data.c Access data after obtaining the lock not before. 3 years ago
getenv.c Following the license change, modify the boilerplates in crypto/ 4 years ago
ia64cpuid.S Following the license change, modify the boilerplates in crypto/ 4 years ago
info.c Add CPU info to the speed command summary 3 years ago
init.c drbg: ensure fork-safety without using a pthread_atfork handler 3 years ago
initthread.c Fix init_get_thread_local() 3 years ago
mem.c Create a FIPS provider and put SHA256 in it 3 years ago
mem_clr.c Following the license change, modify the boilerplates in crypto/ 4 years ago
mem_dbg.c Fix deprecation inconsisteny w.r.t. CRYPTO_mem_debug_{push,pop}() 3 years ago
mem_sec.c Use vxRandLib for VxWorks7 3 years ago
mips_arch.h Fix compiling error for mips32r6 and mips64r6 3 years ago
o_dir.c Following the license change, modify the boilerplates in crypto/ 4 years ago
o_fips.c Following the license change, modify the boilerplates in crypto/ 4 years ago
o_fopen.c Following the license change, modify the boilerplates in crypto/ 4 years ago
o_init.c Following the license change, modify the boilerplates in crypto/ 4 years ago
o_str.c Add OPENSSL_hexstr2buf_ex() and OPENSSL_buf2hexstr_ex() 3 years ago
o_time.c Following the license change, modify the boilerplates in crypto/ 4 years ago
packet.c Give WPACKET the ability to have a NULL buffer underneath it 3 years ago
param_build.c Fix ossl_param_bld_push_{utf8,octet}_string() / param_bld_convert() 3 years ago
params.c OSSL_PARAM_construct_utf8_string computes the string length. 3 years ago
params_from_text.c Params from text to allow zero length value fields 3 years ago
pariscid.pl Following the license change, modify the boilerplates in crypto/ 4 years ago
ppc_arch.h PPC: Try out if mftb works before using it 3 years ago
ppccap.c Make the EC code available from inside the FIPS provider 3 years ago
ppccpuid.pl PPC: Try out if mftb works before using it 3 years ago
provider.c Rename provider and core get_param_types functions 3 years ago
provider_conf.c Load the config file by default 3 years ago
provider_core.c ossl_provider_library_context(NULL) returns NULL. 3 years ago
provider_local.h Replumbing: Add a mechanism to pre-populate the provider store 3 years ago
provider_predefined.c Make core code available within the FIPS module 3 years ago
s390x_arch.h Remove tab characters from C source files. 3 years ago
s390xcap.c s390x assembly pack: use getauxval to detect hw capabilities 3 years ago
s390xcpuid.pl s390xcpuid.pl: fix comment 3 years ago
sparc_arch.h Following the license change, modify the boilerplates in crypto/ 4 years ago
sparccpuid.S Following the license change, modify the boilerplates in crypto/ 4 years ago
sparcv9cap.c Ensure we get all the right defines for AES assembler in FIPS module 3 years ago
sparse_array.c Fix Typos 3 years ago
threads_none.c drbg: ensure fork-safety without using a pthread_atfork handler 3 years ago
threads_pthread.c drbg: ensure fork-safety without using a pthread_atfork handler 3 years ago
threads_win.c crypto/threads_win.c: fix preprocessor indentation 3 years ago
trace.c prevent endless recursion when trace API is used within OPENSSL_init_crypto() 3 years ago
uid.c Remove NextStep support 3 years ago
vms_rms.h Following the license change, modify the boilerplates in crypto/ 4 years ago
x86_64cpuid.pl Following the license change, modify the boilerplates in crypto/ 4 years ago
x86cpuid.pl Following the license change, modify the boilerplates in crypto/ 4 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.