<div dir="ltr">Yawning<div><br></div><div>Thanks very much - you've saved me another few days down the wrong path!  It seems I was taking the onion-key not the signing key.  Would never have caught that this far down the rabbit hole without your response!</div>

<div><br></div><div>Now to work out why Tor is detecting a different identity to the SSL cert I'm sending.</div><div><br></div><div>Best</div><div>Garth</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On 17 August 2014 17:06, Yawning Angel <span dir="ltr"><<a href="mailto:yawning@schwanenlied.me" target="_blank">yawning@schwanenlied.me</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="">On Sun, 17 Aug 2014 16:19:56 +0100<br>
Gareth Owen <<a href="mailto:gareth.owen@port.ac.uk">gareth.owen@port.ac.uk</a>> wrote:<br>
<br>
> I'm trying to generate the fingerprint given just the pubilc key in<br>
> Java and after almost a whole day I'm about to give up.  Does anyone<br>
> have a sample PKCS#1 encoded public key that is used immediately<br>
> before SHA-1 to generate the fingerprint?  e.g. a hex string is what<br>
> I'm after.<br>
<br>
</div>Both descriptors and microdescriptors contain this in the appropriate<br>
format (albeit Base64 encoded and with a PEM envelope). Check the data<br>
directory of a running tor instance and look at<br>
cached-microdescs(.new), which will have onion-key entries for all the<br>
relays.<br>
<div class=""><br>
> It seems there are subtle ways that an PKCS#1 can vary while encoding<br>
> the same information which affects the hash, Java seems to be doing<br>
> it one way, OpenSSL another, an example on stack overflow adds an<br>
> extra field, etc.<br>
<br>
</div>The way that you care about (that matches how tor does it) is specified<br>
in RFC 2313.<br>
<br>
  7.1 Public-key syntax<br>
<br>
     An RSA public key shall have ASN.1 type RSAPublicKey:<br>
<br>
     RSAPublicKey ::= SEQUENCE {<br>
       modulus INTEGER, -- n<br>
       publicExponent INTEGER -- e }<br>
<br>
     (This type is specified in X.509 and is retained here for<br>
     compatibility.)<br>
<br>
How to do this in Java depends on which crypto API you are using, look<br>
at oracle.security.crypto.asn1 or org.bouncycastle.asn1.  Additionally<br>
this (<a href="http://lapo.it/asn1js/" target="_blank">http://lapo.it/asn1js/</a>) will probably be useful.<br>
<br>
Regards,<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Yawning Angel<br>
</font></span><br>_______________________________________________<br>
tor-dev mailing list<br>
<a href="mailto:tor-dev@lists.torproject.org">tor-dev@lists.torproject.org</a><br>
<a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Dr Gareth Owen<div>Senior Lecturer</div><div>School of Computing, University of Portsmouth</div><div><br></div><div>Tel: 02392 846423</div><div>

Web: <a href="http://ghowen.me" target="_blank">ghowen.me</a></div></div>
</div>