Exemple #1
0
        public static string ReadPass(string _decryptionKeyPlain,
                                      string _fileDir,
                                      string _websiteURL,
                                      string _numOfIterations)
        {
            string ret;
            int    NumOfIterations = _numOfIterations == "" ? 0 : Convert.ToInt32(_numOfIterations); //avoid exceptions when empty

            if (_decryptionKeyPlain == "")
            {
                return("Please fill in the encryption key first");
            }
            if (NumOfIterations < CandyStore.GetParameters().MinNumOfIterationsParm)
            {
                return("Safety: Number of iterations must exceed" + Convert.ToString(CandyStore.GetParameters().MinNumOfIterationsParm));
            }

            string DecryptionKey = CandyStore.PBKDF2Service(_decryptionKeyPlain, NumOfIterations);

            try
            {
                ret = ReadPassService.ReadPass(_websiteURL, DecryptionKey, _fileDir, NumOfIterations);
            }
            catch
            {
                return("Could not read key");
            }

            return("Your pass: " + ret);
        }
Exemple #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CandyStore = await _context.CandyStore.FirstOrDefaultAsync(m => m.CSID == id);

            if (CandyStore == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CandyStore = await _context.CandyStore.FindAsync(id);

            if (CandyStore != null)
            {
                _context.CandyStore.Remove(CandyStore);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #4
0
        public static string CreatePass(string _encryptionKeyPlain,
                                        string _fileDir,
                                        string _websiteURL,
                                        string _websitePass,
                                        string _numOfIterations)
        {
            int NumOfIterations = _numOfIterations == ""? 0:Convert.ToInt32(_numOfIterations);  //avoid exceptions when empty

            if (NumOfIterations < CandyStore.GetParameters().MinNumOfIterationsParm)
            {
                return("Safety: Number of iterations must exceed" + Convert.ToString(CandyStore.GetParameters().MinNumOfIterationsParm));
            }

            if (_encryptionKeyPlain == "")
            {
                return("Please fill in the encryption key first");
            }
            if (_websiteURL == "")
            {
                return("Please fill in the website URL");
            }

            if (_websitePass == "")
            {
                return("Please fill in the website pass");
            }

            string EncryptionKey = CandyStore.PBKDF2Service(_encryptionKeyPlain, NumOfIterations);

            try
            {
                if (CreatePassService.CreatePass(_websiteURL, _websitePass, EncryptionKey, _fileDir, NumOfIterations))
                {
                    return("Pass encryption completed for website:" + _websiteURL);
                }
                else
                {
                    return("Pass encryption failed (did you allow storage permissions for this app?)");
                }
            }
            catch
            {
                return("Could not create key");
            }
        }
Exemple #5
0
        public static string RemoveStorageSpecific(string _fileDir, string _websiteURL)
        {
            string ret;

            try
            {
                string uniqueId = CandyStore.PBKDF2Service(_websiteURL, CandyStore.GetParameters().MinNumOfIterationsParm);
                uniqueId = CandyStore.ToHexString(uniqueId);

                ret = StorageHelper.RemoveStorageSpecific(_fileDir, uniqueId);
            }
            catch
            {
                return("Removal failed");
            }

            return(ret);
        }
Exemple #6
0
        public static string ReadPass(string _websiteString, string _decryptionKey, string _fileDir, int _numOfIterations)
        {
            string ret      = "";
            string uniqueId = CandyStore.PBKDF2Service(_websiteString, _numOfIterations);

            uniqueId = CandyStore.ToHexString(uniqueId);


            try
            {
                PassObject PassObject = StorageHelper.ReadBlobToObject(uniqueId, _fileDir);

                ret = EncryptDecryptStore.Decrypt(PassObject.GetEncryptedPass(), _decryptionKey);
            }
            catch
            {
                ret = "Cannot read, does this website exist as pass?";
            }

            return(ret);
        }