summary refs log tree commit diff
path: root/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs')
-rw-r--r--crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
index 23c8c7f76..38a4088d4 100644
--- a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
+++ b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
@@ -33,11 +33,10 @@ namespace Org.BouncyCastle.Pkcs
             {
                 MemoryStream bOut = new MemoryStream();
                 ICipher cOut = encryptor.BuildCipher(bOut);
-                byte[] keyData = privateKeyInfo.GetEncoded();
 
-                using (var str = cOut.Stream)
+                using (var stream = cOut.Stream)
                 {
-                    str.Write(keyData, 0, keyData.Length);
+                    privateKeyInfo.EncodeTo(stream);
                 }
 
                 return new Pkcs8EncryptedPrivateKeyInfo(