def derive_openssl(key, salt): key = key[0:-16] key_and_iv = b('') prev = b('') while len(key_and_iv) < 32: prev = MD5.new(prev + key + salt).digest() # ? key_and_iv += prev return key_and_iv[0:16], key_and_iv[16:]
def get_santy_string(base64_encoded_string): salted_prefix = b('Salted__') zero_init_vector = b('\x00') * 16 decoded_data = b64decode(base64_encoded_string) if decoded_data.startswith(salted_prefix): return SaltyString(salt=decoded_data[8:16], data=decoded_data[16:]) return SaltyString(salt=zero_init_vector, data=decoded_data)
def derive_pbkdf2(password, salt, iterations): key_and_iv = pbkdf2_bin(b(password), salt, iterations=iterations, keylen=32) return key_and_iv[0:16], key_and_iv[16:]