blob: 783541829f3dc94d7a753458406d32fdac0f2830 [file] [log] [blame]
David Reid2a746ce2013-11-15 15:32:14 -08001.. hazmat::
2
Alex Stapletonc5fffd32014-03-18 15:29:00 +00003Backend interfaces
David Reid2a746ce2013-11-15 15:32:14 -08004==================
5
Alex Gaynorf8796b12013-12-13 20:28:55 -08006.. currentmodule:: cryptography.hazmat.backends.interfaces
David Reid2a746ce2013-11-15 15:32:14 -08007
8
Alex Gaynor969f18e2014-05-17 20:07:35 -07009Backend implementations may provide a number of interfaces to support
10operations such as :doc:`/hazmat/primitives/symmetric-encryption`,
David Reid6b9df812013-11-18 14:13:02 -080011:doc:`/hazmat/primitives/cryptographic-hashes`, and
Ayrxfa4a6b22014-04-16 23:03:14 +080012:doc:`/hazmat/primitives/mac/hmac`.
David Reid6b9df812013-11-18 14:13:02 -080013
14A specific ``backend`` may provide one or more of these interfaces.
15
16
David Reid2a746ce2013-11-15 15:32:14 -080017.. class:: CipherBackend
18
Alex Stapleton63b3de22014-02-08 09:43:16 +000019 A backend that provides methods for using ciphers for encryption
David Reid5973f4c2013-11-18 11:29:44 -080020 and decryption.
21
Alex Gaynor585c99c2014-02-04 16:10:10 -080022 The following backends implement this interface:
23
24 * :doc:`/hazmat/backends/openssl`
25 * :doc:`/hazmat/backends/commoncrypto`
26
David Reid2a746ce2013-11-15 15:32:14 -080027 .. method:: cipher_supported(cipher, mode)
28
David Reid5973f4c2013-11-18 11:29:44 -080029 Check if a ``cipher`` and ``mode`` combination is supported by
30 this backend.
31
32 :param cipher: An instance of a
33 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
34 provider.
35 :param mode: An instance of a
36 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
37
38 :returns: ``True`` if the specified ``cipher`` and ``mode`` combination
39 is supported by this backend, otherwise ``False``
David Reid2a746ce2013-11-15 15:32:14 -080040
David Reid2a746ce2013-11-15 15:32:14 -080041
42 .. method:: create_symmetric_encryption_ctx(cipher, mode)
43
David Reid5973f4c2013-11-18 11:29:44 -080044 Create a
Paul Kehrer446cc2a2014-01-29 14:39:30 -060045 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext` that
David Reid5973f4c2013-11-18 11:29:44 -080046 can be used for encrypting data with the symmetric ``cipher`` using
47 the given ``mode``.
48
49 :param cipher: An instance of a
50 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
51 provider.
52 :param mode: An instance of a
53 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
54
55 :returns:
56 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext`
57
Paul Kehrera07925a2013-12-06 11:49:42 -060058 :raises ValueError: When tag is not None in an AEAD mode
59
David Reid2a746ce2013-11-15 15:32:14 -080060
61 .. method:: create_symmetric_decryption_ctx(cipher, mode)
62
David Reid5973f4c2013-11-18 11:29:44 -080063 Create a
Paul Kehrer446cc2a2014-01-29 14:39:30 -060064 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext` that
David Reid5973f4c2013-11-18 11:29:44 -080065 can be used for decrypting data with the symmetric ``cipher`` using
66 the given ``mode``.
67
68 :param cipher: An instance of a
69 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
70 provider.
71 :param mode: An instance of a
72 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
73
74 :returns:
75 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext`
David Reid2a746ce2013-11-15 15:32:14 -080076
Paul Kehrera07925a2013-12-06 11:49:42 -060077 :raises ValueError: When tag is None in an AEAD mode
78
David Reid2a746ce2013-11-15 15:32:14 -080079
80.. class:: HashBackend
81
David Reid5973f4c2013-11-18 11:29:44 -080082 A backend with methods for using cryptographic hash functions.
83
Alex Gaynor585c99c2014-02-04 16:10:10 -080084 The following backends implement this interface:
85
86 * :doc:`/hazmat/backends/openssl`
87 * :doc:`/hazmat/backends/commoncrypto`
88
David Reid2a746ce2013-11-15 15:32:14 -080089 .. method:: hash_supported(algorithm)
90
David Reid6624a442013-11-18 12:44:30 -080091 Check if the specified ``algorithm`` is supported by this backend.
92
David Reid5973f4c2013-11-18 11:29:44 -080093 :param algorithm: An instance of a
94 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
95 provider.
96
97 :returns: ``True`` if the specified ``algorithm`` is supported by this
98 backend, otherwise ``False``.
99
David Reid2a746ce2013-11-15 15:32:14 -0800100
101 .. method:: create_hash_ctx(algorithm)
102
David Reid6624a442013-11-18 12:44:30 -0800103 Create a
Paul Kehrer446cc2a2014-01-29 14:39:30 -0600104 :class:`~cryptography.hazmat.primitives.interfaces.HashContext` that
David Reid6624a442013-11-18 12:44:30 -0800105 uses the specified ``algorithm`` to calculate a message digest.
106
David Reid5973f4c2013-11-18 11:29:44 -0800107 :param algorithm: An instance of a
108 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
109 provider.
110
111 :returns:
112 :class:`~cryptography.hazmat.primitives.interfaces.HashContext`
David Reid2a746ce2013-11-15 15:32:14 -0800113
114
115.. class:: HMACBackend
116
David Reid5973f4c2013-11-18 11:29:44 -0800117 A backend with methods for using cryptographic hash functions as message
118 authentication codes.
119
Alex Gaynor585c99c2014-02-04 16:10:10 -0800120 The following backends implement this interface:
121
122 * :doc:`/hazmat/backends/openssl`
123 * :doc:`/hazmat/backends/commoncrypto`
124
Paul Kehrer90ae8662013-12-23 17:21:00 -0600125 .. method:: hmac_supported(algorithm)
126
127 Check if the specified ``algorithm`` is supported by this backend.
128
129 :param algorithm: An instance of a
130 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
131 provider.
132
133 :returns: ``True`` if the specified ``algorithm`` is supported for HMAC
134 by this backend, otherwise ``False``.
135
David Reid2a746ce2013-11-15 15:32:14 -0800136 .. method:: create_hmac_ctx(algorithm)
137
David Reid6624a442013-11-18 12:44:30 -0800138 Create a
Paul Kehrer446cc2a2014-01-29 14:39:30 -0600139 :class:`~cryptography.hazmat.primitives.interfaces.HashContext` that
Paul Kehrer4f776c42013-12-23 17:25:54 -0600140 uses the specified ``algorithm`` to calculate a hash-based message
141 authentication code.
David Reid6624a442013-11-18 12:44:30 -0800142
David Reid5973f4c2013-11-18 11:29:44 -0800143 :param algorithm: An instance of a
144 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
145 provider.
146
147 :returns:
148 :class:`~cryptography.hazmat.primitives.interfaces.HashContext`
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600149
150
Alexander Gaynora1f1afa2014-07-18 10:57:41 -0700151.. class:: CMACBackend
152
153 .. versionadded:: 0.4
154
155 A backend with methods for using CMAC
156
157 .. method:: cmac_algorithm_supported(algorithm)
158
159 :param algorithm: An instance of a
160 :class:`~cryptography.hazmat.primitives.interfaces.BlockCipherAlgorithm`
161 provider.
162 :return: Returns True if the block cipher is supported for CMAC by this backend
163
164 .. method:: create_cmac_ctx(algorithm)
165
166 Create a
167 :class:`~cryptography.hazmat.primitives.interfaces.CMACContext` that
168 uses the specified ``algorithm`` to calculate a message authentication code.
169
170 :param algorithm: An instance of a
171 :class:`~cryptography.hazmat.primitives.interfaces.BlockCipherAlgorithm`
172 provider.
173
174 :returns:
175 :class:`~cryptography.hazmat.primitives.interfaces.CMACContext`
176
177
Paul Kehrer98e40e62014-01-28 15:07:49 -0600178.. class:: PBKDF2HMACBackend
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600179
Paul Kehrer5d1af212014-01-28 12:19:32 -0600180 .. versionadded:: 0.2
181
Paul Kehrer98e40e62014-01-28 15:07:49 -0600182 A backend with methods for using PBKDF2 using HMAC as a PRF.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600183
Alex Gaynor585c99c2014-02-04 16:10:10 -0800184 The following backends implement this interface:
185
186 * :doc:`/hazmat/backends/openssl`
187 * :doc:`/hazmat/backends/commoncrypto`
188
Paul Kehrer98e40e62014-01-28 15:07:49 -0600189 .. method:: pbkdf2_hmac_supported(algorithm)
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600190
191 Check if the specified ``algorithm`` is supported by this backend.
192
Paul Kehrer589b9082014-01-28 21:25:41 -0600193 :param algorithm: An instance of a
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600194 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
195 provider.
196
197 :returns: ``True`` if the specified ``algorithm`` is supported for
Paul Kehrer98e40e62014-01-28 15:07:49 -0600198 PBKDF2 HMAC by this backend, otherwise ``False``.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600199
Paul Kehrer98e40e62014-01-28 15:07:49 -0600200 .. method:: derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,
201 key_material)
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600202
203 :param algorithm: An instance of a
204 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
205 provider.
206
207 :param int length: The desired length of the derived key. Maximum is
Paul Kehrer98e40e62014-01-28 15:07:49 -0600208 (2\ :sup:`32` - 1) * ``algorithm.digest_size``
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600209
Paul Kehrerb6d764c2014-01-27 22:32:11 -0600210 :param bytes salt: A salt.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600211
212 :param int iterations: The number of iterations to perform of the hash
Paul Kehrerc58b4782014-01-29 13:56:25 -0600213 function. This can be used to control the length of time the
214 operation takes. Higher numbers help mitigate brute force attacks
215 against derived keys.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600216
217 :param bytes key_material: The key material to use as a basis for
218 the derived key. This is typically a password.
219
220 :return bytes: Derived key.
Alex Stapleton209a1322014-02-07 20:26:44 +0000221
222
223.. class:: RSABackend
224
225 .. versionadded:: 0.2
226
227 A backend with methods for using RSA.
228
Alex Stapletone009ad22014-02-08 17:23:46 +0000229 .. method:: generate_rsa_private_key(public_exponent, key_size)
Alex Stapleton209a1322014-02-07 20:26:44 +0000230
231 :param int public_exponent: The public exponent of the new key.
232 Often one of the small Fermat primes 3, 5, 17, 257 or 65537.
233
Alex Stapletone009ad22014-02-08 17:23:46 +0000234 :param int key_size: The length in bits of the modulus. Should be
Alex Stapleton209a1322014-02-07 20:26:44 +0000235 at least 2048.
236
237 :return: A new instance of a
238 :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey`
239 provider.
240
241 :raises ValueError: If the public_exponent is not valid.
Paul Kehrer2b3f0fc2014-02-17 19:20:14 -0600242
Paul Kehrerc333dbc2014-05-24 18:35:02 -0500243 .. method:: rsa_padding_supported(padding)
244
245 Check if the specified ``padding`` is supported by the backend.
246
247 :param padding: An instance of an
248 :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricPadding`
249 provider.
250
251 :returns: ``True`` if the specified ``padding`` is supported by this
252 backend, otherwise ``False``.
253
Paul Kehrer342d2e42014-05-25 22:01:20 -0500254 .. method:: generate_rsa_parameters_supported(public_exponent, key_size)
255
256 Check if the specified parameters are supported for key generation by
257 the backend.
258
Paul Kehrer1b760f12014-05-26 08:54:38 -0500259 :param int public_exponent: The public exponent.
Paul Kehrer342d2e42014-05-25 22:01:20 -0500260
Paul Kehrer1b760f12014-05-26 08:54:38 -0500261 :param int key_size: The bit length of the generated modulus.
Paul Kehrer342d2e42014-05-25 22:01:20 -0500262
David Reida674afe2014-05-30 14:15:29 -0700263 .. method:: load_rsa_private_numbers(numbers):
David Reid68b509a2014-05-08 10:31:51 -0700264
265 :param numbers: An instance of
David Reida674afe2014-05-30 14:15:29 -0700266 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`.
David Reid68b509a2014-05-08 10:31:51 -0700267
268 :returns: A provider of
David Reida674afe2014-05-30 14:15:29 -0700269 :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey`.
270
David Reidc57a3762014-06-03 13:27:50 -0700271 :raises ValueError: This is raised when the values of ``p``, ``q``,
272 ``private_exponent``, ``public_exponent``, or ``modulus`` do not
273 match the bounds specified in :rfc:`3447`.
274
David Reidda76ae02014-06-03 14:01:18 -0700275 :raises cryptography.exceptions.UnsupportedAlgorithm: This raised when
276 any backend specific criteria are not met.
277
David Reida674afe2014-05-30 14:15:29 -0700278 .. method:: load_rsa_public_numbers(numbers):
279
280 :param numbers: An instance of
281 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`.
282
283 :returns: A provider of
284 :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey`.
David Reid68b509a2014-05-08 10:31:51 -0700285
David Reidc57a3762014-06-03 13:27:50 -0700286 :raises ValueError: This is raised when the values of
287 ``public_exponent`` or ``modulus`` do not match the bounds
288 specified in :rfc:`3447`.
289
David Reidda76ae02014-06-03 14:01:18 -0700290 :raises cryptography.exceptions.UnsupportedAlgorithm: This raised when
291 any backend specific criteria are not met.
292
Alex Stapleton2fb76a32014-02-15 11:10:57 +0000293
Mohammed Attia29474ac2014-04-02 04:03:09 +0200294.. class:: DSABackend
295
296 .. versionadded:: 0.4
297
298 A backend with methods for using DSA.
299
300 .. method:: generate_dsa_parameters(key_size)
301
Alex Gaynorc9dc0a02014-04-24 13:38:12 -0700302 :param int key_size: The length of the modulus in bits. It should be
303 either 1024, 2048 or 3072. For keys generated in 2014 this should
Mohammed Attia29474ac2014-04-02 04:03:09 +0200304 be at least 2048.
Alex Gaynorc9dc0a02014-04-24 13:38:12 -0700305 Note that some applications (such as SSH) have not yet gained
306 support for larger key sizes specified in FIPS 186-3 and are still
307 restricted to only the 1024-bit keys specified in FIPS 186-2.
Mohammed Attia29474ac2014-04-02 04:03:09 +0200308
309 :return: A new instance of a
310 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
311 provider.
312
313 .. method:: generate_dsa_private_key(parameters)
314
315 :param parameters: A
316 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
317 provider.
318
319 :return: A new instance of a
320 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`
321 provider.
322
Alex Gaynor239d5182014-04-24 13:42:58 -0700323 :raises ValueError: This is raised if the key size is not one of 1024,
324 2048, or 3072. It is also raised when OpenSSL is older than version
325 1.0.0 and the key size is larger than 1024; older OpenSSL versions
326 do not support keys larger than 1024 bits.
Ayrx97a72fd2014-04-15 19:02:51 +0800327
Paul Kehrer298effd2014-06-27 14:07:59 -0600328 .. method:: generate_dsa_private_key_and_parameters(key_size)
329
330 :param int key_size: The length of the modulus in bits. It should be
331 either 1024, 2048 or 3072. For keys generated in 2014 this should
332 be at least 2048.
333 Note that some applications (such as SSH) have not yet gained
334 support for larger key sizes specified in FIPS 186-3 and are still
335 restricted to only the 1024-bit keys specified in FIPS 186-2.
336
337 :return: A new instance of a
338 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`
339 provider.
340
341 :raises ValueError: This is raised if the key size is not supported
342 by the backend.
343
Mohammed Attia59edb612014-04-25 22:44:40 +0200344 .. method:: dsa_hash_supported(algorithm):
Paul Kehrer43dc2762014-04-30 16:24:39 -0500345
Mohammed Attia59edb612014-04-25 22:44:40 +0200346 :param algorithm: An instance of a
347 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
348 provider.
349
350 :returns: ``True`` if the specified ``algorithm`` is supported by this
351 backend, otherwise ``False``.
352
Paul Kehrer21babbb2014-05-01 11:33:22 -0500353 .. method:: dsa_parameters_supported(p, q, g):
Paul Kehrerb4037872014-04-30 16:32:23 -0500354
355 :param int p: The p value of a DSA key.
356
357 :param int q: The q value of a DSA key.
358
Paul Kehrer21babbb2014-05-01 11:33:22 -0500359 :param int g: The g value of a DSA key.
360
361 :returns: ``True`` if the given values of ``p``, ``q``, and ``g`` are
362 supported by this backend, otherwise ``False``.
Paul Kehrerb4037872014-04-30 16:32:23 -0500363
Paul Kehrer0739afc2014-06-22 12:06:18 -0600364 .. method:: load_dsa_parameter_numbers(numbers):
365
366 :param numbers: An instance of
367 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAParameterNumbers`.
368
369 :returns: A provider of
370 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`.
371
372 :raises cryptography.exceptions.UnsupportedAlgorithm: This raised when
373 any backend specific criteria are not met.
374
375 .. method:: load_dsa_private_numbers(numbers):
376
377 :param numbers: An instance of
378 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateNumbers`.
379
380 :returns: A provider of
381 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`.
382
383 :raises cryptography.exceptions.UnsupportedAlgorithm: This raised when
384 any backend specific criteria are not met.
385
386 .. method:: load_dsa_public_numbers(numbers):
387
388 :param numbers: An instance of
389 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicNumbers`.
390
391 :returns: A provider of
392 :class:`~cryptography.hazmat.primitives.interfaces.DSAPublicKey`.
393
394 :raises cryptography.exceptions.UnsupportedAlgorithm: This raised when
395 any backend specific criteria are not met.
396
397
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100398.. class:: EllipticCurveBackend
399
400 .. versionadded:: 0.5
401
402 .. method:: elliptic_curve_supported(curve)
403
404 :param curve: An instance of a
405 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
406 provider.
407
408 :returns: True if the elliptic curve is supported by this backend.
409
410 .. method:: elliptic_curve_signature_algorithm_supported(signature_algorithm, curve)
411
412 :param signature_algorithm: An instance of a
413 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurveSignatureAlgorithm`
414 provider.
415
416 :param curve: An instance of a
417 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
418 provider.
419
420 :returns: True if the signature algorithm and curve are supported by this backend.
421
422 .. method:: generate_elliptic_curve_private_key(curve)
423
424 :param curve: An instance of a
425 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
426 provider.
427
Paul Kehrer77e95a02014-09-25 12:28:07 -0500428 .. method:: load_elliptic_curve_private_numbers(numbers)
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100429
430 :param numbers: An instance of a
431 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateNumbers`
432 provider.
433
434 :returns: An instance of a
435 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateKey`
436 provider.
437
Paul Kehrer77e95a02014-09-25 12:28:07 -0500438 .. method:: load_elliptic_curve_public_numbers(numbers)
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100439
440 :param numbers: An instance of a
441 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicNumbers`
442 provider.
443
444 :returns: An instance of a
445 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicKey`
446 provider.
Alexander Gaynora1f1afa2014-07-18 10:57:41 -0700447
Alexander Gaynore0e95412014-07-19 10:58:50 -0700448.. class:: PEMSerializationBackend
449
450 .. versionadded:: 0.6
451
452 A backend with methods for working with any PEM encoded keys.
453
454 .. method:: load_pem_private_key(data, password)
455
456 :param bytes data: PEM data to load.
457 :param bytes password: The password to use if the data is encrypted.
Alex Gaynor99e61ea2014-09-08 10:26:40 -0700458 Should be ``None`` if the data is not encrypted.
Alexander Gaynore0e95412014-07-19 10:58:50 -0700459 :return: A new instance of the appropriate type of private key that the
460 serialized data contains.
461 :raises ValueError: If the data could not be deserialized.
462 :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
463 encrypted with an unsupported algorithm.
464
michael-hart801e8c12014-09-26 00:32:25 +0100465 .. method:: load_pem_public_key(data)
466
467 :param bytes data: PEM data to load.
Alex Gaynorb366f392014-09-29 11:07:05 -0700468 :return: A new instance of the appropriate type of public key
469 serialized data contains.
michael-hart801e8c12014-09-26 00:32:25 +0100470 :raises ValueError: If the data could not be deserialized.
471
Alexander Gaynora1f1afa2014-07-18 10:57:41 -0700472.. class:: TraditionalOpenSSLSerializationBackend
473
474 .. versionadded:: 0.3
475
476 A backend with methods for working with OpenSSL's "traditional" PKCS #1
477 style key serialization.
478
479 .. method:: load_openssl_pem_private_key(data, password)
480
481 :param bytes data: PEM data to deserialize.
482
483 :param bytes password: The password to use if this data is encrypted.
484 Should be None if the data is not encrypted.
485
Alexander Gaynore0e95412014-07-19 10:58:50 -0700486 :return: A new instance of the appropriate type of private key that the
487 serialized data contains.
Alexander Gaynora1f1afa2014-07-18 10:57:41 -0700488
489 :raises ValueError: If the data could not be deserialized correctly.
490
491 :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
492 encrypted with an unsupported algorithm.
493
494
495.. class:: PKCS8SerializationBackend
496
497 .. versionadded:: 0.5
498
499 A backend with methods for working with PKCS #8 key serialization.
500
501 .. method:: load_pkcs8_pem_private_key(data, password)
502
503 :param bytes data: PEM data to deserialize.
504
505 :param bytes password: The password to use if this data is encrypted.
506 Should be None if the data is not encrypted.
507
508 :return: A new instance of the appropriate private key or public key
509 that the serialized data contains.
510
511 :raises ValueError: If the data could not be deserialized correctly.
512
513 :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
514 encrypted with an unsupported algorithm.
515