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.
 
 
 
 
 
 
Richard Levitte 2d956b320c PROV: Add DERlib support for ECDSA and EC keys 3 years ago
..
aes aes-s390x.pl: fix stg offset caused by typo in perlasm 3 years ago
aria Reorganize private crypto header files 3 years ago
asn1 Fix bug in strncpy() use of sk_ASN1_UTF8STRING2text() in asn1_lib.c 3 years ago
async Use swapcontext for Intel CET 3 years ago
bf Also check for errors in x86_64-xlate.pl. 3 years ago
bio Constify various mostly X509-related parameter types in crypto/ and apps/ 3 years ago
bn [BN] harden `BN_copy()` against leaks from memory accesses 3 years ago
buffer Rework how our providers are built 3 years ago
camellia Also check for errors in x86_64-xlate.pl. 3 years ago
cast Also check for errors in x86_64-xlate.pl. 3 years ago
chacha Also check for errors in x86_64-xlate.pl. 3 years ago
cmac Deprecate the low level CMAC functions 3 years ago
cmp HTTP client: make server/proxy and port params more consistent; minor other improvements 3 years ago
cms Implementation of Russian GOST CMS 3 years ago
comp Reorganize local header files 3 years ago
conf Add support for passing the libctx to the config loader 3 years ago
crmf Constify various mostly X509-related parameter types in crypto/ and apps/ 3 years ago
ct Deprecate the low level SHA functions. 3 years ago
des Also check for errors in x86_64-xlate.pl. 3 years ago
dh Param build: make structures opaque. 3 years ago
dsa PROV: Add DERlib support for DSA 3 years ago
dso Reorganize local header files 3 years ago
ec PROV: Add DERlib support for ECDSA and EC keys 3 years ago
engine Deprecate the low level SHA functions. 3 years ago
err HTTP client: make server/proxy and port params more consistent; minor other improvements 3 years ago
ess Fix error handling in x509v3_cache_extensions and related functions 3 years ago
evp Add EVP_PKEY_gettable_params support for accessing EVP_PKEY key data fields 3 years ago
ffc EVP: Implement support for key downgrading in backends 3 years ago
hmac Deprecate the low level HMAC functions 3 years ago
http HTTP client: make server/proxy and port params more consistent; minor other improvements 3 years ago
idea Deprecate the low level IDEA functions. 3 years ago
kdf Deprecate ERR_load_KDF_strings() 3 years ago
lhash Rework how our providers are built 3 years ago
md2 Adapt all build.info and test recipes to the new $disabled{'deprecated-x.y'} 3 years ago
md4 Adapt all build.info and test recipes to the new $disabled{'deprecated-x.y'} 3 years ago
md5 Also check for errors in x86_64-xlate.pl. 3 years ago
mdc2 Adapt all build.info and test recipes to the new $disabled{'deprecated-x.y'} 3 years ago
modes Also check for errors in x86_64-xlate.pl. 3 years ago
objects Add support for DH 'modp' group parameters (RFC 3526) 3 years ago
ocsp Add OCSP_RESPID_set_by_key_ex() and OCSP_RESPID_match_ex() 3 years ago
pem Deprecate the low level DSA functions. 3 years ago
perlasm Fix build with clang assembler 3 years ago
pkcs7 Explicitly test against NULL; do not use !p or similar 3 years ago
pkcs12 Fix error handling in x509v3_cache_extensions and related functions 3 years ago
poly1305 Also check for errors in x86_64-xlate.pl. 3 years ago
property Introduce the provider property 3 years ago
rand AES CTR-DRGB: performance improvement 3 years ago
rc2 Deprecate the low level RC2 functions 3 years ago
rc4 Also check for errors in x86_64-xlate.pl. 3 years ago
rc5 Also check for errors in x86_64-xlate.pl. 3 years ago
ripemd Also check for errors in x86_64-xlate.pl. 3 years ago
rsa PROV: Add DERlib support for RSA 3 years ago
seed Deprecate the low level SEED functions 3 years ago
serializer If the first serializer we find is the desired one that's ok 3 years ago
sha x86_64: Don't assume 8-byte pointer size 3 years ago
siphash Reorganize private crypto header files 3 years ago
sm2 SM2: Make the EVP_PKEY_METHOD ctrl_str function listen to distid 3 years ago
sm3 Cleanup legacy digest methods. 3 years ago
sm4 Reorganize private crypto header files 3 years ago
srp Make SRP library context aware 3 years ago
stack Rework how our providers are built 3 years ago
store Constify various mostly X509-related parameter types in crypto/ and apps/ 3 years ago
ts Fix error handling in x509v3_cache_extensions and related functions 3 years ago
txt_db Following the license change, modify the boilerplates in crypto/ 4 years ago
ui Constify various mostly X509-related parameter types in crypto/ and apps/ 3 years ago
whrlpool Also check for errors in x86_64-xlate.pl. 3 years ago
x509 Set X509_V_ERR_INVALID_EXTENSION error for invalid basic constraints 3 years ago
LPdir_nyi.c Following the license change, modify the boilerplates in crypto/ 4 years ago
LPdir_unix.c Fix a -Warray-bounds gcc warning in OPENSSL_DIR_read 3 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 Also check for errors in x86_64-xlate.pl. 3 years ago
arm64cpuid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
arm_arch.h Fix header file include guard names 3 years ago
armcap.c crypto/armcap.c, crypto/ppccap.c: stricter use of getauxval() 4 years ago
armv4cpuid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
asn1_dsa.c Fix some typos 3 years ago
bsearch.c ossl_bsearch(): New generic internal binary search utility function 3 years ago
build.info PROV: Add the beginning of a DER writing library 3 years ago
c64xpluscpuid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
context.c Put an error on the stack in the event of a fetch failure 3 years ago
core_algorithm.c Replumbing: make it possible for providers to specify multiple names 3 years ago
core_fetch.c CORE: pass the full algorithm definition to the method constructor 3 years ago
core_namemap.c Modify EVP_CIPHER_is_a() and EVP_MD_is_a() to handle legacy methods too 3 years ago
cpt_err.c CORE: ossl_namemap_add_names(): new function to add multiple names 3 years ago
cryptlib.c Reorganize private crypto header files 3 years ago
ctype.c Reorganize private crypto header files 3 years ago
cversion.c Cleanup include/openssl/opensslv.h.in 3 years ago
der_writer.c PROV: Add the beginning of a DER writing library 3 years ago
dllmain.c Reorganize private crypto header files 3 years ago
ebcdic.c Following the license change, modify the boilerplates in crypto/ 4 years ago
ex_data.c Remove double fetch of "OSSL_EX_DATA_GLOBAL" for global lock 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 Modify the add_seeds_stringlist() macro to fix a preprocessor error 3 years ago
init.c Reorganize private crypto header files 3 years ago
initthread.c Fix init_thread_stop 3 years ago
mem.c Memory allocator code cleanup 3 years ago
mem_clr.c Following the license change, modify the boilerplates in crypto/ 4 years ago
mem_sec.c secmem: ignore small minsize arguments to CRYPTO_secure_malloc_init(). 3 years ago
mips_arch.h Fix header file include guard names 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 Add "endfirst" writing to WPACKET 3 years ago
param_build.c Param builder: Remove the static size limit. 3 years ago
param_build_set.c Add EVP_PKEY_gettable_params support for accessing EVP_PKEY key data fields 3 years ago
params.c Allow strings in params to be of zero length 3 years ago
params_from_text.c Params: add argument to the _from_text calls to indicate if the param exists. 3 years ago
pariscid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
ppc_arch.h Fix header file include guard names 3 years ago
ppccap.c Reorganize local header files 3 years ago
ppccpuid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
provider.c Rename provider and core get_param_types functions 3 years ago
provider_conf.c Add support for passing the libctx to the config loader 3 years ago
provider_core.c Fix off-by-1 bug on provider_activate with custom error strings 3 years ago
provider_local.h Replumbing: Add a mechanism to pre-populate the provider store 4 years ago
provider_predefined.c When building of modules is disabled, build the legacy provider into libcrypto 3 years ago
s390x_arch.h Fix header file include guard names 3 years ago
s390xcap.c crypto/s390xcap.c: Add guards around the GETAUXVAL checks 3 years ago
s390xcpuid.pl Also check for errors in x86_64-xlate.pl. 3 years ago
self_test_core.c Add pairwise consistency self tests to asym keygenerators 3 years ago
sparc_arch.h Fix header file include guard names 3 years ago
sparccpuid.S Following the license change, modify the boilerplates in crypto/ 4 years ago
sparcv9cap.c Fix misspelling errors and typos reported by codespell 3 years ago
sparse_array.c Reorganize private crypto header files 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 OSSL_STORE: add tracing 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 Also check for errors in x86_64-xlate.pl. 3 years ago
x86cpuid.pl Also check for errors in x86_64-xlate.pl. 3 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.