AddCertification() 공개 정적인 메소드

Add a revocation or some other key certification to a key.
public static AddCertification ( PgpPublicKey key, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the revocation is to be added to.
certification PgpSignature The key signature to be added.
리턴 PgpPublicKey
예제 #1
0
        private static PgpPublicKey CertifiedPublicKey(int certificationLevel, PgpKeyPair keyPair, string id, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, HashAlgorithmTag hashAlgorithm)
        {
            PgpSignatureGenerator pgpSignatureGenerator;

            try
            {
                pgpSignatureGenerator = new PgpSignatureGenerator(keyPair.PublicKey.Algorithm, hashAlgorithm);
            }
            catch (global::System.Exception ex)
            {
                throw new PgpException("Creating signature generator: " + ex.get_Message(), ex);
            }
            pgpSignatureGenerator.InitSign(certificationLevel, keyPair.PrivateKey);
            pgpSignatureGenerator.SetHashedSubpackets(hashedPackets);
            pgpSignatureGenerator.SetUnhashedSubpackets(unhashedPackets);
            try
            {
                PgpSignature certification = pgpSignatureGenerator.GenerateCertification(id, keyPair.PublicKey);
                return(PgpPublicKey.AddCertification(keyPair.PublicKey, id, certification));
            }
            catch (global::System.Exception ex2)
            {
                throw new PgpException("Exception doing certification: " + ex2.get_Message(), ex2);
            }
        }
예제 #2
0
        public PgpSecretKey(
            int certificationLevel,
            PgpKeyPair keyPair,
            string id,
            SymmetricKeyAlgorithmTag encAlgorithm,
            char[]                                          passPhrase,
            bool useSHA1,
            PgpSignatureSubpacketVector hashedPackets,
            PgpSignatureSubpacketVector unhashedPackets,
            SecureRandom rand)
            : this(keyPair, encAlgorithm, passPhrase, useSHA1, rand)
        {
            try
            {
                this.trust = null;
                this.ids   = new ArrayList();
                ids.Add(id);

                this.idTrusts = new ArrayList();
                idTrusts.Add(null);

                this.idSigs = new ArrayList();

                PgpSignatureGenerator sGen = new PgpSignatureGenerator(
                    keyPair.PublicKey.Algorithm, HashAlgorithmTag.Sha1);

                //
                // Generate the certification
                //
                sGen.InitSign(certificationLevel, keyPair.PrivateKey);

                sGen.SetHashedSubpackets(hashedPackets);
                sGen.SetUnhashedSubpackets(unhashedPackets);

                PgpSignature certification = sGen.GenerateCertification(id, keyPair.PublicKey);
                this.pub = PgpPublicKey.AddCertification(keyPair.PublicKey, id, certification);

                ArrayList sigList = new ArrayList();
                sigList.Add(certification);
                idSigs.Add(sigList);
            }
            catch (PgpException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new PgpException("Exception encrypting key", e);
            }
        }
예제 #3
0
        private static PgpPublicKey CertifiedPublicKey(
            int certificationLevel,
            PgpKeyPair keyPair,
            string id,
            PgpSignatureSubpacketVector hashedPackets,
            PgpSignatureSubpacketVector unhashedPackets,
            HashAlgorithmTag hashAlgorithm)
        {
            PgpSignatureGenerator sGen;

            try
            {
                sGen = new PgpSignatureGenerator(keyPair.PublicKey.Algorithm, hashAlgorithm);
            }
            catch (Exception e)
            {
                throw new PgpException("Creating signature generator: " + e.Message, e);
            }

            //
            // Generate the certification
            //
            sGen.InitSign(certificationLevel, keyPair.PrivateKey);

            sGen.SetHashedSubpackets(hashedPackets);
            sGen.SetUnhashedSubpackets(unhashedPackets);

            try
            {
                PgpSignature certification = sGen.GenerateCertification(id, keyPair.PublicKey);
                return(PgpPublicKey.AddCertification(keyPair.PublicKey, id, certification));
            }
            catch (Exception e)
            {
                throw new PgpException("Exception doing certification: " + e.Message, e);
            }
        }