public GetEncryptedDataObjects ( ) : IEnumerable | ||
Résultat | IEnumerable |
private static PgpPublicKeyEncryptedData extractPublicKey(PgpEncryptedDataList encryptedDataList) { PgpPublicKeyEncryptedData publicKeyED = null; foreach (PgpPublicKeyEncryptedData privateKeyED in encryptedDataList.GetEncryptedDataObjects()) { if (privateKeyED != null) { publicKeyED = privateKeyED; break; } } return publicKeyED; }
/// <summary> /// Gets the encrypted data stream by locating the private key from the secret keyring. /// </summary> /// <param name="encryptedDataList">The encrypted data list.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">encryptedDataList</exception> /// <exception cref="Org.BouncyCastle.Bcpg.OpenPgp.PgpException">data integrity compromised /// or /// no secret key for any message found.</exception> private Stream GetEncryptedDataStream(PgpEncryptedDataList encryptedDataList) { if (encryptedDataList == null) throw new ArgumentNullException("encryptedDataList"); // Iterate through encrypted data objects until we find one we have a secret key for foreach (var encryptedDataObject in encryptedDataList.GetEncryptedDataObjects().Cast<PgpPublicKeyEncryptedData>()) { if (encryptedDataObject.IsIntegrityProtected() && !encryptedDataObject.Verify()) throw new PgpException("Data integrity compromised."); var secretKey = _secretKeyRingBundle.GetSecretKey(encryptedDataObject.KeyId); if (secretKey == null) continue; var privateKey = secretKey.ExtractPrivateKey(_passPhraseChars); return encryptedDataObject.GetDataStream(privateKey); } throw new PgpException("No secret key found for any encrypted content."); }