Exemplo n.º 1
0
 public PkiMessage(PkiHeader header, PkiBody body, DerBitString protection, CmpCertificate[] extraCerts)
 {
     this.header     = header;
     this.body       = body;
     this.protection = protection;
     if (extraCerts != null)
     {
         this.extraCerts = new DerSequence(extraCerts);
     }
 }
Exemplo n.º 2
0
 private PkiMessage(Asn1Sequence seq)
 {
     header = PkiHeader.GetInstance(seq[0]);
     body   = PkiBody.GetInstance(seq[1]);
     for (int i = 2; i < seq.Count; i++)
     {
         Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)seq[i].ToAsn1Object();
         if (asn1TaggedObject.TagNo == 0)
         {
             protection = DerBitString.GetInstance(asn1TaggedObject, isExplicit: true);
         }
         else
         {
             extraCerts = Asn1Sequence.GetInstance(asn1TaggedObject, explicitly: true);
         }
     }
 }
        private byte[] CalculateSignature(IStreamCalculator signer, PkiHeader header, PkiBody body)
        {
            Asn1EncodableVector avec = new Asn1EncodableVector();

            avec.Add(header);
            avec.Add(body);
            byte[] encoded = new DerSequence(avec).GetEncoded();
            signer.Stream.Write(encoded, 0, encoded.Length);
            Object result = signer.GetResult();

            if (result is DefaultSignatureResult)
            {
                return(((DefaultSignatureResult)result).Collect());
            }
            else if (result is IBlockResult)
            {
                return(((IBlockResult)result).Collect());
            }
            else if (result is byte[])
            {
                return((byte[])result);
            }

            throw new InvalidOperationException("result is not byte[] or DefaultSignatureResult");
        }
Exemplo n.º 4
0
 public ProtectedPart(PkiHeader header, PkiBody body)
 {
     this.header = header;
     this.body   = body;
 }
Exemplo n.º 5
0
 private ProtectedPart(Asn1Sequence seq)
 {
     header = PkiHeader.GetInstance(seq[0]);
     body   = PkiBody.GetInstance(seq[1]);
 }