So I have a SOAP message like this (key data and encrypted data has been truncated):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
      <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#" Id="_0">
        <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
        <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
          <o:SecurityTokenReference>
            <X509Data>
              <X509IssuerSerial>
                <X509IssuerName>CN=blah, O=blah, L=blah, S=blah, C=blah</X509IssuerName>
                <X509SerialNumber>1</X509SerialNumber>
              </X509IssuerSerial>
            </X509Data>
          </o:SecurityTokenReference>
        </KeyInfo>
        <e:CipherData>
          <e:CipherValue>TiMPCLfQgfw==</e:CipherValue>
        </e:CipherData>
        <e:ReferenceList>
          <e:DataReference URI="#_2"/>
        </e:ReferenceList>
      </e:EncryptedKey>
    </o:Security>
  </s:Header>
  <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" u:Id="_1">
    <e:EncryptedData xmlns:e="http://www.w3.org/2001/04/xmlenc#" Id="_2" Type="http://www.w3.org/2001/04/xmlenc#Content">
      <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
      <e:CipherData>
        <e:CipherValue>1qsIPulqkVQ3==</e:CipherValue>
      </e:CipherData>
    </e:EncryptedData>
  </s:Body>
</s:Envelope>
So the body has been encoded in aes-256-cbc and then the session key that did this encoding has been encoded with my public key.
My question is how do I decode this manually?
I was trying the following:
- Copy Encrypted Session Key to a file - echo "TiMPCLfQgfw==" > sessionkey.enc
- Format key to 64 chars max per line: - sed -e "s/.{64}/&\n/g" < sessionkey.enc > sessionkey.hex
- Convert session key to binary format for openssl (as rsautl command only works with binary): - openssl enc -in sessionkey.hex -out sessionkey.bin -d -a
- Decrypt session key using openssl and privatekey: - openssl rsautl -decrypt -in sessionkey.bin -out sessionkey.dec -inkey myprivatekey.key
- Copy Encrypted Message Body to a file - echo "1qsIPulqkVQ3==" > messagebody.enc
- Format Encrypted Message Body to 64 chars max per line (hex format): - sed -e "s/.{64}/&\n/g" < messagebody.enc > messagebody.hex
- Convert Message Body key to binary format for openssl: - openssl enc -in messagebody.hex -out messagebody.bin -d -a
- Decrypt Message Body using openssl and session key: - openssl enc -aes-256-cbc -d -in messagebody.bin -out messagebody.dec -kfile sessionkey.dec
But I get "bad magic number" on this last step when I try this. Any ideas why?

