Re: Hash of Public key
From: Arkady Frenkel (arkadyf_at_hotmailxdotx.com)
Date: 05/19/05
- Next message: Valery Pryamikov: "Re: Hash of Public key"
- Previous message: Valery Pryamikov: "Re: Hash of Public key"
- In reply to: Valery Pryamikov: "Re: Hash of Public key"
- Next in thread: Valery Pryamikov: "Re: Hash of Public key"
- Reply: Valery Pryamikov: "Re: Hash of Public key"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 19 May 2005 13:25:25 +0200
No , I can't do it on my own .
I need the way MSFT use it ( at least ) because I do it for UPnP device and
other devices ( not mine obviously like PC can be UPnP device too , WiFi ,
cameras and so on ) receive that hashed value as identification ID due to
UPnP security spec, so I can't do on my own but at least as MSFT do that and
in managed code ( so can't use (C)API ).
Arkady
"Valery Pryamikov" <valery@harper.no> wrote in message
news:ulQr0ZFXFHA.3712@TK2MSFTNGP09.phx.gbl...
>I answered you several times you can hash your public key in many different
>ways - all depends on your needs. Ex:
> 1. Calculate hash on concatenation of little endian modulus with little
> endian exponent without conversions (little endian is presentation used by
> CAPI);
> 2. Calculate hash on concatenation of little endian exponent with little
> endian modulus without conversions;
> 3. Calculate hash of little endian modulus and state that you are
> expecting standard recommended public exponent only 0x1001 and fail
> processing if exponent is different.
> 4. Do as in 1, but convert both values to big endian;
> 5. Do as in 2, but convert both values to big endian;
> 6. Do as in 3, but convert modulus to big endian;
> 7. Do as in 1, but convert both values to ASN1;
> 8. Do as in 2, but convert both values to ASN1;
> 9. Do as in 3, but convert modulus to ASN1;
> 7. Do as in 1, but pack both values into xml format;
> 8. Do as in 2, but pack both values into xml format;
> 9. Do as in 3, but pack modulus into xml format;
> 10. any variation of all above;
> 11. Use CAPI's CryptExportKey and calculate hash on PLAINTEXTBLOB;
> 12. Use CAPI's CryptExportKey and calculate hash on PUBLICKEYBLOB;
> 13. Use CAPI's CryptEncodeObjectEx to pack public key into ASN1.DER
> encoded structure of public key as specified in PKCS#1 and calculate hash
> on that blob;
> 14. In case if your public key is stored in certificate it is already in
> the form as in 13 - retrieve public key blob and calculate hash on that
> blob;
>
> I can add a hundred more practical suggestions on how to hash public key.
> You didn't provide us with concrete requirements to make a single
> practical suggestion. I have tried to explain that to you several times.
> I did write that public key could be hashed in many different ways
> depending on your requirements in several of my posts to that thread.
>
> -Valery.
> http://www.harper.no/valery
>
> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
> news:OZbLClEXFHA.1508@tk2msftngp13.phx.gbl...
>>I ask very simple question and really want to read practical advice : how
>>to calculate hash from public key , if you ( Valery ) want to think as I
>>have to calculate public key token ( really I don't need that ) , but
>>before to receive last 8 bytes ( token ) I have to receive all hash and
>>that is my simple question. Do I need to send array of bytes of Modulus
>>only or both ( Modulus and Exponent which is 3 ( that I wrote about ) in
>>the case of RSA? I don't need theories of security algorithms and their
>>output , just practical answer on my simple question.
>> I have ( C# code ):
>> RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
>>
>> RSAParameters rsaresult = new RSAParameters();
>>
>> rsaresult = rsa.ExportParameters(false);
>>
>> Now I have public key in the rsaresult and want to know if modulus will
>> be enough for hash of public key , that's all I need . Like to extract
>> token ( last reverced 8 bytes ) afterwards e.g.
>>
>> byte[] PKbytes = new byte [ rsaresult.Modulus.GetLength(0)/* probably or
>> something else + rsaresult.Exponent.GetLength(0) */];
>>
>> rsaresult.Modulus.CopyTo(PKbytes,0);
>>
>> // probably or something else
>>
>> // rsaresult.Exponent.CopyTo(PKbytes,rsaresult.Modulus.GetLength(0));
>>
>> SHA1Managed sha = new SHA1Managed() ;
>>
>> byte[] b = sha.ComputeHash(PKbytes,0,PKbytes.Length ) ;
>>
>> All I want to know what have to be in PKbytes array to receive hash of
>>
>> public key.
>>
>> All I want practical answer on practical question ( please no theory , I
>> have enough books around me )
>>
>> Arkady
>>
>> "Valery Pryamikov" <valery@harper.no> wrote in message
>> news:eH09eNDXFHA.1044@TK2MSFTNGP10.phx.gbl...
>>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>>> news:u9T$di%23WFHA.1796@TK2MSFTNGP15.phx.gbl...
>>>> That not correct , exponent is 3 not 4 bytes. OTOH only 128 bytes used
>>>> to calculate hash of public key not 131 and not 132.But both of you
>>>> didn't answer my simple question what is algorithm of callculation hash
>>>> from public key so I see I have to try other group, indirectly I see
>>>> both in Windows and open source ( free ssl ) modulus used only but I'm
>>>> not sure 100%
>>>> Arkady
>>>>
>>> Hmm,
>>> at first you are asking a completely meaningless question. We've tried
>>> to clarify your requirements hoping that would show you the answers that
>>> you were looking for. Instead you simply repeat your meaningless
>>> question with extra mumbling about some number that you taken from
>>> somewhere...
>>> How to hash a public key? You take a hash function, send public key as a
>>> parameter to a hash function and get the result. That's at least how it
>>> is usually done.
>>> And your "That not correct..." is in fact completely wrong.
>>> Modulus and exponent are not measured in bytes, but in bits. You are
>>> referring to 1024 bit modulus that becomes less and less used due to
>>> simple fact that is providing less than 80 bits of security (and just a
>>> couple of weeks ago 740 bits modulus 200 decimal digits was successfully
>>> factored).
>>> Public exponent could be any number from 3 up to large integer that
>>> takes a half of bits of modulus (not bigger than that, since small
>>> private exponents are vulnerable to Weiner's attack). The only
>>> requirement for public and private exponents in rsa is that e*d=1 mod
>>> phi(m), where phi(m) is Euler's phi function and is (p-1)*(q-1).
>>> In fact, on other platforms than Windows it's quite usual to have public
>>> exponent of the same size as private exponent and about half-size of
>>> modulus, because in this case you actually can use public key and
>>> private key interchangeably...
>>>
>>> But you know, what? I think that you were not really asking for help....
>>>
>>> -Valery.
>>> http://www.harper.no/valery
>>>
>>
>>
>
- Next message: Valery Pryamikov: "Re: Hash of Public key"
- Previous message: Valery Pryamikov: "Re: Hash of Public key"
- In reply to: Valery Pryamikov: "Re: Hash of Public key"
- Next in thread: Valery Pryamikov: "Re: Hash of Public key"
- Reply: Valery Pryamikov: "Re: Hash of Public key"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|