コード例 #1
0
		public KdfParameters(PwUuid puKdf)
		{
			if(puKdf == null) throw new ArgumentNullException("puKdf");

			m_puKdf = puKdf;
			SetByteArray(ParamUuid, puKdf.UuidBytes);
		}
コード例 #2
0
ファイル: CipherPool.cs プロジェクト: dbremner/keepass2
		/// <summary>
		/// Get a cipher identified by its UUID.
		/// </summary>
		/// <param name="uuidCipher">UUID of the cipher to return.</param>
		/// <returns>Reference to the requested cipher. If the cipher is
		/// not found, <c>null</c> is returned.</returns>
		public ICipherEngine GetCipher(PwUuid uuidCipher)
		{
			foreach(ICipherEngine iEngine in m_vCiphers)
			{
				if(iEngine.CipherUuid.Equals(uuidCipher))
					return iEngine;
			}

			return null;
		}
コード例 #3
0
ファイル: KdfPool.cs プロジェクト: joshuadugie/KeePass-2.x
		public static KdfEngine Get(PwUuid pu)
		{
			if(pu == null) { Debug.Assert(false); return null; }

			EnsureInitialized();

			foreach(KdfEngine kdf in g_l)
			{
				if(pu.Equals(kdf.Uuid)) return kdf;
			}

			return null;
		}
コード例 #4
0
        private void SetLoginHandler(Request r, Response resp, Aes aes)
        {
            if (!VerifyRequest(r, aes))
            {
                return;
            }

            string url     = CryptoTransform(r.Url, true, false, aes, CMode.DECRYPT);
            var    urlHost = GetHost(url);

            PwUuid uuid = null;
            string username, password, name = null, group = null;

            username = CryptoTransform(r.Login, true, false, aes, CMode.DECRYPT);
            password = CryptoTransform(r.Password, true, false, aes, CMode.DECRYPT);

            if (r.Name != null)
            {
                name = CryptoTransform(r.Name, true, false, aes, CMode.DECRYPT);
            }

            if (r.GroupName != null)
            {
                group = CryptoTransform(r.GroupName, true, false, aes, CMode.DECRYPT);
            }

            if (r.Uuid != null)
            {
                uuid = new PwUuid(MemUtil.HexStringToByteArray(
                                      CryptoTransform(r.Uuid, true, false, aes, CMode.DECRYPT)));
            }

            if (uuid != null)
            {
                // modify existing entry
                resp.Success = UpdateEntry(uuid, username, password, urlHost, r.Id, group, name);
            }
            else
            {
                // create new entry
                resp.Success = CreateEntry(username, password, urlHost, url, r, aes, group, name);
            }

            resp.Id = r.Id;
            SetResponseVerifier(resp, aes);
        }
コード例 #5
0
ファイル: TsrPool.cs プロジェクト: ajeebkp23/KeePass2.x
        private static TsrFactory GetFactory(PwUuid u)
        {
            if (u == null)
            {
                Debug.Assert(false); return(null);
            }

            foreach (TsrFactory f in TsrPool.Factories)
            {
                if (u.Equals(f.Uuid))
                {
                    return(f);
                }
            }

            return(null);
        }
コード例 #6
0
        public PwEntryViewModel FindEntryInGroup(PwUuid uuid)
        {
            var entry = Entries.FirstOrDefault(e => e.Model.Uuid.Equals(uuid));

            if (entry == null)
            {
                foreach (var group in Groups)
                {
                    entry = group.FindEntryInGroup(uuid);
                    if (entry != null)
                    {
                        break;
                    }
                }
            }
            return(entry);
        }
