URI: 
       tadd support for rsa+sha384 and rsa+sha512 in paymentrequests - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 3e1078c79b8f45efd3365b43440a18f2b5dcfe08
   DIR parent 7b0903d81c37bca3bc7e78c2e61442d868c1bf49
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sun,  8 Feb 2015 20:04:42 +0100
       
       add support for rsa+sha384 and rsa+sha512 in paymentrequests
       
       Diffstat:
         M lib/paymentrequest.py               |      12 ++++++++----
         M lib/x509.py                         |      10 ++++++++++
       
       2 files changed, 18 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py
       t@@ -190,8 +190,13 @@ class PaymentRequest:
                        verify = pubkey.hashAndVerify(sig, data)
                    elif algo.getComponentByName('algorithm') == x509.ALGO_RSA_SHA256:
                        hashBytes = bytearray(hashlib.sha256(data).digest())
       -                prefixBytes = bytearray([0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20])
       -                verify = pubkey.verify(sig, prefixBytes + hashBytes)
       +                verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA256 + hashBytes)
       +            elif algo.getComponentByName('algorithm') == x509.ALGO_RSA_SHA384:
       +                hashBytes = bytearray(hashlib.sha384(data).digest())
       +                verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA384 + hashBytes)
       +            elif algo.getComponentByName('algorithm') == x509.ALGO_RSA_SHA512:
       +                hashBytes = bytearray(hashlib.sha512(data).digest())
       +                verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA512 + hashBytes)
                    else:
                        self.error = "Algorithm not supported"
                        util.print_error(self.error, algo.getComponentByName('algorithm'))
       t@@ -226,8 +231,7 @@ class PaymentRequest:
        
                if paymntreq.pki_type == "x509+sha256":
                    hashBytes = bytearray(hashlib.sha256(msgBytes).digest())
       -            prefixBytes = bytearray([0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20])
       -            verify = pubkey0.verify(sigBytes, prefixBytes + hashBytes)
       +            verify = pubkey0.verify(sigBytes, x509.PREFIX_RSA_SHA256 + hashBytes)
                elif paymntreq.pki_type == "x509+sha1":
                    verify = pubkey0.hashAndVerify(sigBytes, msgBytes)
                else:
   DIR diff --git a/lib/x509.py b/lib/x509.py
       t@@ -41,8 +41,18 @@ from pyasn1_modules.rfc2459 import id_at_organizationalUnitName as OU_NAME
        from pyasn1_modules.rfc2459 import id_ce_basicConstraints, BasicConstraints
        XMPP_ADDR = ObjectIdentifier('1.3.6.1.5.5.7.8.5')
        SRV_NAME = ObjectIdentifier('1.3.6.1.5.5.7.8.7')
       +
       +# algo OIDs
        ALGO_RSA_SHA1 = ObjectIdentifier('1.2.840.113549.1.1.5')
        ALGO_RSA_SHA256 = ObjectIdentifier('1.2.840.113549.1.1.11')
       +ALGO_RSA_SHA384 = ObjectIdentifier('1.2.840.113549.1.1.12')
       +ALGO_RSA_SHA512 = ObjectIdentifier('1.2.840.113549.1.1.13')
       +
       +# prefixes, see http://stackoverflow.com/questions/3713774/c-sharp-how-to-calculate-asn-1-der-encoding-of-a-particular-hash-algorithm
       +PREFIX_RSA_SHA256 = bytearray([0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20])
       +PREFIX_RSA_SHA384 = bytearray([0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30])
       +PREFIX_RSA_SHA512 = bytearray([0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40])
       +
        
        class CertificateError(Exception):
            pass