Skip to content
Advertisement

How to decrypt EncryptedAssertion manually

I want to decrypt the EncryptedAssertion. I tried with OpenSaml Decrypter but its not working for me.I am getting Failed to decrypt EncryptedData I have already ask that question – EncryptedAssertion Decryption failing

While I am waiting for any solution I am trying to decrypt it manually. Its a Hybrid encryption

EncryptedAssertion

I tried below code

JavaScript

I am not sure if I am on the right path, but above decryptedValue is the decryption key for my Encrypted Data.This decryptedValue is not in readable format. Not sure what to do next.

getPrivateKey method

JavaScript

Based on the suggestion I coded like below. Not sure if I am doing it correct also I am getting errors

JavaScript

Error –

JavaScript

UPDATE :: hope I am doing it correctly based on the comments.

JavaScript

Advertisement

Answer

I won’t provide you a complete answer but I hope to get you on the right track

You should not just simply decrypt the calue with the private key.

First decrypt the KeyInfo value (unwrap the aes key) using RSA/ECB/PKCS1Padding (according to the provided saml snippet)

It should give you a 256 bit (32 bytes) random key used to encrypt data itself

then use the AES key to decrypt the data . Please note that first bytes (128 bit / 16 bytes, aes block size) is used as IV.

further reading

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement