Error "wrong data format" when decrypting TStream in TScCMSProcessor

Error "wrong data format" when decrypting TStream in TScCMSProcessor

Hi,

Error "wrong data format" is always generated when decrypting a TStream in TScCMSProcessor. It works fine for files, but not for TStream.

  •   InStream := TMemoryStream.Create;
  •   InStream.LoadFromFile('Document.txt');
  •   OutStream := TMemoryStream.Create;

  •   // Files
  •   InStream.SaveToFile('Document.txt');
  •   ScCMSProcessor1.Encrypt('Document.txt', 'DocumentEnc.pem', cePEM);
  •   ScCMSProcessor1.Decrypt('DocumentEnc.pem', 'DocumentNew.txt');
  •   ScCMSProcessor1.SignAndEncrypt('Document.txt', 'DocumentSgnEnc.pem', '', cePEM);
  •   ScCMSProcessor1.DecryptAndCheckSignature('DocumentSgnEnc.pem', 'DocumentNew2.txt');

  •   // Everything above works fine

  •   // TStream
  •   ScCMSProc.Encrypt(InStream, OutStream, cePEM);
  •   //  ScCMSProc.SignAndEncrypt(InStream, OutStream, nil, cePEM);

  •   // The next two statements throw an exception, although it tries to decrypt
  •   // OutStream that contains the recently encrypted (or Signed & encrypted) (without changes)

  •   ScCMSProcessor1.Decrypt(OutStream, InStream);  // Throws Exception: "Wrong data format"
  • //  ScCMSProcessor1.DecryptAndCheckSignature(OutStream, InStream);  // Throws Exception: "Wrong data format"



  • In the first part, with files, everything it's OK, but with TSream it throws the exception "Wrong data format", even though the same TSream that was just encrypted is used. I also tried it with TStringStream with the same problem.

    SecureBridge V10.2.1

    TIA,
    Ricardo