-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
429 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
|
||
def load_pem_traditional_openssl_private_key(data, password, backend): | ||
return backend.load_traditional_openssl_pem_private_key( | ||
data, password | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Asymmetric algorithms | |
dsa | ||
rsa | ||
padding | ||
serialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.. hazmat:: | ||
|
||
Key Serialization | ||
================= | ||
|
||
.. currentmodule:: cryptography.hazmat.primitives.serialization | ||
|
||
There are several common schemes for serializing asymmetric private and public | ||
keys to bytes. They generally support encryption of private keys and additional | ||
key metadata. | ||
|
||
|
||
Traditional OpenSSL Format | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The "traditional" PKCS #1 based serialization format used by OpenSSL. | ||
It supports password based symmetric key encryption. Commonly found in | ||
OpenSSL based TLS applications. It is usually found in PEM format with a | ||
header that mentions the type of the serialized key. e.g. | ||
``-----BEGIN RSA PRIVATE KEY-----``. | ||
|
||
.. function:: load_pem_traditional_openssl_private_key(data, password, backend) | ||
|
||
.. versionadded:: 0.4 | ||
|
||
Deserialize a private key from PEM encoded data to one of the supported | ||
asymmetric private key types. | ||
|
||
:param bytes data: The PEM encoded key data. | ||
|
||
:param bytes password: The password to use to decrypt the data. Should | ||
be ``None`` if the private key is not encrypted. | ||
:param backend: A | ||
:class:`~cryptography.hazmat.backends.interfaces.TraditionalOpenSSLSerializationBackend` | ||
provider. | ||
|
||
:returns: A new instance of a private key. | ||
|
||
:raises ValueError: If the PEM data could not be decrypted or if its | ||
structure could not be decoded successfully. | ||
|
||
:raises TypeError: If a ``password`` was given and the private key was | ||
not encrypted. Or if the key was encrypted but no | ||
password was supplied. | ||
|
||
:raises UnsupportedAlgorithm: If the serialized key is of a type that | ||
is not supported by the backend or if the key is encrypted with a | ||
symmetric cipher that is not supported by the backend. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.