Beispiel #1
0
 def __init__(self, d):
     if isinstance(d, int) or isinstance(d, long):
         self.value = d
         self.bytes = crypto.i2b(d)
         return
     if isinstance(d, basestring):
         stream = io.BytesIO(d)
     elif isinstance(d, io.BytesIO):
         stream = d
     bits = crypto.b2i(stream.read(2))
     mpiBytes = int(math.ceil(float(bits) / 8))
     self.bytes = stream.read(mpiBytes)
     self.value = crypto.b2i(self.bytes)
Beispiel #2
0
 def computeSignature(self, secretKeyMessage):
     """
     Compute self signature
     """        
     key = secretKeyMessage.packets[SecretKeyPacket.TAG]
     m = encoding.hashEncode(self.hashdata(),
                             key.n.bits() - 1,
                             crypto.HASH_SHA256, encoding.ENCODING_PKCSPSS)
     s = crypto.rsaSign(crypto.b2i(m), key.d.value, key.n.value)
     self.signature = MPIElement(s)
Beispiel #3
0
 def __init__(self, d):
     self.value = 0
     if isinstance(d, basestring):
         self.value = crypto.b2i(d)
     elif isinstance(d, int) or isinstance(d, long):
         self.value = d