Two very basic questions:
1. Digital Signing
Why is it not possible to just simply replace the hash value from the request?
Examples:
- Mallory creates two different documents A and B, that have an
identical hash value (collision).
- Mallory then sends document A to Alice, who agrees to what the
document says, signs its hash and sends it back to Mallory.
- Mallory copies the signature sent by Alice from document A to
document B. Then she sends document B to Bob, claiming that Alice
signed the other document (document B).
- Because the digital signature matches the document hash, Bob's
software is unable to detect the modification.
Reference: http://en.wikipedia.org/wiki/Collision_attack
It's not transmitted, a secret and at the same time you just send the hash eventually? How does this work out?
Hash functions are also great for signing data. For example, if you're using HMAC, you sign a piece of data by taking a hash of the data concatenated with a known but not transmitted value (a secret value). So you send the plain-text and the hmac hash. Then, the receiver simply hashes the submitted data with the known value and checks to see if it matches the transmitted hmac. If it's the same, you know it wasn't tampered with by a party without the secret value. This is commonly used in secure cookie systems by HTTP frameworks, as well as in message transmission of data over HTTP where you want some validity to the data.
Reference : https://stackoverflow.com/questions/4948322/fundamental-difference-between-hashing-and-encryption-algorithms
2. Digital Signing
I can't see why this code produces less colitions than the second one As soon as you have a conflict with two inputs, how does it help to append the same two values for the next recursive loops?
Not recommended:
hash = sha512(password + salt);
for (i = 0; i < 1000; i++) {
hash = sha512(hash); // <-- Do NOT do this!
}
Recommended:
hash = sha512(password + salt);
for (i = 0; i < 1000; i++) {
hash = sha512(hash + password + salt);
}
I was reading that part five times and although it kind of makes sense I am having a hard time fully comprehending it.
Now, hash1 has a probability of collision of 0.001%. But when we do the next hash2 = sha1(hash1);, all collisions of hash1 automatically become collisions of hash2. So now, we have hash1's rate at 0.001%, and the 2nd sha1 call adds to that.
Reference : https://stackoverflow.com/questions/4948322/fundamental-difference-between-hashing-and-encryption-algorithms