'Search in 2-3 tree with log(d) complexity, where d is the rank of the element

I have to find a way to search an element x in a 2-3 tree in O(log(d)) time, where d is the rank of x. also I have to maintain O(log(n)) complexity for inserting and deleting an element, where n is the number of elements in the tree.

the usual search takes O(log(n)) time, at first I tried to prove that in the usual search it also takes O(log(d)) time but that is not true.

Any directions or suggestions for an algorithm?

Note: I am allowed to add information and fields to each node but I have to keep the structure of a 2-3 tree.



Solution 1:[1]

openssl enc -e -A -aes-256-cbc -a -K ${password} -iv ${password} -nosalt)

With aes-256 the key needs to have 32 bytes and iv needs to have 16 bytes, so properly you cannot use the same value (it works for aes-128 though).

You are using the password as a key (-K parameter), so let's use a proper denotation key, which in this case should be 32 bytes hex encoded.

if some one get my "pubkey" and know that the "pubkey" is generated by the way above, can he/she crash my password?

no, that shouldn't be possible

  1. If the pubkeys match, the password is the correct one.
  2. Use the correct password to decrypt my information.

I don't really understand the reason behind the step. You can just try to decrypt the file and if the key is not current, the decryption fails on invalid padding.

Or - do you want to validate the key once when provided by the user? In that case you could validate a hash of the password

echo 'some password' | openssl dgst -sha256

Usually storing a simple hash of a user password is not secure enough, but assuming you provide a random 256 bit key, it should be ok.

iv=${pwd}

This seems to be a vulnerability, the cbc mode needs a random IV to be secure. Reusing the IV for multiple encryptions is not secure.

Maybe just let the openssl generate a random salt (and derive the key and IV from the salt and password) would solve the problem.

echo -n 'some text' | openssl enc -e -A -aes-128-cbc -k 'password' -a

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1