示例#1
0
        public void AddUser(byte[] userID)
        {
            GenericUserRepositoryCollection userreps      = userRepository.GetUserRepository(userID);
            RSAEncryptingKeyValueStorage    symmetricKeys = userreps.SymmetricKeys;

            foreach (var sk in symmetricKeys)
            {
                if (!permanentStorage.ContainsKey(sk.Key))
                {
                    //#warning SO WRONG
                    foreach (var cr in crs)                      //this is sooooooooooo wrong because ih creates unnecessary KVSs in unrelated DBs
                    {
                        permanentStorage.Add(sk.Key, new AESEncryptingKeyValueStorage(cr.LencryptedData [sk.Key], sk.Value));
                    }
                }
            }
        }
示例#2
0
 public void AddChunkRepository(ChunkRepository chunkRepository)
 {
     crs.Add(chunkRepository);
     if (chunkRepository == null)
     {
         throw new ArgumentNullException("chunkRepository");
     }
     foreach (var user in userRepository.LoggedInUsers)
     {
         GenericUserRepositoryCollection userreps      = userRepository.GetUserRepository(user);
         RSAEncryptingKeyValueStorage    symmetricKeys = userreps.SymmetricKeys;
         foreach (var sk in symmetricKeys)
         {
             if (!permanentStorage.ContainsKey(sk.Key))
             {
                 permanentStorage.Add(sk.Key, new AESEncryptingKeyValueStorage(chunkRepository.LencryptedData [sk.Key], sk.Value));
             }
         }
     }
 }
示例#3
0
        public byte[] CreateNewKey(byte[][] userIDs)
        {
            Aes aes = Aes.Create();

            aes.GenerateKey();
            byte[] keyBytes = aes.Key;
            byte[] keyID    = keyBytes.SHA256();
            //TODO: create AES KEY, intern it for all logged in users; sign it with the same users; RSA encrypt it for the users
            foreach (var u in userRepository.LoggedInUsers)
            {
                GenericUserRepositoryCollection ur = userRepository.GetUserRepository(u);
                ur.SymmetricKeys.Put(keyID, keyBytes);
            }
            foreach (var u in userIDs)
            {
                if (!userRepository.LoggedInUsers.Contains(u))
                {
                    GenericUserRepositoryCollection ur = userRepository.GetUserRepository(u);
                    ur.SymmetricKeys.Put(keyID, keyBytes);
                }
            }

            return(keyID);
        }