示例#1
0
 public AesManaged GetAesManaged()
 {
     if (aesManaged == null)
     {
         aesManaged     = new AesManaged();
         aesManaged.IV  = KeySerializer.StringToByteArray(IV);
         aesManaged.Key = KeySerializer.StringToByteArray(Key);
     }
     return(aesManaged);
 }
示例#2
0
        public async Task <byte[]> GetCombinedSecret(List <IAuthenticatedShareHolder> authenticatedShareHolders, SecureString hsmSecret, int electionId)
        {
            using (var initializedHsm = await hsmFactory.GetHsm(hsmSecret))
            {
                var availableShares = new List <string>();
                foreach (var shareHolder in authenticatedShareHolders)
                {
                    var shares = DeserializeShares(await shareHolder.GetShares());
                    availableShares.AddRange(shares);
                }

                var combinedSecret     = SecretCombiner.Combine(availableShares);
                var byteArrayKey       = KeySerializer.StringToByteArray(combinedSecret.RecoveredTextString);
                var decryptedSecretKey = initializedHsm.Decrypt(centralDbRepository.GetMasterKeyHandle(electionId), byteArrayKey);
                return(decryptedSecretKey);
            }
        }