Пример #1
0
 def encrypt(self, pk, M, object):
     key = self.group.random(GT)
     c1 = abenc.encrypt(pk, key, object)
     # instantiate a symmetric enc scheme from this key
     cipher = AuthenticatedCryptoAbstraction(sha1(key))
     c2 = cipher.encrypt(M)
     return { 'c1':c1, 'c2':c2 }
Пример #2
0
 def encrypt(self, pk, gp, M, policy_str):
     if type(M) != str and type(policy_str) != str: raise "message and policy not right type!"        
     key = group.random(GT)
     c1 = abencma.encrypt(pk, gp, key, policy_str)
     # instantiate a symmetric enc scheme from this key
     cipher = AuthenticatedCryptoAbstraction(sha1(key)) 
     c2 = cipher.encrypt(M)
     return { 'c1':c1, 'c2':c2 }
Пример #3
0
 def encrypt(self, pk, ID, M):
     if type(M) != str: raise "message not right type!"        
     key = group.random(GT)
     c1 = ibenc.encrypt(pk, ID, key)
     # instantiate a symmetric enc scheme from this key
     cipher = AuthenticatedCryptoAbstraction(sha1(key))
     c2 = cipher.encrypt(M)
     return { 'c1':c1, 'c2':c2 }
Пример #4
0
 def decrypt(self, pk, sk, ct):
     c1, c2 = ct['c1'], ct['c2']
     key = self.pkenc.decrypt(pk, sk, c1)[:self.key_len]
     if debug: print("Rec key =>", key,", len =", len(key))
     cipher = AuthenticatedCryptoAbstraction(key)
     msg = cipher.decrypt(c2)
     if debug: print("Rec msg =>", msg)
     return msg
Пример #5
0
 def encrypt(self, pk, M):
     # generate a short session key, K and encrypt using pkenc
     key = urandom(self.key_len)
     # encrypt session key using PKEnc
     c1 = self.pkenc.encrypt(pk, key)
     # use symmetric key encryption to enc actual message
     cipher = AuthenticatedCryptoAbstraction(key)
     c2 = cipher.encrypt(M)
     if debug: print("Ciphertext 2...")
     if debug: print(c2)
     return { 'c1':c1, 'c2':c2 }
Пример #6
0
 def decrypt(self, gp, sk, ct):
     c1, c2 = ct['c1'], ct['c2']
     key = abencma.decrypt(gp, sk, c1)
     cipher = AuthenticatedCryptoAbstraction(sha1(key))
     return cipher.decrypt(c2)
Пример #7
0
 def decrypt(self, pk, ID, ct):
     c1, c2 = ct['c1'], ct['c2']
     key = ibenc.decrypt(pk, ID, c1)        
     cipher = AuthenticatedCryptoAbstraction(sha1(key))
     return cipher.decrypt(c2)
Пример #8
0
def SymEnc(s2_sesskey, M):
    getUserGlobals()
    cipher = AuthenticatedCryptoAbstraction(s2_sesskey)
    return cipher.encrypt(M)
Пример #9
0
def SymDec(s2_sesskey, T1):
    getUserGlobals()
    cipher = AuthenticatedCryptoAbstraction(s2_sesskey)
    return cipher.decrypt(T1)
Пример #10
0
def SymEnc(s2_sesskey, M):
	getUserGlobals()
	cipher = AuthenticatedCryptoAbstraction(s2_sesskey)
	return cipher.encrypt(M) 
Пример #11
0
def SymDec(s2_sesskey, T1):
	getUserGlobals()
	cipher = AuthenticatedCryptoAbstraction(s2_sesskey)
	return cipher.decrypt(T1)
Пример #12
0
 def decrypt(self, ct, sk):
     c1, c2 = ct["c1"], ct["c2"]
     key = abenc.decrypt(c1, sk)
     cipher = AuthenticatedCryptoAbstraction(sha1(key))
     return cipher.decrypt(c2)