1

I encrypt my data with AES with a key and a random IV. This key I encrypt with RSA and include it in my EncryptedData as seen below. I need to include the IV too but how do I include it with XML Encryption Syntax as the KeyInfo element is already occupied by the EncryptedKey element?

<?xml version='1.0' encoding='UTF-8'?>
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
    xmlns="http://www.w3.org/2001/04/xmlenc#">
    <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbf" />
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
            <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
                <KeySize>256</KeySize>
                <OAEPparams>AA==</OAEPparams>
                <DigestMethod xmlns="http://www.w3.org/2000/09/xmldsig#"
                    Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            </EncryptionMethod>
            <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
                <KeyName>client provided public key</KeyName>
            </KeyInfo>
            <CipherData>
                <CipherValue>...</CipherValue>
            </CipherData>
        </EncryptedKey>
    </KeyInfo>
    <CipherData>
        <CipherValue>...</CipherValue>
    </CipherData>
</EncryptedData>
steros
  • 1,794
  • 2
  • 26
  • 60

1 Answers1

1

As per XMLEnc (see 5.2.2) the IV is placed in front of the encrypted data and is not included as a part of the key. Neither XMLEnc specification says anything about including the IV with the key during KeyTransport or KeyWrap procedure.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • Yes that paragraph got me confused quite a bit, especially the "the IV, if any, could be specified as being with the cipher data, as an algorithm content element, or elsewhere." part. So I just prepend the IV to the CipherValue Element content separated by a space? – steros Oct 25 '14 at 19:50
  • @4485670 that's for user-defined algorithms. For specification-defined algorithms the IV goes before the encrypted data, as the next paragraph says. So it's quite clear. – Eugene Mayevski 'Callback Oct 25 '14 at 19:51