Esempio n. 1
0
        public override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(false);
            }

            OriginatorID id = obj as OriginatorID;

            if (id == null)
            {
                return(false);
            }

            return(Arrays.AreEqual(SubjectKeyIdentifier, id.SubjectKeyIdentifier) &&
                   Platform.Equals(SerialNumber, id.SerialNumber) &&
                   IssuersMatch(Issuer, id.Issuer));
        }
		private AsymmetricKeyParameter GetSenderPublicKey(
			AsymmetricKeyParameter		receiverPrivateKey,
			OriginatorIdentifierOrKey	originator)
		{
			OriginatorPublicKey opk = originator.OriginatorPublicKey;
			if (opk != null)
			{
				return GetPublicKeyFromOriginatorPublicKey(receiverPrivateKey, opk);
			}
			
			OriginatorID origID = new OriginatorID();
			
			Asn1.Cms.IssuerAndSerialNumber iAndSN = originator.IssuerAndSerialNumber;
			if (iAndSN != null)
			{
				origID.Issuer = iAndSN.Name;
				origID.SerialNumber = iAndSN.SerialNumber.Value;
			}
			else
			{
				SubjectKeyIdentifier ski = originator.SubjectKeyIdentifier;

				origID.SubjectKeyIdentifier = ski.GetKeyIdentifier();
			}

			return GetPublicKeyFromOriginatorID(origID);
		}
		private AsymmetricKeyParameter GetPublicKeyFromOriginatorID(
			OriginatorID origID)
		{
			// TODO Support all alternatives for OriginatorIdentifierOrKey
			// see RFC 3852 6.2.2
			throw new CmsException("No support for 'originator' as IssuerAndSerialNumber or SubjectKeyIdentifier");
		}