Ejemplo n.º 1
0
 def import_publickeyblob(cls, data):
     rsapubkey = RSAPUBKEY._make(RSAPUBKEY_s.unpack_from(data))
     assert rsapubkey.magic == RSAPUBKEY_MAGIC
     bitlen8 = rsapubkey.bitlen // 8
     modulus = bytes_to_long(data[12:12 + bitlen8][::-1])
     r = RSA.construct((modulus, long(rsapubkey.pubexp)))
     return cls(r)
Ejemplo n.º 2
0
 def import_publickeyblob(cls, data):
     rsapubkey = RSAPUBKEY._make(RSAPUBKEY_s.unpack_from(data))
     assert rsapubkey.magic == RSAPUBKEY_MAGIC
     bitlen8 = rsapubkey.bitlen // 8
     modulus = bytes_to_long(data[12:12 + bitlen8][::-1])
     r = RSA.construct((modulus, long(rsapubkey.pubexp)))
     return cls(r)
Ejemplo n.º 3
0
    def import_privatekeyblob(cls, data):
        rsapubkey = RSAPUBKEY._make(RSAPUBKEY_s.unpack_from(data))
        assert rsapubkey.magic == PRIVATEKEYBLOB_MAGIC
        bitlen8 = rsapubkey.bitlen / 8
        bitlen16 = rsapubkey.bitlen / 16
        privatekeyblob_s = struct.Struct(
            '%ds%ds%ds%ds%ds%ds%ds' % (bitlen8, bitlen16, bitlen16, bitlen16, bitlen16, bitlen16, bitlen8))
        privatekey = PRIVATEKEYBLOB._make(bytes_to_long(x[::-1]) for x in privatekeyblob_s.unpack_from(data[12:]))

        r = RSA.construct((privatekey.modulus, long(rsapubkey.pubexp), privatekey.privateExponent,
                           privatekey.prime1, privatekey.prime2))
        return cls(r)