Key Wrapping

This pull request adds support for key wrapping and also includes some fixes.

Please, review it.