blob: 3d222684387af21b7cc8703065157519c97cc3c9 [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
Alex Gaynor1cfc5d52014-11-23 17:44:28 -0600200 .. method:: derive_pbkdf2_hmac(self, algorithm, length, salt, iterations, key_material)
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600201
202 :param algorithm: An instance of a
203 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
204 provider.
205
206 :param int length: The desired length of the derived key. Maximum is
Paul Kehrer98e40e62014-01-28 15:07:49 -0600207 (2\ :sup:`32` - 1) * ``algorithm.digest_size``
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600208
Paul Kehrerb6d764c2014-01-27 22:32:11 -0600209 :param bytes salt: A salt.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600210
211 :param int iterations: The number of iterations to perform of the hash
Paul Kehrerc58b4782014-01-29 13:56:25 -0600212 function. This can be used to control the length of time the
213 operation takes. Higher numbers help mitigate brute force attacks
214 against derived keys.
Paul Kehrer1050ddf2014-01-27 21:04:03 -0600215
216 :param bytes key_material: The key material to use as a basis for
217 the derived key. This is typically a password.
218
219 :return bytes: Derived key.
Alex Stapleton209a1322014-02-07 20:26:44 +0000220
221
222.. class:: RSABackend
223
224 .. versionadded:: 0.2
225
226 A backend with methods for using RSA.
227
Alex Stapletone009ad22014-02-08 17:23:46 +0000228 .. method:: generate_rsa_private_key(public_exponent, key_size)
Alex Stapleton209a1322014-02-07 20:26:44 +0000229
230 :param int public_exponent: The public exponent of the new key.
231 Often one of the small Fermat primes 3, 5, 17, 257 or 65537.
232
Alex Stapletone009ad22014-02-08 17:23:46 +0000233 :param int key_size: The length in bits of the modulus. Should be
Alex Stapleton209a1322014-02-07 20:26:44 +0000234 at least 2048.
235
236 :return: A new instance of a
237 :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey`
238 provider.
239
240 :raises ValueError: If the public_exponent is not valid.
Paul Kehrer2b3f0fc2014-02-17 19:20:14 -0600241
Paul Kehrerc333dbc2014-05-24 18:35:02 -0500242 .. method:: rsa_padding_supported(padding)
243
244 Check if the specified ``padding`` is supported by the backend.
245
246 :param padding: An instance of an
247 :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricPadding`
248 provider.
249
250 :returns: ``True`` if the specified ``padding`` is supported by this
251 backend, otherwise ``False``.
252
Paul Kehrer342d2e42014-05-25 22:01:20 -0500253 .. method:: generate_rsa_parameters_supported(public_exponent, key_size)
254
255 Check if the specified parameters are supported for key generation by
256 the backend.
257
Paul Kehrer1b760f12014-05-26 08:54:38 -0500258 :param int public_exponent: The public exponent.
Paul Kehrer342d2e42014-05-25 22:01:20 -0500259
Paul Kehrer1b760f12014-05-26 08:54:38 -0500260 :param int key_size: The bit length of the generated modulus.
Paul Kehrer342d2e42014-05-25 22:01:20 -0500261
Alex Gaynor4922c452014-11-20 19:45:07 -0800262 .. method:: load_rsa_private_numbers(numbers)
David Reid68b509a2014-05-08 10:31:51 -0700263
264 :param numbers: An instance of
David Reida674afe2014-05-30 14:15:29 -0700265 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`.
David Reid68b509a2014-05-08 10:31:51 -0700266
267 :returns: A provider of
David Reida674afe2014-05-30 14:15:29 -0700268 :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey`.
269
David Reidc57a3762014-06-03 13:27:50 -0700270 :raises ValueError: This is raised when the values of ``p``, ``q``,
271 ``private_exponent``, ``public_exponent``, or ``modulus`` do not
272 match the bounds specified in :rfc:`3447`.
273
Alex Gaynorfecf6442014-12-27 11:19:32 -0800274 :raises cryptography.exceptions.UnsupportedAlgorithm: This is raised
275 when any backend specific criteria are not met.
David Reidda76ae02014-06-03 14:01:18 -0700276
Alex Gaynor4922c452014-11-20 19:45:07 -0800277 .. method:: load_rsa_public_numbers(numbers)
David Reida674afe2014-05-30 14:15:29 -0700278
279 :param numbers: An instance of
280 :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`.
281
282 :returns: A provider of
283 :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey`.
David Reid68b509a2014-05-08 10:31:51 -0700284
David Reidc57a3762014-06-03 13:27:50 -0700285 :raises ValueError: This is raised when the values of
286 ``public_exponent`` or ``modulus`` do not match the bounds
287 specified in :rfc:`3447`.
288
Alex Gaynorfecf6442014-12-27 11:19:32 -0800289 :raises cryptography.exceptions.UnsupportedAlgorithm: This is raised
290 when any backend specific criteria are not met.
David Reidda76ae02014-06-03 14:01:18 -0700291
Alex Stapleton2fb76a32014-02-15 11:10:57 +0000292
Mohammed Attia29474ac2014-04-02 04:03:09 +0200293.. class:: DSABackend
294
295 .. versionadded:: 0.4
296
297 A backend with methods for using DSA.
298
299 .. method:: generate_dsa_parameters(key_size)
300
Alex Gaynorc9dc0a02014-04-24 13:38:12 -0700301 :param int key_size: The length of the modulus in bits. It should be
302 either 1024, 2048 or 3072. For keys generated in 2014 this should
Mohammed Attia29474ac2014-04-02 04:03:09 +0200303 be at least 2048.
Alex Gaynorc9dc0a02014-04-24 13:38:12 -0700304 Note that some applications (such as SSH) have not yet gained
305 support for larger key sizes specified in FIPS 186-3 and are still
306 restricted to only the 1024-bit keys specified in FIPS 186-2.
Mohammed Attia29474ac2014-04-02 04:03:09 +0200307
308 :return: A new instance of a
309 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
310 provider.
311
312 .. method:: generate_dsa_private_key(parameters)
313
314 :param parameters: A
315 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
316 provider.
317
318 :return: A new instance of a
319 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`
320 provider.
321
Alex Gaynor239d5182014-04-24 13:42:58 -0700322 :raises ValueError: This is raised if the key size is not one of 1024,
323 2048, or 3072. It is also raised when OpenSSL is older than version
324 1.0.0 and the key size is larger than 1024; older OpenSSL versions
325 do not support keys larger than 1024 bits.
Ayrx97a72fd2014-04-15 19:02:51 +0800326
Paul Kehrer298effd2014-06-27 14:07:59 -0600327 .. method:: generate_dsa_private_key_and_parameters(key_size)
328
329 :param int key_size: The length of the modulus in bits. It should be
330 either 1024, 2048 or 3072. For keys generated in 2014 this should
331 be at least 2048.
332 Note that some applications (such as SSH) have not yet gained
333 support for larger key sizes specified in FIPS 186-3 and are still
334 restricted to only the 1024-bit keys specified in FIPS 186-2.
335
336 :return: A new instance of a
337 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`
338 provider.
339
340 :raises ValueError: This is raised if the key size is not supported
341 by the backend.
342
Alex Gaynor4922c452014-11-20 19:45:07 -0800343 .. method:: dsa_hash_supported(algorithm)
Paul Kehrer43dc2762014-04-30 16:24:39 -0500344
Mohammed Attia59edb612014-04-25 22:44:40 +0200345 :param algorithm: An instance of a
346 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
347 provider.
348
349 :returns: ``True`` if the specified ``algorithm`` is supported by this
350 backend, otherwise ``False``.
351
Alex Gaynor4922c452014-11-20 19:45:07 -0800352 .. method:: dsa_parameters_supported(p, q, g)
Paul Kehrerb4037872014-04-30 16:32:23 -0500353
354 :param int p: The p value of a DSA key.
355
356 :param int q: The q value of a DSA key.
357
Paul Kehrer21babbb2014-05-01 11:33:22 -0500358 :param int g: The g value of a DSA key.
359
360 :returns: ``True`` if the given values of ``p``, ``q``, and ``g`` are
361 supported by this backend, otherwise ``False``.
Paul Kehrerb4037872014-04-30 16:32:23 -0500362
Alex Gaynor4922c452014-11-20 19:45:07 -0800363 .. method:: load_dsa_parameter_numbers(numbers)
Paul Kehrer0739afc2014-06-22 12:06:18 -0600364
365 :param numbers: An instance of
366 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAParameterNumbers`.
367
368 :returns: A provider of
369 :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`.
370
Alex Gaynorfecf6442014-12-27 11:19:32 -0800371 :raises cryptography.exceptions.UnsupportedAlgorithm: This is raised
372 when any backend specific criteria are not met.
Paul Kehrer0739afc2014-06-22 12:06:18 -0600373
Alex Gaynor4922c452014-11-20 19:45:07 -0800374 .. method:: load_dsa_private_numbers(numbers)
Paul Kehrer0739afc2014-06-22 12:06:18 -0600375
376 :param numbers: An instance of
377 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateNumbers`.
378
379 :returns: A provider of
380 :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`.
381
Alex Gaynorfecf6442014-12-27 11:19:32 -0800382 :raises cryptography.exceptions.UnsupportedAlgorithm: This is raised
383 when any backend specific criteria are not met.
Paul Kehrer0739afc2014-06-22 12:06:18 -0600384
Alex Gaynor4922c452014-11-20 19:45:07 -0800385 .. method:: load_dsa_public_numbers(numbers)
Paul Kehrer0739afc2014-06-22 12:06:18 -0600386
387 :param numbers: An instance of
388 :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicNumbers`.
389
390 :returns: A provider of
391 :class:`~cryptography.hazmat.primitives.interfaces.DSAPublicKey`.
392
Alex Gaynorfecf6442014-12-27 11:19:32 -0800393 :raises cryptography.exceptions.UnsupportedAlgorithm: This is raised
394 when any backend specific criteria are not met.
Paul Kehrer0739afc2014-06-22 12:06:18 -0600395
396
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100397.. class:: EllipticCurveBackend
398
399 .. versionadded:: 0.5
400
401 .. method:: elliptic_curve_supported(curve)
402
403 :param curve: An instance of a
404 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
405 provider.
406
407 :returns: True if the elliptic curve is supported by this backend.
408
409 .. method:: elliptic_curve_signature_algorithm_supported(signature_algorithm, curve)
410
411 :param signature_algorithm: An instance of a
412 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurveSignatureAlgorithm`
413 provider.
414
415 :param curve: An instance of a
416 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
417 provider.
418
419 :returns: True if the signature algorithm and curve are supported by this backend.
420
421 .. method:: generate_elliptic_curve_private_key(curve)
422
423 :param curve: An instance of a
424 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve`
425 provider.
426
Paul Kehrer77e95a02014-09-25 12:28:07 -0500427 .. method:: load_elliptic_curve_private_numbers(numbers)
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100428
429 :param numbers: An instance of a
430 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateNumbers`
431 provider.
432
433 :returns: An instance of a
434 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateKey`
435 provider.
436
Paul Kehrer77e95a02014-09-25 12:28:07 -0500437 .. method:: load_elliptic_curve_public_numbers(numbers)
Alex Stapleton13f1d8d2014-05-17 16:50:11 +0100438
439 :param numbers: An instance of a
440 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicNumbers`
441 provider.
442
443 :returns: An instance of a
444 :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicKey`
445 provider.
Alexander Gaynora1f1afa2014-07-18 10:57:41 -0700446
Alexander Gaynore0e95412014-07-19 10:58:50 -0700447.. class:: PEMSerializationBackend
448
449 .. versionadded:: 0.6
450
451 A backend with methods for working with any PEM encoded keys.
452
453 .. method:: load_pem_private_key(data, password)
454
455 :param bytes data: PEM data to load.
456 :param bytes password: The password to use if the data is encrypted.
Alex Gaynor99e61ea2014-09-08 10:26:40 -0700457 Should be ``None`` if the data is not encrypted.
Alexander Gaynore0e95412014-07-19 10:58:50 -0700458 :return: A new instance of the appropriate type of private key that the
459 serialized data contains.
460 :raises ValueError: If the data could not be deserialized.
461 :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
462 encrypted with an unsupported algorithm.
463
michael-hart801e8c12014-09-26 00:32:25 +0100464 .. method:: load_pem_public_key(data)
465
466 :param bytes data: PEM data to load.
Alex Gaynorb366f392014-09-29 11:07:05 -0700467 :return: A new instance of the appropriate type of public key
468 serialized data contains.
michael-hart801e8c12014-09-26 00:32:25 +0100469 :raises ValueError: If the data could not be deserialized.
470
Paul Kehrer76da86a2015-01-04 15:54:32 -0600471.. class:: DERSerializationBackend
472
473 .. versionadded:: 0.8
474
475 A backend with methods for working with DER encoded keys.
476
477 .. method:: load_der_private_key(data, password)
478
479 :param bytes data: DER data to load.
480 :param bytes password: The password to use if the data is encrypted.
481 Should be ``None`` if the data is not encrypted.
482 :return: A new instance of the appropriate type of private key that the
483 serialized data contains.
484 :raises ValueError: If the data could not be deserialized.
485 :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
486 encrypted with an unsupported algorithm.
487
488 .. method:: load_der_public_key(data)
489
490 :param bytes data: DER data to load.
491 :return: A new instance of the appropriate type of public key
492 serialized data contains.
493 :raises ValueError: If the data could not be deserialized.
494
Paul Kehrer6c4302e2014-11-24 09:20:38 -1000495.. class:: X509Backend
496
497 .. versionadded:: 0.7
498
499 A backend with methods for working with X.509 objects.
500
501 .. method:: load_pem_x509_certificate(data)
502
503 :param bytes data: PEM formatted certificate data.
504
Paul Kehrer333ae9b2014-11-24 12:23:22 -1000505 :returns: An instance of
506 :class:`~cryptography.hazmat.primitives.interfaces.X509Certificate`.
Paul Kehrer8473df62014-11-24 17:13:59 -1000507
508 .. method:: load_der_x509_certificate(data)
509
510 :param bytes data: DER formatted certificate data.
511
512 :returns: An instance of
513 :class:`~cryptography.hazmat.primitives.interfaces.X509Certificate`.