blob: 1b49a4c5d984b42af2328ab239173b08ab81a1e1 [file] [log] [blame]
Paul Kehrerca8e1612015-03-16 20:57:09 -05001.. hazmat::
2
3.. module:: cryptography.hazmat.primitives.keywrap
4
5Key wrapping
6============
7
8Key wrapping is a cryptographic construct that uses symmetric encryption to
9encapsulate key material.
10
11.. function:: aes_key_wrap(wrapping_key, key_to_wrap, backend)
12
Paul Kehrer6f6cf002015-06-17 19:58:10 -060013 .. versionadded:: 1.1
14
Paul Kehrerca8e1612015-03-16 20:57:09 -050015 :param bytes wrapping_key: The wrapping key.
16
17 :param bytes key_to_wrap: The key to wrap.
18
19 :param backend: A
20 :class:`~cryptography.hazmat.backends.interfaces.CipherBackend`
21 provider that supports
22 :class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES`.
23
24 :return bytes: The wrapped key as bytes.
25
26.. function:: aes_key_unwrap(wrapping_key, wrapped_key, backend)
27
Paul Kehrer6f6cf002015-06-17 19:58:10 -060028 .. versionadded:: 1.1
29
Paul Kehrerca8e1612015-03-16 20:57:09 -050030 :param bytes wrapping_key: The wrapping key.
31
32 :param bytes wrapped_key: The wrapped key.
33
34 :param backend: A
35 :class:`~cryptography.hazmat.backends.interfaces.CipherBackend`
36 provider that supports
37 :class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES`.
38
39 :return bytes: The unwrapped key as bytes.
40
Paul Kehrer6f6cf002015-06-17 19:58:10 -060041 :raises cryptography.hazmat.primitives.keywrap.InvalidUnwrap: This is
42 raised if the key is not successfully unwrapped.
43
Paul Kehrerca8e1612015-03-16 20:57:09 -050044Exceptions
45~~~~~~~~~~
46
47.. class:: InvalidUnwrap
48
49 This is raised when a wrapped key fails to unwrap. It can be caused by a
50 corrupted or invalid wrapped key or an invalid wrapping key.