Skip to content

[feature request]: CryptoNetAes.ExportKey() from version 2 and CryptoNetAes.GetKey() from version 3 produce different results #167

@maythamfahmi

Description

@maythamfahmi

Contact Details

Tawmy

Is your feature request related to a problem? Please describe.

Hey @maythamfahmi, thank you for the updated documentation! I apologise for getting back to you so late, I only got back to working on this project now.

My previous comment was vague because I wasn't sure yet myself, but I've dug a bit deeper now:

CryptoNetAes.ExportKey() from version 2 and CryptoNetAes.GetKey() from version 3 produce different results:

ExportKey() is XML formatted:

<?xml version="1.0" encoding="utf-16" standalone="no"?>
<AesKeyValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <key>KEY_HERE</key>
    <iv>IV_HERE</iv>
</AesKeyValue>

GetKey() is JSON formatted:

{
  "Key" : "KEY_HERE",
  "Iv" : "IV_HERE"
}

This means that any key that was previously exported using version 2 cannot be used with version 3. Passing the XML-formatted key from version 2 to CryptoNetAes.EncryptFromBytes() results in a JsonException.

Would it be possible to add an option to stay with XML-encoded AES keys, or for the CryptoNet methods to at least handle XML-formatted ones when passed to them? Then newly exported keys would be JSON-formatted while the previous XML-formatted ones can still be used.

Describe the solution you'd like

Make ExportKey in v3 to be working like v2 as optional

Describe alternatives you've considered

No response

Additional context

No response

Priority Level

Medium

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions