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); }
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); }
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; } }