Пример #1
0
 def instantiateCipher(self, mode, message):
     self.alg, self.key_len = AES, 16
     # hash GT msg into a hex string
     key = sha1(message)[0:self.key_len]
     iv = '6543210987654321'  # static IV (for testing)
     PRP_method = selectPRP(self.alg, (key, mode, iv))
     return PRP_method
 def getPRP(self, message):
     self.mode, self.key_len = AES, 16
     # hash GT msg into a hex string
     key = sha1(message)[0:self.key_len]
     iv = '6543210987654321'  # static IV (for testing)
     PRP_method = selectPRP(AES, (key, MODE_CBC, iv))
     return PRP_method
Пример #3
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 }
Пример #4
0
 def instantiateCipher(self, mode, message):
     self.alg, self.key_len = AES, 16
     # hash GT msg into a hex string
     key = sha1(message)[0:self.key_len]
     iv  = '6543210987654321' # static IV (for testing)    
     PRP_method = selectPRP(self.alg, (key, mode, iv))        
     return PRP_method
 def getPRP(self, message):
     self.mode, self.key_len = AES, 16
     # hash GT msg into a hex string
     key = sha1(message)[0:self.key_len]
     iv  = '6543210987654321' # static IV (for testing)    
     PRP_method = selectPRP(AES, (key, MODE_CBC, iv))        
     return PRP_method
Пример #6
0
 def elmtToString(self, g, length):
     hash_len = 20
     b = math.ceil(length / hash_len)
     gStr = b""
     for i in range(1, b + 1):
         gStr += sha1(g, i)
     return gStr[:length]
Пример #7
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 }
Пример #8
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 }
Пример #9
0
 def keyenc(self, params, ID, msg):
     s = group.random()
     A = sha1(params['v'] ** s) # session key
     B = params['Y'] ** s
     C = (params['X'] ** s) * (params['g'] ** (s * ID))
     # use prf here?
     ciph = { 'B': B, 'C': C }
     return (A, ciph) # user must destroy A since it protects the msg
Пример #10
0
 def keyenc(self, params, ID, msg):
     s = group.random()
     A = sha1(params['v']**s)  # session key
     B = params['Y']**s
     C = (params['X']**s) * (params['g']**(s * ID))
     # use prf here?
     ciph = {'B': B, 'C': C}
     return (A, ciph)  # user must destroy A since it protects the msg
Пример #11
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)
Пример #12
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)
Пример #13
0
 def keydec(self, pk, dID, CT):
     A, B, C = CT['A'], CT['B'], CT['C']
     v_s = pair(((B ** dID['r']) * C), dID['K'])
     return sha1(v_s)
Пример #14
0
 def keydec(self, pk, dID, CT):
     A, B, C = CT['A'], CT['B'], CT['C']
     v_s = pair(((B**dID['r']) * C), dID['K'])
     return sha1(v_s)
Пример #15
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)