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.SignAndEncrypt('Document.txt', 'DocumentSgnEnc.pem', '', cePEM);
// Everything above works fine
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.