Paul Kehrer | ca8e161 | 2015-03-16 20:57:09 -0500 | [diff] [blame] | 1 | .. hazmat:: |
| 2 | |
| 3 | .. module:: cryptography.hazmat.primitives.keywrap |
| 4 | |
| 5 | Key wrapping |
| 6 | ============ |
| 7 | |
| 8 | Key wrapping is a cryptographic construct that uses symmetric encryption to |
Paul Kehrer | 42e029b | 2015-10-17 09:52:04 -0500 | [diff] [blame^] | 9 | encapsulate key material. Key wrapping algorithms are occasionally utilized |
| 10 | to protect keys at rest or transmit them over insecure networks. Many of the |
| 11 | protections offered by key wrapping are also offered by using authenticated |
| 12 | :doc:`symmetric encryption </hazmat/primitives/symmetric-encryption>`. |
Paul Kehrer | ca8e161 | 2015-03-16 20:57:09 -0500 | [diff] [blame] | 13 | |
| 14 | .. function:: aes_key_wrap(wrapping_key, key_to_wrap, backend) |
| 15 | |
Paul Kehrer | 6f6cf00 | 2015-06-17 19:58:10 -0600 | [diff] [blame] | 16 | .. versionadded:: 1.1 |
| 17 | |
Paul Kehrer | ca8e161 | 2015-03-16 20:57:09 -0500 | [diff] [blame] | 18 | :param bytes wrapping_key: The wrapping key. |
| 19 | |
| 20 | :param bytes key_to_wrap: The key to wrap. |
| 21 | |
| 22 | :param backend: A |
| 23 | :class:`~cryptography.hazmat.backends.interfaces.CipherBackend` |
| 24 | provider that supports |
| 25 | :class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES`. |
| 26 | |
| 27 | :return bytes: The wrapped key as bytes. |
| 28 | |
| 29 | .. function:: aes_key_unwrap(wrapping_key, wrapped_key, backend) |
| 30 | |
Paul Kehrer | 6f6cf00 | 2015-06-17 19:58:10 -0600 | [diff] [blame] | 31 | .. versionadded:: 1.1 |
| 32 | |
Paul Kehrer | ca8e161 | 2015-03-16 20:57:09 -0500 | [diff] [blame] | 33 | :param bytes wrapping_key: The wrapping key. |
| 34 | |
| 35 | :param bytes wrapped_key: The wrapped key. |
| 36 | |
| 37 | :param backend: A |
| 38 | :class:`~cryptography.hazmat.backends.interfaces.CipherBackend` |
| 39 | provider that supports |
| 40 | :class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES`. |
| 41 | |
| 42 | :return bytes: The unwrapped key as bytes. |
| 43 | |
Paul Kehrer | 6f6cf00 | 2015-06-17 19:58:10 -0600 | [diff] [blame] | 44 | :raises cryptography.hazmat.primitives.keywrap.InvalidUnwrap: This is |
| 45 | raised if the key is not successfully unwrapped. |
| 46 | |
Paul Kehrer | ca8e161 | 2015-03-16 20:57:09 -0500 | [diff] [blame] | 47 | Exceptions |
| 48 | ~~~~~~~~~~ |
| 49 | |
| 50 | .. class:: InvalidUnwrap |
| 51 | |
| 52 | This is raised when a wrapped key fails to unwrap. It can be caused by a |
| 53 | corrupted or invalid wrapped key or an invalid wrapping key. |