Exemplo n.º 1
0
        private static byte[] ReencryptToUser(User user, byte[] value)
        {
            if (user.DelegationToken != null)   // can be null if user is DO, then just return the original ciphertext
            {
                IPreService preProxy = CreatePreProxy();
                return(preProxy.Reencrypt(user.DelegationToken.ToUser, value));
            }

            return(value);
        }
Exemplo n.º 2
0
        private DataEntity ReencryptDataEntityMetadata(DataEntity dataEntity, Guid userId)
        {
            byte[] delegationKey = GetDelegationKey(userId);

            DataEntity  reencryptedEntity = new DataEntity();
            IPreService proxy             = CreatePreProxy();

            byte[] reencryptedIV = proxy.Reencrypt(delegationKey, dataEntity.AesInfo.IV);

            proxy = CreatePreProxy();
            byte[] reencryptedKey = proxy.Reencrypt(delegationKey, dataEntity.AesInfo.Key);

            reencryptedEntity.AesInfo    = new AesEncryptionInfo(reencryptedKey, reencryptedIV);
            reencryptedEntity.Attributes = dataEntity.Attributes;
            reencryptedEntity.Payload    = dataEntity.Payload;
            reencryptedEntity.Id         = dataEntity.Id;

            return(reencryptedEntity);
        }
Exemplo n.º 3
0
 public byte[] Reencrypt(byte[] delegationKey, byte[] cipherText)
 {
     try
     {
         IPreService proxy = CreateProxy();
         return(proxy.Reencrypt(delegationKey, cipherText));
     }
     catch (Exception e)
     {
         Logger.LogError("Error reencrypting", e);
         throw;
     }
 }