コード例 #7
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (AppTask.TryGetFromActivityResult(data, ref AppTask))
            {
                //make sure the app task is passed to the calling activity
                AppTask.SetActivityResult(this, KeePass.ExitNormal);
            }

            if ((GroupEditActivity.RequestCodeGroupEdit == requestCode) && (resultCode == Result.Ok))
            {
                String groupName         = data.Extras.GetString(GroupEditActivity.KeyName);
                int    groupIconId       = data.Extras.GetInt(GroupEditActivity.KeyIconId);
                PwUuid groupCustomIconId =
                    new PwUuid(MemUtil.HexStringToByteArray(data.Extras.GetString(GroupEditActivity.KeyCustomIconId)));
                String            strGroupUuid = data.Extras.GetString(GroupEditActivity.KeyGroupUuid);
                GroupBaseActivity act          = this;
                Handler           handler      = new Handler();
                RunnableOnFinish  task;
                if (strGroupUuid == null)
                {
                    task = AddGroup.GetInstance(this, App.Kp2a, groupName, groupIconId, groupCustomIconId, Group, new RefreshTask(handler, this), false);
                }
                else
                {
                    PwUuid groupUuid = new PwUuid(MemUtil.HexStringToByteArray(strGroupUuid));
                    task = new EditGroup(this, App.Kp2a, groupName, (PwIcon)groupIconId, groupCustomIconId, App.Kp2a.GetDb().Groups[groupUuid],
                                         new RefreshTask(handler, this));
                }
                ProgressTask pt = new ProgressTask(App.Kp2a, act, task);
                pt.Run();
            }

            if (resultCode == KeePass.ExitCloseAfterTaskComplete)
            {
                AppTask.SetActivityResult(this, KeePass.ExitCloseAfterTaskComplete);
                Finish();
            }

            if (resultCode == KeePass.ExitReloadDb)
            {
                AppTask.SetActivityResult(this, KeePass.ExitReloadDb);
                Finish();
            }
        }
コード例 #8
0
        public override ParcelFileDescriptor OpenFile(Android.Net.Uri uri, string mode)
        {
            switch ((UriMatches)UriMatcher.Match(uri))
            {
            case UriMatches.GetIcon:
                var iconId         = (PwIcon)Enum.Parse(typeof(PwIcon), uri.GetQueryParameter(IconIdParameter));
                var customIconUuid = new PwUuid(MemUtil.HexStringToByteArray(uri.GetQueryParameter(CustomIconUuidParameter)));

                var iconDrawable = _db.DrawableFactory.GetIconDrawable(App.Context, _db.KpDatabase, iconId, customIconUuid, false) as BitmapDrawable;
                if (iconDrawable != null)
                {
                    var pipe      = ParcelFileDescriptor.CreatePipe();
                    var outStream = new OutputStreamInvoker(new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]));

                    ThreadPool.QueueUserWorkItem(state =>
                    {
                        var original        = iconDrawable.Bitmap;
                        Bitmap copy         = Bitmap.CreateBitmap(original.Width, original.Height, original.GetConfig());
                        Canvas copiedCanvas = new Canvas(copy);
                        copiedCanvas.DrawBitmap(original, 0f, 0f, null);

                        var bitmap           = copy;
                        float maxSize        = convertDpToPixel(60, App.Context);
                        float scale          = Math.Min(maxSize / bitmap.Width, maxSize / bitmap.Height);
                        var scaleWidth       = (int)(bitmap.Width * scale);
                        var scaleHeight      = (int)(bitmap.Height * scale);
                        var scaledBitmap     = Bitmap.CreateScaledBitmap(bitmap, scaleWidth, scaleHeight, true);
                        Bitmap newRectBitmap = Bitmap.CreateBitmap((int)maxSize, (int)maxSize, Bitmap.Config.Argb8888);

                        Canvas c = new Canvas(newRectBitmap);
                        c.DrawBitmap(scaledBitmap, (maxSize - scaledBitmap.Width) / 2.0f, (maxSize - scaledBitmap.Height) / 2.0f, null);
                        bitmap = newRectBitmap;
                        bitmap.Compress(Bitmap.CompressFormat.Png, 100, outStream);
                        outStream.Close();
                    });

                    return(pipe[0]);
                }

                // Couldn't get an icon for some reason.
                return(null);

            default:
                throw new ArgumentException("Unknown Uri: " + uri, "uri");
            }
        }
コード例 #9
0
        public EcasEventType Find(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            foreach (EcasEventType t in m_events)
            {
                if (t.Type.EqualsValue(uuid))
                {
                    return(t);
                }
            }

            return(null);
        }
