Bitcoin Forum
December 08, 2016, 08:13:43 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Paying to add RSA/SHA512 padding to a Javascript lib  (Read 6366 times)
Nefario
Hero Member
*****
Offline Offline

Activity: 602


GLBSE Support support@glbse.com


View Profile WWW
May 15, 2011, 01:05:57 PM
 #1

I will be needing to sign some requests using RSA and SHA512 for padding in Javascript.

Here is the Javascript RSA lib http://www9.atwiki.jp/kurushima/pub/jsrsa/

However it doesn't do SHA512(doing only sha1 & sha256) for padding.

Here is what the page says about adding another hashing method.

Quote
How to add supported signature algorithms
The script "rsa-sign.js" currently supports SHA1withRSA and SHA256withRSA signature algorithms. However you can extend other signature algorithms such like MD5withRSA or SHA512withRSA by just specifying two variables in it.

_RSASIGN_DIHEAD['md5'] = "30..."; // Hexadecimal DigestInfo prefix for MD5 _RSASIGN_HASHHEXFUNC['md5'] = md5hex; // function which returns value in hex.


You can use any sha512 javascript function that works for this.

Please post your solution below and how much work was involved for you and I'll give you a payment you'll be happy with (not giving exact numbers, but I'm not known as someone who's mean or stingy).

Regards Nefario

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
1481184823
Hero Member
*
Offline Offline

Posts: 1481184823

View Profile Personal Message (Offline)

Ignore
1481184823
Reply with quote  #2

1481184823
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481184823
Hero Member
*
Offline Offline

Posts: 1481184823

View Profile Personal Message (Offline)

Ignore
1481184823
Reply with quote  #2

1481184823
Report to moderator
1481184823
Hero Member
*
Offline Offline

Posts: 1481184823

View Profile Personal Message (Offline)

Ignore
1481184823
Reply with quote  #2

1481184823
Report to moderator
lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
May 15, 2011, 04:08:27 PM
 #2

I'm not quite sure what you need, but this library says it supports SHA512: http://jssha.sourceforge.net/

EDIT: Err, I was working on the same code graingert gave, so I'll just leave that to him then.

graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 15, 2011, 04:11:30 PM
 #3

    _RSASIGN_DIHEAD['sha512'] = "30..."; // Hexadecimal DigestInfo prefix for sha512
_RSASIGN_HASHHEXFUNC['sha512'] = sha512func; // function which returns sha512 value in hex.

 *Image Removed*
graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 15, 2011, 04:15:51 PM
 #4

and you'll need

function sha512func() {
try {
return hashObj.getHash("SHA-512", "HEX");
} catch(e) {
}
}

build yourself a hash obj using http://jssha.sourceforge.net/

throw me a few coins if you think it's worth it / it works : 163aFkTefqW3Ab8dJ3XvzkURigd7uTAP2d

 *Image Removed*
graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 15, 2011, 04:20:48 PM
 #5

sorry that should be:
Code:
function sha512func(valueToBeHashed) {
    try {
        hashObj = new jsSHA(valueToBeHashed, "HEX");
        return hashObj.getHash("SHA-512", "HEX");
    } catch(e) {
    }
}
_RSASIGN_DIHEAD['sha512'] = "30..."; // Hexadecimal DigestInfo prefix for sha512
_RSASIGN_HASHHEXFUNC['sha512'] = sha512func; // function which returns sha512 value in hex.

and you'll need to import <script type="text/javascript" src="sha.js"></script> from http://jssha.sourceforge.net/


 *Image Removed*
lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
May 15, 2011, 04:22:12 PM
 #6

sorry that should be:

function sha512func(valueToBeHashed) {
try {
hashObj = new jsSHA(valueToBeHashed, "HEX");
return hashObj.getHash("SHA-512", "HEX");
} catch(e) {
}
}

and you'll need to import <script type="text/javascript" src="sha.js"></script> from http://jssha.sourceforge.net/



Actually, I think you'll want:

Code:
hashObj = new jsSHA(valueToBeHashed, "ASCII");

But I'm not sure.

graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 15, 2011, 04:23:24 PM
 #7

ah I thought you'd want HEX to HEX hashing, but yes if you are using ASCII then use "ASCII"

 *Image Removed*
graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 17, 2011, 01:14:13 AM
 #8

did it work?

 *Image Removed*
Nefario
Hero Member
*****
Offline Offline

Activity: 602


GLBSE Support support@glbse.com


View Profile WWW
May 17, 2011, 03:30:29 AM
 #9

Can't tell, it's seems to be signing, that is it's kind of working, but the signature isn't verifying with openssl.

I'll send a bit of btc yourway graingert for getting the hash function to work.

Now however I have a related task, and 50BTC to the person who sorts this out for me.

That is, the signature can be verified using the public key and openssl on a server somewhere.

For bonus point get it working with openssl and ruby.

Code:
require 'openssl'
pubkey="fsdfsdf..."
#signature is the javascript signature
#data is whats signed
public_key=OpenSSL::PKey::RSA.new(pubkey)
public_key.verify( OpenSSL::Digest::SHA512.new, signature, data )

My experience is that openssl expects binary for the signature (at least that's what it outputs)

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
Nefario
Hero Member
*****
Offline Offline

Activity: 602


GLBSE Support support@glbse.com


View Profile WWW
May 17, 2011, 05:19:21 AM
 #10

Above offer withdrawn, looks like I've got it figured out.

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
Nefario
Hero Member
*****
Offline Offline

Activity: 602


GLBSE Support support@glbse.com


View Profile WWW
May 17, 2011, 08:12:05 AM
 #11

10btc heading graingert's way for his initial answer (which worked) and for helping me out later on IRC which helped to get me the rest of the way.

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
graingert
Full Member
***
Offline Offline

Activity: 227


View Profile WWW
May 17, 2011, 11:45:47 AM
 #12

yep I am happy if you are Cheesy

 *Image Removed*
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!