Exemplo n.º 1
0
 public void SetUnhashedSubpackets(
     PgpSignatureSubpacketVector unhashedPackets)
 {
     unhashed = unhashedPackets == null
                         ?       EmptySignatureSubpackets
                         :       unhashedPackets.ToSubpacketArray();
 }
Exemplo n.º 2
0
 public void SetHashedSubpackets(
     PgpSignatureSubpacketVector hashedPackets)
 {
     hashed = hashedPackets == null
                         ?       EmptySignatureSubpackets
                         :       hashedPackets.ToSubpacketArray();
 }
Exemplo n.º 3
0
 /*
  * Construct a PgpSecretKey using the passed in private/public key pair and binding it to the passed in id
  * using a generated certification of certificationLevel. If keyEncryptor.ChecksumCalculatorFactory returns null
  * the secret key checksum is calculated using the original
  * non-digest based checksum.
  *
  * @param certificationLevel the type of certification to be added.
  * @param keyPair the public/private keys to use.
  * @param id the id to bind to the key.
  * @param hashedPcks the hashed packets to be added to the certification.
  * @param unhashedPcks the unhashed packets to be added to the certification.
  * @param certificationSignerBuilder the builder for generating the certification.
  * @param keyEncryptor an encryptor for the key if required (null otherwise).
  * @throws PgpException if there is an issue creating the secret key packet or the certification.
  */
 public PgpSecretKey(
     int certificationLevel,
     PgpKeyPair keyPair,
     String id,
     PgpSignatureSubpacketVector hashedPcks,
     PgpSignatureSubpacketVector unhashedPcks,
     ISignatureWithDigestFactory <PgpSignatureIdentifier> certificationSignerBuilder,
     IPbeSecretKeyEncryptor keyEncryptor) : this(keyPair.PrivateKey, certifiedPublicKey(certificationLevel, keyPair, id, hashedPcks, unhashedPcks, certificationSignerBuilder), true, keyEncryptor)
 {
 }
Exemplo n.º 4
0
        private long GetExpirationTimeFromSig(
            bool selfSigned,
            int signatureType)
        {
            foreach (PgpSignature sig in GetSignaturesOfType(signatureType))
            {
                if (!selfSigned || sig.KeyId == KeyId)
                {
                    PgpSignatureSubpacketVector hashed = sig.GetHashedSubPackets();

                    if (hashed != null)
                    {
                        return(hashed.GetKeyExpirationTime());
                    }

                    return(0);
                }
            }

            return(-1);
        }
Exemplo n.º 5
0
        private static PgpPublicKey certifiedPublicKey(
            int certificationLevel,
            PgpKeyPair keyPair,
            String id,
            PgpSignatureSubpacketVector hashedPcks,
            PgpSignatureSubpacketVector unhashedPcks,
            ISignatureWithDigestFactory <PgpSignatureIdentifier> certificationSignerBuilder)
        {
            PgpSignatureGenerator sGen;

            try
            {
                sGen = new PgpSignatureGenerator();
            }
            catch (Exception e)
            {
                throw new PgpException("creating signature generator: " + e, e);
            }

            //
            // generate the certification
            //
            sGen.InitSign(certificationLevel, certificationSignerBuilder);

            sGen.SetHashedSubpackets(hashedPcks);
            sGen.SetUnhashedSubpackets(unhashedPcks);

            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, e);
            }
        }