Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/cryptography/hazmat/primitives/_serialization.py : 91%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
5import abc
6from enum import Enum
8# This exists to break an import cycle. These classes are normally accessible
9# from the serialization module.
12class Encoding(Enum):
13 PEM = "PEM"
14 DER = "DER"
15 OpenSSH = "OpenSSH"
16 Raw = "Raw"
17 X962 = "ANSI X9.62"
18 SMIME = "S/MIME"
21class PrivateFormat(Enum):
22 PKCS8 = "PKCS8"
23 TraditionalOpenSSL = "TraditionalOpenSSL"
24 Raw = "Raw"
25 OpenSSH = "OpenSSH"
28class PublicFormat(Enum):
29 SubjectPublicKeyInfo = "X.509 subjectPublicKeyInfo with PKCS#1"
30 PKCS1 = "Raw PKCS#1"
31 OpenSSH = "OpenSSH"
32 Raw = "Raw"
33 CompressedPoint = "X9.62 Compressed Point"
34 UncompressedPoint = "X9.62 Uncompressed Point"
37class ParameterFormat(Enum):
38 PKCS3 = "PKCS3"
41class KeySerializationEncryption(metaclass=abc.ABCMeta):
42 pass
45class BestAvailableEncryption(KeySerializationEncryption):
46 def __init__(self, password: bytes):
47 if not isinstance(password, bytes) or len(password) == 0:
48 raise ValueError("Password must be 1 or more bytes.")
50 self.password = password
53class NoEncryption(KeySerializationEncryption):
54 pass