I am trying to answer a CASP exam practice question.

Could someone comment on the options below regarding the logic behind each item? Where is the logical error behind each statement?

A Storage-as-a-Service company implements both encryption at rest as well as encryption in transit of customers’ data. The security administrator is concerned with the overall security of the encrypted customer data stored by the company servers and wants the development team to implement a solution that will strengthen the customer’s encryption key.

Which of the following, if implemented, will MOST increase the time an offline password attack against the customers’ data would take?

key = NULL ; for (int i=0; i<5000; i++) { **key = sha(key + password)** }

password = NULL ; for (int i=0; i<10000; i++) { password = sha256(key) }

password = password + sha(password+salt) + aes256(password+salt)

key = aes128(sha256(password), password))

source: various CASP exam cram question banks

This is what I know:

1) SHA-256 or higher generates really strong hashes with a very low collision probability. It's highly unlikely to produce a collision.

2) I read another article, but not conclusive regarding the JavaScript option: https://stackoverflow.com/questions/18279141/javascript-string-encryption-and- decryption

3) This one is much more articulated regarding options to improve the alternatives: https://stackoverflow.com/questions/18338890/are-there-any-sha-256-javascript-implementations-that-are-generally-considered-t

4) I found this real example of the SHA256 encoding scheme and as well generating a salt to make it even more secure by defeating precomputed hash tables. We will then run it through password-checking to ensure the password was typed correctly:

// From Python: Penetration Testing for Developers

import uuid
import hashlib

# Let's do the hashing. We create a salt and append it to the password once hashes.

def hash(password):
    salt = uuid.uuid4().hex
    return hashlib.sha512(salt.encode() + password.encode()).hexdigest() + ':' + salt

# Let's confirm that worked as intended.

def check(hashed, p2):
    password, salt = hashed.split(':')
    return password == hashlib.sha512(salt.encode() + p2.encode()).hexdigest()

password = raw_input('Please enter a password: ')
hashed = hash(password)
print('The string to store in the db is: ' + hashed)
re = raw_input('Please re-enter your password: ')

# Let's ensure the passwords matched

if check(hashed, re):
    print('Password Match')
    print('Password Mismatch')
  • 1
    Obviously the answer is A. B doesn't do anything but set password to the same value over and over, and C and D are just silly homebrew KDF schemes.
    – forest
    Commented Sep 10, 2018 at 2:50
  • @forest this is a CASP exam question, can you expand on your explanations as an answer?
    – schroeder
    Commented Sep 10, 2018 at 9:26

1 Answer 1


I think that you are overthinking the question. You do not need to understand proper password handling to answer this. Work through each logic flow.

A: You recursively hash sha(key + password) 5000 times, so this increases the work someone has to do to crack it by 5000. Work = 5000

B: You just set password to the same value 10000 times, so it is equivalent to just password = sha256(key) which is a single hash function. Work = 1

C: The password is not hashed at all, it is left in plaintext with hashes appended to the end. This is obviously the worst possible answer. Work = 0

D: This is a single hash function with 2 steps, so it is a tiny bit better than B, but not really. Work = 1

  • Although both A and D are a bit unclear to me because those are calculating not the hash but the key. As a result, they are useless without further details on how the key is being used to generate the hashed password... Commented Sep 10, 2018 at 16:50
  • @ConorMancone agreed, but I don't think that's the concept being tested in the question
    – schroeder
    Commented Sep 10, 2018 at 18:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .