public override void Encode(IBcpgOutputStream pOut)
            {
                var pk = new SymmetricKeyEncSessionPacket(
                    EncAlgorithm, _s2K, SessionInfo);

                pOut.WritePacket(pk);
            }
		internal PgpPbeEncryptedData(
			SymmetricKeyEncSessionPacket	keyData,
			InputStreamPacket				encData)
			: base(encData)
		{
			this.keyData = keyData;
		}
Beispiel #3
0
            public override void Encode(BcpgOutputStream pOut)
            {
                SymmetricKeyEncSessionPacket pk = new SymmetricKeyEncSessionPacket(
                    encAlgorithm, s2k, sessionInfo);

                pOut.WritePacket(pk);
            }
			public override void Encode(BcpgOutputStream pOut)
            {
                SymmetricKeyEncSessionPacket pk = new SymmetricKeyEncSessionPacket(
                    encAlgorithm, s2k, sessionInfo);

				pOut.WritePacket(pk);
            }
Beispiel #5
0
 internal PgpPbeEncryptedData(
     SymmetricKeyEncSessionPacket keyData,
     InputStreamPacket encData)
     : base(encData)
 {
     this.keyData = keyData;
 }
Beispiel #6
0
 /// <summary>Return the decrypted session data for the packet.</summary>
 private static byte[] GetSessionData(SymmetricKeyEncSessionPacket keyData, ReadOnlySpan <byte> rawPassword)
 {
     byte[] key = Array.Empty <byte>();
     try
     {
         key = new byte[PgpUtilities.GetKeySize(keyData.EncAlgorithm) / 8];
         S2kBasedEncryption.MakeKey(rawPassword, keyData.S2k.HashAlgorithm, keyData.S2k.GetIV(), keyData.S2k.IterationCount, key);
         if (keyData.SecKeyData?.Length > 0)
         {
             using var keyCipher    = PgpUtilities.GetSymmetricAlgorithm(keyData.EncAlgorithm);
             using var keyDecryptor = new ZeroPaddedCryptoTransform(keyCipher.CreateDecryptor(key, new byte[(keyCipher.BlockSize + 7) / 8]));
             return(keyDecryptor.TransformFinalBlock(keyData.SecKeyData, 0, keyData.SecKeyData.Length));
         }
         else
         {
             var sessionData = new byte[key.Length + 1];
             sessionData[0] = (byte)keyData.EncAlgorithm;
             key.CopyTo(sessionData, 1);
             return(sessionData);
         }
     }
     finally
     {
         CryptographicOperations.ZeroMemory(key);
     }
 }
            public override void Encode(IBcpgOutputStream pOut)
            {
                var pk = new SymmetricKeyEncSessionPacket(
                    EncAlgorithm, _s2K, SessionInfo);

                pOut.WritePacket(pk);
            }