コード例 #1
0
ファイル: PgpUser.cs プロジェクト: 1hub/springburg
        public static PgpUser AddCertification(PgpUser user, PgpKey publicKey, PgpSignature signature)
        {
            var newUser = new PgpUser(user, publicKey);

            newUser.AddCertification(publicKey, signature);
            return(newUser);
        }
コード例 #2
0
ファイル: PgpKey.cs プロジェクト: 1hub/springburg
        /// <summary>Add a certification for the given UserAttributeSubpackets to the given public key.</summary>
        /// <param name="key">The key the certification is to be added to.</param>
        /// <param name="userAttributes">The attributes the certification is associated with.</param>
        /// <param name="certification">The new certification.</param>
        /// <returns>The re-certified key.</returns>
        public static TKey AddCertification <TKey>(
            TKey key,
            PgpUserAttributes userAttributes,
            PgpCertification certification)
            where TKey : PgpKey
        {
            var returnKey = (TKey)key.CreateMutableCopy();

            Debug.Assert(certification.PublicKey.KeyId == key.KeyId);

            for (int i = 0; i < returnKey.ids.Count; i++)
            {
                if (returnKey.ids[i].UserAttributes?.Equals(userAttributes) == true)
                {
                    returnKey.ids[i] = PgpUser.AddCertification(returnKey.ids[i], returnKey, certification.Signature);
                    return(returnKey);
                }
            }

            returnKey.ids.Add(new PgpUser(new UserAttributePacket(userAttributes.ToSubpacketArray()), returnKey, certification.Signature));
            return(returnKey);
        }
コード例 #3
0
ファイル: PgpKey.cs プロジェクト: 1hub/springburg
        /// <summary>Add a certification for an id to the given public key.</summary>
        /// <param name="key">The key the certification is to be added to.</param>
        /// <param name="id">The ID the certification is associated with.</param>
        /// <param name="certification">The new certification.</param>
        /// <returns>The re-certified key.</returns>
        public static TKey AddCertification <TKey>(
            TKey key,
            string id,
            PgpCertification certification)
            where TKey : PgpKey
        {
            var returnKey = (TKey)key.CreateMutableCopy();

            Debug.Assert(certification.PublicKey.KeyId == key.KeyId);

            for (int i = 0; i < returnKey.ids.Count; i++)
            {
                if (returnKey.ids[i].UserId?.Equals(id) == true)
                {
                    returnKey.ids[i] = PgpUser.AddCertification(returnKey.ids[i], returnKey, certification.Signature);
                    return(returnKey);
                }
            }

            returnKey.ids.Add(new PgpUser(new UserIdPacket(id), returnKey, certification.Signature));
            return(returnKey);
        }