I am new in cryptography. I need to compute a hash of a string value represented as follows:
$name||i$ where $i$ is an integer.
I use the following pseudocode:
message = byte(name||i) hashize = 1536 // Using SHA256 full-domain-hash with 1536 bits hashed = fdh.Sum(crypto.SHA256, hashize, message) Print(hashed)
Here the hash is a vector of integer values. How can I have only one integer that represents the hash of the message?
My guess is that the intention is to make an RSA-1536 (or Rabin) signature of name (as a string) and integer $i$ per Full Domain Hash. Thus I answer, form a crypto standpoint, a rephrasing of the question as:
How do I make a full-domain hash of the concatenation of a name (given as a string) and an integer, towards signing these per RSA-FDH.
In a nutshell, my recommendation is to make that as in RSA-PSS, but with a fixed salt.
An implementation of that could be
10won't have the same hash as name
0), and normalize the integer (so that integers
0will result in the same hash). Formatting could be as a SEQUENCE (tag 16) with name as UTF8String (tag 12) then INTEGER (tag 2). See Burton S. Kaliski's A Layman's Guide to a Subset of ASN.1, BER, and DER (RSA labs, 1993), which is enough for an implementer, except for the UTF8String type.
Note: when targeting RSA, the combination of 2…5 is precisely signature per RSASSA-PSS of PKCS#1v2.2, and implementations of that should be reusable directly, if they have an input for the salt or for the salt-generating method.
Answered by fgrieu on January 30, 2021
1 Asked on February 23, 2021 by ssa
2 Asked on February 23, 2021 by mint-branch-conditioner
0 Asked on February 21, 2021
0 Asked on February 19, 2021 by irwin
0 Asked on February 18, 2021 by confused-andstuck
1 Asked on February 18, 2021
0 Asked on February 16, 2021
0 Asked on February 13, 2021 by forest
0 Asked on February 9, 2021 by doctopus
1 Asked on January 30, 2021 by jusmin
3 Asked on January 29, 2021 by 38fule
2 Asked on January 26, 2021 by columbida
3 Asked on January 22, 2021 by m-s-dousti
0 Asked on January 22, 2021 by modal-nest
0 Asked on January 19, 2021 by antonis-paragas
7 Asked on January 18, 2021
5 Asked on January 15, 2021 by johankj
0 Asked on January 14, 2021 by ay
Get help from others!