Exemplo n.º 1
0
 private static void WriteEncodable(MemoryStream ms, Asn1Encodable e)
 {
     if (e != null)
     {
         byte[] bs = e.GetDerEncoded();
         ms.Write(bs, 0, bs.Length);
     }
 }
Exemplo n.º 2
0
        public DerApplicationSpecific(
            bool isExplicit,
            int tag,
            Asn1Encodable obj)
        {
            byte[] data = obj.GetDerEncoded();

            this.isConstructed = isExplicit;
            this.tag           = tag;

            if (isExplicit)
            {
                this.octets = data;
            }
            else
            {
                int    lenBytes = GetLengthOfLength(data);
                byte[] tmp      = new byte[data.Length - lenBytes];
                Array.Copy(data, lenBytes, tmp, 0, tmp.Length);
                this.octets = tmp;
            }
        }
		public DerApplicationSpecific(
			bool			isExplicit,
			int				tag,
			Asn1Encodable	obj)
		{
			byte[] data = obj.GetDerEncoded();

			this.isConstructed = isExplicit;
			this.tag = tag;

			if (isExplicit)
			{
				this.octets = data;
			}
			else
			{
				int lenBytes = GetLengthOfLength(data);
				byte[] tmp = new byte[data.Length - lenBytes];
				Array.Copy(data, lenBytes, tmp, 0, tmp.Length);
				this.octets = tmp;
			}
		}
Exemplo n.º 4
0
		public DerBitString(
			Asn1Encodable obj)
		{
			this.data = obj.GetDerEncoded();
			//this.padBits = 0;
		}
Exemplo n.º 5
0
		internal static byte[] GetSignatureForObject(
			DerObjectIdentifier		sigOid, // TODO Redundant now?
			string					sigName,
			AsymmetricKeyParameter	privateKey,
			SecureRandom			random,
			Asn1Encodable			ae)
		{
			if (sigOid == null)
				throw new ArgumentNullException("sigOid");

			ISigner sig = SignerUtilities.GetSigner(sigName);

			if (random != null)
			{
				sig.Init(true, new ParametersWithRandom(privateKey, random));
			}
			else
			{
				sig.Init(true, privateKey);
			}

			byte[] encoded = ae.GetDerEncoded();
			sig.BlockUpdate(encoded, 0, encoded.Length);

			return sig.GenerateSignature();
		}
Exemplo n.º 6
0
 public DerBitString(
     Asn1Encodable obj)
 {
     this.data = obj.GetDerEncoded();
     //this.padBits = 0;
 }
Exemplo n.º 7
0
		private static void WriteEncodable(MemoryStream ms, Asn1Encodable e)
		{
			if (e != null)
			{
				byte[] bs = e.GetDerEncoded();
				ms.Write(bs, 0, bs.Length);
			}
		}