-->

SOAP response MTOM attachment can't be decrypt

2020-07-30 03:59发布

问题:

I'm working on the soap client and have a problem with reading (and decryption) of the response attachment. The attachment is included into the the response using MTOM mechanism and encrypted via AES128-CBC algorithm (the secret key is included to the response xml header).

Here is the basic structure of the response:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope>

.. the xml data that includes the secret key for the attachment 
decryption usign AES algorithm.

</soapenv:Envelope>

--MIMEBoundaryurn_uuid_174A74CB7221A5AF451426570004765
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:174A74CB7221A5AF451426570004768@apache.org>

iQ�<]�+)B�ل�$O:���'�zT�F�x�����������}�t��݄��')#^��&�a�p}Q��¨גZ<G�%_"��|
Ps�<���'9��g](ǧ">�l��� ��XPrJ��jM�f�<$�)Q�*��
--MIMEBoundaryurn_uuid_174A74CB7221A5AF451426570004765--

MTOM mechanism implies that the attachment is sent as a binary string (without encoding to base64). As I suggest, this binary string is what must be decrypted via AES. But unfortunately it has the wrong length to apply the AES decryption - AES uses the 16 bytes blocks, so the cipher must be a multiple of 16. But it does not, for example in the example above the attachment length is 250.

Maybe I'm missing something and some kind of transformation must be applied to the attachment binary string before decrypting it?

P.S. The part of the response xml body is encrypted using the same algorithm (AES128-CBC), but is sent as a base64 cipher, which must be decoded to get the binary string and then decrypted. Which works fine. The decoded body cipher has the proper length - a multiple of 16 and it can be decrypted without any problems.

Thank you in advance for any thought or ideas!

回答1:

Old, but from Oracle about half way down the page

Note: Streaming MTOM cannot be used in conjunction with message encryption.

http://docs.oracle.com/cd/E14571_01/web.1111/e13734/mtom.htm#WSADV141



标签: soap aes mtom