> From: owner-openssl-us...@openssl.org On Behalf Of Carlo Milono > Sent: Thursday, 30 July, 2009 19:27
> I'm trying to illustrate how to take an OASIS WSSE SOAP > Message and operate on it with the commands in OpenSSL. > The SOAP Message encrypts the contents of an element in the > Body with AES-256-CBC with a key that was encrypted with > RSA-1_5 using a public key. We have an RSA encryption of a > key for bulk AES encryption. > > I am close, but not able to actually decrypt the element in the body. > > 2) We have the BinarySecurityToken: > 3) We have the PKCS#12 certificate corresponding to the above > certificate, so can obtain the private key. > > 4) We have the CipherValue for the EncryptedKey: > <xenc:CipherValue>cZx/SXYEmZv0kkePPNoqN0S/8y58VeyODeLZYJP/1kfC > nLUrqu2ZiV > WuG2L7lIIgbtU+A+ODRfCH > HPjSs5hS3w== > </xenc:CipherValue> > > 5) We have knowledge of the cipher being used: > <xenc:EncryptionMethod > Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" > xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"/> > > 6) We have the Encrypted Data from the Body and know it is > limited to the Content: > <xenc:EncryptedData Id="EncDataId-1407437" > Type="http://www.w3.org/2001/04/xmlenc#Content" > > ... > > <xenc:CipherValue > xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">tnOn/zq+2KhNLzs > z8IvcfO2ZR > YF1EWmRx25vL2u30Ws5oVrRTXf7sk2x9VRrAa0HeqNQNBclrKnf > RMoCP6xtS/3qABSB3fwc6XuST9qgIcxr+YUy0paXbLWY8bb4mCJnr8+9nacB/B > R3T0nQMHyn > 7FsS > +Rlvgz7TlxL4Tks6CJfFbwduNkn6aUkz7WHvAT69RF8/TMr8n8I4mk+2OF717e > xeMPfuChlm > 24oS > Sm5v1QR4oV+u8pEzTsUy71QYtw0gkK5xFjsUGYpqFXbUZbz3z9Gi4iLPQJ8wG9 > PicKTC48AC > m274 > vrkn7KkaF4iwOguX4S97NAR5jwP55Yn65uLU6Q== > </xenc:CipherValue> > > ----------------------------- > I should be able to use "openssl rsautl -decrypt -inkey > private.key.pem -in CipherValueKey", but I get RSA operation > error 3328:error:0406506C:rsa > routines:RSA_EAY_PRIVATE_DECRYPT:data greater than mod > len:.\crypto\rsa\rsa_eay.c:512: > > I convert the CipherValueKey to binary and the decryption > works. Right. rsautl only supports binary, not base64. > I should be able to use the result as the symmetric > key (I've tried binary and base64). Here I try it with the > key in a binary format. > > openssl aes-256-cbc -d -in BodyCipherValue.txt -pass > file:symmetric-key.bin > > bad magic number > That doesn't use it as the key; that uses it as a passphrase to generate a PBE-type key, which is a very different thing. Convert binary to hex and pass it with -K (note uppercase). You also need -iv (in hex) explicitly; you don't mention it formatted separately, so it may be the first block of the data. This ought to be stated in your specifications someplace. > Someone suggested that the CipherValue in the Body would be > an ASN.1 structure, and that I'd have to know the offset (?), Unlikely. XML encoding is usually an ALTERNATIVE to ASN.1, except where you need to carry already-ASN.1 items like an X.509 certificate. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org