On Thu, Mar 17, 2011 at 11:52 PM, Leigh wrote:
>
> Cool. I was trying to play around with it, but did not get that far ;-)
>
>> So that is a hex representation of the 512 bit
>> RSA public key.  Theoretically.
>
> Could you print the modulus and exponent parts of the public key separately? 
> That is what is needed for cf/java.
>
> I am still trying to figure out how they arrived at that original string, 
> which is supposedly base64 encoded. Maybe seeing the modulus and exponent 
> parts will help.

I'm thinking you are right in guessing that the base64 routine isn't a
"normal" base64 routine.

The raw data seems to work:

var exponent = 
createObject("java","java.math.BigInteger").init("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C355",16);
var modulus = 
createObject("java","java.math.BigInteger").init("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BFDF38C9703C07CB6877A41C4B05F5E03EAFC6579F2263CF686289C13B96CCFE9587F5C9FF2D8787A784D0DD8EE1B79CD96BB969611E0E42603EB6E4A23CBE3D",16);
var pubKeySpec = createObject("java",
"java.security.spec.RSAPublicKeySpec").init(modulus,exponent);
var factory = 
createObject("java","java.security.KeyFactory").getInstance("RSA");
var keyInstance = factory.generatePublic(pubKeySpec);

But no matter how I played around with it, converting the original
"base64" encoded string didn't come anywhere near that--

OMG!  I had a thought while typing this, and I think I had a
revelation.  Remember how the docs mention things being a byte shorter
to "speed things up"?  Yeah.

I just tried dumping the b64 stuff using sun.misc.BASE64Decoder, as a
bit of a sanity check, and I'll be damned if the string wasn't almost
what it should be.  My nips got hard.  By adding a 0, both CF and Sun
reported the same results!

Ex:
<cfdump var="#binaryEncode(binaryDecode('++11Ik','base64'),'base64')#"
label="orig">
string  ++11Ig==
<cfdump var="#binaryEncode(binaryDecode('++11Ik0','base64'),'base64')#"
label="wazero">
string  ++11Ik0=

Closer, neh?

I can freaking smell victory!  I gotta switch gears, but I figured I'd
toss this out there, even though it pains me to be so close
(theoretically) and not to be able to say "SOLVED!".

If I was a selfish person, I'd wait till I figured it out myself, and
post the solution.  I'm a team player though.  The goal isn't personal
awesomeness, or whatever.  Plus, I'm mad awesome already...  ;)

:Den

-- 
Sin is geographical.
Bertrand Russel

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343125
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to