コード例 #10
0
        public CustomPwGenerator Find(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            foreach (CustomPwGenerator pwg in m_vGens)
            {
                if (uuid.Equals(pwg.Uuid))
                {
                    return(pwg);
                }
            }

            return(null);
        }
コード例 #11
0
ファイル: App.cs プロジェクト: Arushacked/keepass2
 public IStructureItem FindStructureItem(PwUuid uuid)
 {
     foreach (Database db in OpenDatabases)
     {
         PwGroup resultGroup;
         if (db.GroupsById.TryGetValue(uuid, out resultGroup))
         {
             return(resultGroup);
         }
         PwEntry resultEntry;
         if (db.EntriesById.TryGetValue(uuid, out resultEntry))
         {
             return(resultEntry);
         }
     }
     return(null);
 }
コード例 #12
0
        internal static int FindIndex(PwUuid uuid, List <CustomPwGenerator> customPwGenerators)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            for (int i = 0; i < customPwGenerators.Count; ++i)
            {
                if (uuid.EqualsValue(customPwGenerators[i].Uuid))
                {
                    return(i);
                }
            }

            return(-1);
        }
コード例 #13
0
ファイル: EcasActionProvider.cs プロジェクト: zforks/KeeThief
        public bool IsSupported(PwUuid uuidType)
        {
            if (uuidType == null)
            {
                throw new ArgumentNullException("uuidType");
            }

            foreach (EcasActionType t in m_actions)
            {
                if (t.Type.Equals(uuidType))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #14
0
        public IStructureItem GetItemByUuid(PwUuid pwUuid)
        {
            if (pwUuid == null)
            {
                Debug.Assert(false); return(null);
            }

            ulong uId;

            if (!m_dUuidToId.TryGetValue(pwUuid, out uId))
            {
                return(null);
            }
            Debug.Assert(uId != 0);

            return(GetItemById(uId));
        }
コード例 #15
0
        /// <summary>
        /// Find the entry referenced by the given uuid
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public PwEntryViewModel FindEntryByUid(string uuidString)
        {
            PwUuid uuid = new PwUuid(MemUtil.HexStringToByteArray(uuidString));

            PwEntryViewModel entry = null;

            foreach (var groupVM in Groups)
            {
                entry = groupVM.FindEntryInGroup(uuid);
                if (entry != null)
                {
                    break;
                }
            }

            return(entry);
        }
コード例 #16
0
ファイル: EcasActionProvider.cs プロジェクト: zforks/KeeThief
        public EcasActionType Find(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            foreach (EcasActionType t in m_actions)
            {
                if (t.Type.Equals(uuid))
                {
                    return(t);
                }
            }

            return(null);
        }
コード例 #17
0
		public static KdfParameters DeserializeExt(byte[] pb)
		{
			VariantDictionary d = VariantDictionary.Deserialize(pb);
			if(d == null) { Debug.Assert(false); return null; }

			byte[] pbUuid = d.GetByteArray(ParamUuid);
			if((pbUuid == null) || (pbUuid.Length != (int)PwUuid.UuidSize))
			{
				Debug.Assert(false);
				return null;
			}

			PwUuid pu = new PwUuid(pbUuid);
			KdfParameters p = new KdfParameters(pu);
			d.CopyTo(p);
			return p;
		}
コード例 #18
0
        private int FindIndex(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            for (int i = 0; i < m_vGens.Count; ++i)
            {
                if (uuid.Equals(m_vGens[i].Uuid))
                {
                    return(i);
                }
            }

            return(-1);
        }
コード例 #19
0
        public bool Remove(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            int nIndex = FindIndex(uuid);

            if (nIndex < 0)
            {
                return(false);
            }

            m_vGens.RemoveAt(nIndex);
            return(true);
        }
コード例 #20
0
        internal static PwGroup GetTemplatesGroup(PwDatabase pdIn)
        {
            PwDatabase pd = (pdIn ?? Program.MainForm.ActiveDatabase);

            if ((pd == null) || !pd.IsOpen)
            {
                Debug.Assert(false); return(null);
            }

            PwUuid pu = pd.EntryTemplatesGroup;

            if (pu.Equals(PwUuid.Zero))
            {
                return(null);
            }

            return(pd.RootGroup.FindGroup(pu, true));
        }
コード例 #21
0
        private PwEntry GetConfigEntry(bool create)
        {
            var root  = _host.Database.RootGroup;
            var uuid  = new PwUuid(YandexDiskSyncUuid);
            var entry = root.FindEntry(uuid, false);

            if (entry == null && create)
            {
                entry = new PwEntry(false, true)
                {
                    Uuid = uuid
                };
                entry.Strings.Set(PwDefs.TitleField, new ProtectedString(false, YandexDiskSyncName));
                root.AddEntry(entry, true);
                UpdateUI(null);
            }
            return(entry);
        }
コード例 #22
0
ファイル: Options.cs プロジェクト: Aldaviva/WebAutoType
            public GroupComboItem(IPluginHost host, int indentLevel, PwGroup group)
            {
                if (group.CustomIconUuid.Equals(PwUuid.Zero))
                {
                    mImage = host.MainWindow.ClientIcons.Images[(int)group.IconId];
                }
                else
                {
                    mImage = GetCustomIcon(host.Database, group.CustomIconUuid);
                }

                mIndentPosition = indentLevel * mImage.Width;
                mTextPosition   = mIndentPosition + mImage.Width + 2;

                mText = group.Name;

                mUuid = group.Uuid;
            }
コード例 #23
0
        private static int MenuGetImageIndex(PwDocument ds, PwIcon pwID,
                                             PwUuid pwCustomID)
        {
            if (!pwCustomID.Equals(PwUuid.Zero) && (ds ==
                                                    Program.MainForm.DocumentManager.ActiveDocument))
            {
                return((int)PwIcon.Count +
                       Program.MainForm.DocumentManager.ActiveDatabase.GetCustomIconIndex(
                           pwCustomID));
            }

            if ((int)pwID < (int)PwIcon.Count)
            {
                return((int)pwID);
            }

            return((int)PwIcon.Key);
        }
コード例 #24
0
ファイル: EcasPool.cs プロジェクト: matt2005/keepass2
        public EcasActionType FindAction(PwUuid uuid)
        {
            if (uuid == null)
            {
                throw new ArgumentNullException("uuid");
            }

            foreach (EcasActionProvider p in m_vActionProviders)
            {
                EcasActionType t = p.Find(uuid);
                if (t != null)
                {
                    return(t);
                }
            }

            return(null);
        }
コード例 #25
0
ファイル: KdfPool.cs プロジェクト: 77rusa/README
        public static KdfEngine Get(PwUuid pu)
        {
            if (pu == null)
            {
                Debug.Assert(false); return(null);
            }

            EnsureInitialized();

            foreach (KdfEngine kdf in g_l)
            {
                if (pu.Equals(kdf.Uuid))
                {
                    return(kdf);
                }
            }

            return(null);
        }
コード例 #26
0
ファイル: KeePassRPCExt.cs プロジェクト: icts-ca/keepassrpc
        /// <summary>
        /// Gets the kee group and renames it from KeeFox if necessary.
        /// </summary>
        /// <param name="pd">The database</param>
        /// <returns>The Kee group or the root group if the group does not exist</returns>
        internal PwGroup GetKeeGroup(PwDatabase pd)
        {
            PwUuid groupUuid = new PwUuid(new byte[] {
                0xea, 0x9f, 0xf2, 0xed, 0x05, 0x12, 0x47, 0x47,
                0xb6, 0x3e, 0xaf, 0xa5, 0x15, 0xa3, 0x04, 0x23
            });

            PwGroup kfpg = pd.RootGroup.FindGroup(groupUuid, true);

            if (kfpg == null)
            {
                return(pd.RootGroup);
            }
            else if (kfpg.Name == "KeeFox")
            {
                kfpg.Name = "Kee";
            }
            return(kfpg);
        }
コード例 #27
0
        // Strangely, there doesn't appear to already exist a helper to get an image for a group. If one appears, then that should be used instead of this custom one.
        private Image GetImage(PwUuid customIconId, PwIcon iconId)
        {
            Image image = null;

            if (Database != null)
            {
                if (!customIconId.EqualsValue(PwUuid.Zero))
                {
                    image = Database.GetCustomIcon(customIconId);
                }
                if (image == null)
                {
                    try { image = mMainForm.ClientIcons.Images[(int)iconId]; }
                    catch (Exception) { Debug.Assert(false); }
                }
            }

            return(image);
        }
コード例 #28
0
        /// <summary>
        /// Delete every entry in the target group.
        /// </summary>
        /// <param name="sourceGroups">Collection of groups which counterparts should be deleted in the target database.</param>
        /// <param name="targetDatabase">The target database in which the folder structure should be created.</param>
        private static void DeleteTargetGroupsInDatabase(IEnumerable <PwGroup> sourceGroups, PwDatabase targetDatabase)
        {
            foreach (PwGroup sourceGroup in sourceGroups)
            {
                // Get the target group ID based
                PwUuid  groupId     = sourceGroup.Uuid;
                PwGroup targetGroup = targetDatabase.RootGroup.FindGroup(groupId, false);

                // If group exists in target database, delete its entries, otherwise show a warning
                if (targetGroup != null)
                {
                    targetGroup.DeleteAllObjects(targetDatabase);
                }
                else
                {
                    MessageService.ShowWarning("Group not found in target database. OverrideEntireGroup will not work");
                }
            }
        }
コード例 #29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _activityDesign.ApplyTheme();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ImageViewActivity);

            ElementAndDatabaseId fullId = new ElementAndDatabaseId(Intent.GetStringExtra("EntryId"));

            var    uuid   = new PwUuid(MemUtil.HexStringToByteArray(fullId.ElementIdString));
            string key    = Intent.GetStringExtra("EntryKey");
            var    binary = App.Kp2a.GetDatabase(fullId.DatabaseId).EntriesById[uuid].Binaries.Get(key);

            SupportActionBar.Title = key;
            byte[] pbdata = binary.ReadData();

            var bmp = BitmapFactory.DecodeByteArray(pbdata, 0, pbdata.Length);

            FindViewById <ImageView>(Resource.Id.imageView).SetImageBitmap(bmp);
        }
コード例 #30
0
        public void RaiseEvent(PwUuid eventType, EcasPropertyDictionary props)
        {
            if (eventType == null)
            {
                throw new ArgumentNullException("eventType");
            }
            // if(props == null) throw new ArgumentNullException("props");

            if (!m_bEnabled)
            {
                return;
            }

            EcasEvent e = new EcasEvent();

            e.Type = eventType;

            RaiseEventObj(e, (props ?? new EcasPropertyDictionary()));
        }
コード例 #31
0
        public EcasConditionType(PwUuid uuidType, string strName, PwIcon pwIcon,
                                 EcasParameter[] vParams, EcasConditionEvaluate f)
        {
            if ((uuidType == null) || PwUuid.Zero.Equals(uuidType))
            {
                throw new ArgumentNullException("uuidType");
            }
            if (strName == null)
            {
                throw new ArgumentNullException("strName");
            }
            // if(vParams == null) throw new ArgumentNullException("vParams");
            // if(f == null) throw new ArgumentNullException("f");

            m_type    = uuidType;
            m_strName = strName;
            m_pwIcon  = pwIcon;
            m_vParams = (vParams ?? EcasParameter.EmptyArray);
            m_fn      = (f ?? EcasConditionEvaluateTrue);
        }
コード例 #32
0
ファイル: TsrPool.cs プロジェクト: doctorw/KeePassC
        public static bool RemoveFactory(PwUuid u)
        {
            if (u == null)
            {
                Debug.Assert(false); return(false);
            }

            List <TsrFactory> l = TsrPool.Factories;
            int cInitial        = l.Count;

            for (int i = l.Count - 1; i >= g_nStdFac; --i)
            {
                if (u.Equals(l[i].Uuid))
                {
                    l.RemoveAt(i);
                }
            }

            return(l.Count != cInitial);
        }
コード例 #33
0
        public object FindObjectByUuid(PwUuid pwUuid)
        {
            if (pwUuid == null)
            {
                throw new ArgumentNullException("pwUuid");
            }

            foreach (EcasTrigger t in m_vTriggers)
            {
                if (t.Uuid.EqualsValue(pwUuid))
                {
                    return(t);
                }

                foreach (EcasEvent e in t.EventCollection)
                {
                    if (e.Type.EqualsValue(pwUuid))
                    {
                        return(e);
                    }
                }

                foreach (EcasCondition c in t.ConditionCollection)
                {
                    if (c.Type.EqualsValue(pwUuid))
                    {
                        return(c);
                    }
                }

                foreach (EcasAction a in t.ActionCollection)
                {
                    if (a.Type.EqualsValue(pwUuid))
                    {
                        return(a);
                    }
                }
            }

            return(null);
        }
コード例 #34
0
        public override void StartInGroupActivity(GroupBaseActivity groupBaseActivity)
        {
            base.StartInGroupActivity(groupBaseActivity);

            if (GroupIsFound(groupBaseActivity))               // Group has been found: display toaster and stop here

            {
                if (ToastEnable)
                {
                    String toastMessage = groupBaseActivity.GetString(Resource.String.NavigationToGroupCompleted_message, new Java.Lang.Object[] { FullGroupName });

                    Toast.MakeText(groupBaseActivity, toastMessage, ToastLength.Long).Show();
                }

                groupBaseActivity.StartTask(TaskToBeLaunchedAfterNavigation);
                return;
            }
            else if (_groupUuid.Contains(groupBaseActivity.UuidGroup))                 // Need to go up in groups tree

            // Get next Group Uuid
            {
                var linkedListNode = _groupUuid.Find(groupBaseActivity.UuidGroup);
                if (linkedListNode != null)
                {
                    //Note: Resharper says there is a possible NullRefException.
                    //This is not the case because it was checked above if we're already there or not.
                    String nextGroupUuid   = linkedListNode.Next.Value;
                    PwUuid nextGroupPwUuid = new PwUuid(MemUtil.HexStringToByteArray(nextGroupUuid));

                    // Create Group Activity
                    PwGroup nextGroup = App.Kp2a.GetDb().Groups [nextGroupPwUuid];
                    GroupActivity.Launch(groupBaseActivity, nextGroup, this);
                }
                return;
            }
            else                 // Need to go down in groups tree
            {
                SetActivityResult(groupBaseActivity, KeePass.ExitNormal);
                groupBaseActivity.Finish();
            }
        }
コード例 #35
0
ファイル: PwEntry.cs プロジェクト: TheAngryByrd/MetroPass
        public static PwEntry New(PwGroup parent)     
        {
            var entryTemplate = @"
                <Entry>
                    <UUID>{0}</UUID>
                    <IconID>0</IconID>
                    <Times>
                        <LastModificationTime>{1}</LastModificationTime>
                        <CreationTime>{1}</CreationTime>
                        <LastAccessTime>{1}</LastAccessTime>
                        <ExpiryTime>{1}</ExpiryTime>
                        <LocationChanged>{1}</LocationChanged>
                        <Expires>False</Expires>
                        <UsageCount>0</UsageCount>
                    </Times>
                    <String>
                        <Key>Title</Key>
                        <Value>{2}</Value>
                    </String>
                    <String>
                        <Key>UserName</Key>
                        <Value>{3}</Value>
                    </String>
                    <String>
                        <Key>Password</Key>
                        <Value Protected=""True"">{4}</Value>
                    </String>
                    <String>
                        <Key>URL</Key>
                        <Value>{5}</Value>
                    </String>
                    <String>
                        <Key>Notes</Key>
                        <Value>{6}</Value>
                    </String>
                </Entry>
            ";
            var uuid = new PwUuid(true);

            entryTemplate = String.Format(entryTemplate, 
                Convert.ToBase64String(uuid.UuidBytes), 
                DateTime.Now.ToFormattedUtcTime(), 
                Sanitize("Title"), 
                Sanitize("Username"), 
                Sanitize("Password") ,
                Sanitize("Url") , 
                Sanitize("Notes"));

            var element = XElement.Parse(entryTemplate);
            var pwEntry = new PwEntry(element,parent);
            parent.AddEntryToDocument(pwEntry);
           
            return pwEntry;
        }
コード例 #36
0
ファイル: PwObjectPool.cs プロジェクト: rdealexb/keepass
 public IStructureItem Get(PwUuid pwUuid)
 {
     IStructureItem pItem;
     m_dict.TryGetValue(pwUuid, out pItem);
     return pItem;
 }
コード例 #37
0
		public IStructureItem Get(PwUuid pwUuid)
		{
			IStructureItem pItem;
			m_dict.TryGetValue(new PwUuidComparable(pwUuid), out pItem);
			return pItem;
		}
コード例 #38
0
ファイル: CipherPool.cs プロジェクト: ashwingj/keepass2
        /// <summary>
        /// Get the index of a cipher. This index is temporary and should
        /// not be stored or used to identify a cipher.
        /// </summary>
        /// <param name="uuidCipher">UUID of the cipher.</param>
        /// <returns>Index of the requested cipher. Returns <c>-1</c> if
        /// the specified cipher is not found.</returns>
        public int GetCipherIndex(PwUuid uuidCipher)
        {
            for(int i = 0; i < m_vCiphers.Count; ++i)
            {
                if(m_vCiphers[i].CipherUuid.EqualsValue(uuidCipher))
                    return i;
            }

            Debug.Assert(false);
            return -1;
        }
コード例 #39
0
        private XElement GetNewGroupElement()
        {
            var groupTemplate = @"
                <Group>
                    <UUID>{0}</UUID>
                    <Name>{2}</Name>
                    <IconID>0</IconID>
                    <Times>
                        <LastModificationTime>{1}</LastModificationTime>
                        <CreationTime>{1}</CreationTime>
                        <LastAccessTime>{1}</LastAccessTime>
                        <ExpiryTime>{1}</ExpiryTime>
                        <LocationChanged>{1}</LocationChanged>
                        <Expires>False</Expires>
                        <UsageCount>0</UsageCount>
                    </Times>
                    <IsExpanded>True</IsExpanded>
                    <DefaultAutoTypeSequence />
                    <EnableAutoType>null</EnableAutoType>
                    <EnableSearching>null</EnableSearching>
                </Group>
            ";
            var uuid = new PwUuid(true);
            groupTemplate = String.Format(groupTemplate, Convert.ToBase64String(uuid.UuidBytes), DateTime.Now.ToFormattedUtcTime(), FolderName);

            var element = XElement.Parse(groupTemplate);
            return element;
        }
コード例 #40
0
ファイル: KdbxFile.Write.cs プロジェクト: Stoom/KeePass
        private void WriteObject(string name, PwUuid value)
        {
            Debug.Assert(name != null);
            Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value");

            WriteObject(name, Convert.ToBase64String(value.UuidBytes), false);
        }
コード例 #41
0
ファイル: PwGenerator.cs プロジェクト: riking/go-keepass2
		private static PwgError GenerateCustom(out ProtectedString psOut,
			PwProfile pwProfile, CryptoRandomStream crs,
			CustomPwGeneratorPool pwAlgorithmPool)
		{
			psOut = ProtectedString.Empty;

			Debug.Assert(pwProfile.GeneratorType == PasswordGeneratorType.Custom);
			if(pwAlgorithmPool == null) return PwgError.UnknownAlgorithm;

			string strID = pwProfile.CustomAlgorithmUuid;
			if(string.IsNullOrEmpty(strID)) { Debug.Assert(false); return PwgError.UnknownAlgorithm; }

			byte[] pbUuid = Convert.FromBase64String(strID);
			PwUuid uuid = new PwUuid(pbUuid);
			CustomPwGenerator pwg = pwAlgorithmPool.Find(uuid);
			if(pwg == null) { Debug.Assert(false); return PwgError.UnknownAlgorithm; }

			ProtectedString pwd = pwg.Generate(pwProfile.CloneDeep(), crs);
			if(pwd == null) return PwgError.Unknown;

			psOut = pwd;
			return PwgError.Success;
		}