Cryptography Asked by jusmin on January 30, 2021
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
foo
and integer 10
won't have the same hash as name foo1
and integer 0
), and normalize the integer (so that integers 00
and 0
will 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
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP