A list of PGP signatures - normally in the signature block after literal data.
Inheritance: PgpObject
コード例 #1
0
		DigitalSignatureCollection GetDigitalSignatures (PgpSignatureList signatureList, Stream content)
		{
			var signatures = new List<IDigitalSignature> ();
			var buf = new byte[4096];
			int nread;

			for (int i = 0; i < signatureList.Count; i++) {
				var pubkey = PublicKeyRingBundle.GetPublicKey (signatureList[i].KeyId);
				var signature = new OpenPgpDigitalSignature (pubkey, signatureList[i]) {
					PublicKeyAlgorithm = GetPublicKeyAlgorithm (signatureList[i].KeyAlgorithm),
					DigestAlgorithm = GetDigestAlgorithm (signatureList[i].HashAlgorithm),
					CreationDate = signatureList[i].CreationTime,
				};

				if (pubkey != null)
					signatureList[i].InitVerify (pubkey);

				signatures.Add (signature);
			}

			var memory = content as MemoryStream;
			if (memory != null) {
				// We can optimize things a bit if we've got a memory stream...
				var buffer = memory.GetBuffer ();

				for (int index = (int) memory.Position; index < (int) memory.Length; index++) {
					byte c = buffer[index];

					for (int i = 0; i < signatures.Count; i++) {
						if (signatures[i].SignerCertificate != null) {
							var pgp = (OpenPgpDigitalSignature) signatures[i];
							pgp.Signature.Update (c);
						}
					}
				}
			} else {
				while ((nread = content.Read (buf, 0, buf.Length)) > 0) {
					for (int i = 0; i < signatures.Count; i++) {
						if (signatures[i].SignerCertificate != null) {
							var pgp = (OpenPgpDigitalSignature) signatures[i];
							pgp.Signature.Update (buf, 0, nread);
						}
					}
				}
			}

			return new DigitalSignatureCollection (signatures);
		}
コード例 #2
0
		DigitalSignatureCollection GetDigitalSignatures (PgpSignatureList signatureList, Stream content)
		{
			var signatures = new List<IDigitalSignature> ();
			var buf = new byte[4096];
			int nread;

			for (int i = 0; i < signatureList.Count; i++) {
				var pubkey = PublicKeyRingBundle.GetPublicKey (signatureList[i].KeyId);
				var signature = new OpenPgpDigitalSignature (pubkey, signatureList[i]) {
					PublicKeyAlgorithm = GetPublicKeyAlgorithm (signatureList[i].KeyAlgorithm),
					DigestAlgorithm = GetDigestAlgorithm (signatureList[i].HashAlgorithm),
					CreationDate = signatureList[i].CreationTime,
				};

				if (pubkey != null)
					signatureList[i].InitVerify (pubkey);

				signatures.Add (signature);
			}

			while ((nread = content.Read (buf, 0, buf.Length)) > 0) {
				for (int i = 0; i < signatures.Count; i++) {
					if (signatures[i].SignerCertificate != null) {
						var pgp = (OpenPgpDigitalSignature) signatures[i];
						pgp.Signature.Update (buf, 0, nread);
					}
				}
			}

			return new DigitalSignatureCollection (signatures);
		}