42
42
# We only actually need these imports when running the mypy checks
43
43
pass
44
44
45
- SUPPORTED_VERSIONS = (1 ,)
45
+ SUPPORTED_VERSIONS = (3 ,)
46
46
KEY_TYPES = ("symmetric" , "private" , "public" )
47
47
KEY_ENCODINGS = ("base64" , "pem" )
48
48
KEY_ALGORITHMS = ("aes" , "rsa" )
@@ -123,18 +123,14 @@ class ManualKeySpec(KeySpec):
123
123
:param str type_name: Key type
124
124
:param int bits: Key length in bits
125
125
:param str encoding: Encoding used to encode key material
126
- :param material: Raw material encoded, then split into lines separated by ``line_separator``
127
- :type material: list of str
128
- :param str line_separator: Character with which to separate members of ``material``
129
- before decoding (optional: default is empty string)
126
+ :param str material: Raw material encoded
130
127
"""
131
128
132
129
algorithm = attr .ib (validator = membership_validator (KEY_ALGORITHMS ))
133
130
type_name = attr .ib (validator = membership_validator (KEY_TYPES ))
134
131
bits = attr .ib (validator = attr .validators .instance_of (int ))
135
132
encoding = attr .ib (validator = membership_validator (KEY_ENCODINGS ))
136
- material = attr .ib (validator = iterable_validator (list , six .string_types ))
137
- line_separator = attr .ib (default = "" , validator = attr .validators .instance_of (six .string_types ))
133
+ material = attr .ib (validator = attr .validators .instance_of (six .string_types ))
138
134
139
135
def __init__ (
140
136
self ,
@@ -145,7 +141,6 @@ def __init__(
145
141
bits , # type: int
146
142
encoding , # type: str
147
143
material , # type: Iterable[str]
148
- line_separator = "" , # type: Optional[str]
149
144
): # noqa=D107
150
145
# type: (...) -> None
151
146
# Workaround pending resolution of attrs/mypy interaction.
@@ -156,7 +151,6 @@ def __init__(
156
151
self .bits = bits
157
152
self .encoding = encoding
158
153
self .material = material
159
- self .line_separator = line_separator
160
154
super (ManualKeySpec , self ).__init__ (encrypt , decrypt )
161
155
162
156
@property
@@ -167,7 +161,7 @@ def raw_material(self):
167
161
:return: Binary key material
168
162
:rtype: bytes
169
163
"""
170
- raw_material = self .line_separator . join ( self . material ) .encode (ENCODING )
164
+ raw_material = self .material .encode (ENCODING )
171
165
if self .encoding == "base64" :
172
166
return base64 .b64decode (raw_material )
173
167
@@ -188,7 +182,6 @@ def manifest_spec(self):
188
182
"type" : self .type_name ,
189
183
"bits" : self .bits ,
190
184
"encoding" : self .encoding ,
191
- "line-separator" : self .line_separator ,
192
185
"material" : self .material ,
193
186
}
194
187
@@ -211,16 +204,14 @@ def key_from_manifest_spec(key_spec):
211
204
algorithm = key_spec ["algorithm" ] # type: str
212
205
bits = key_spec ["bits" ] # type: int
213
206
encoding = key_spec ["encoding" ] # type: str
214
- line_separator = key_spec .get ("line-separator" , "" ) # type: str
215
- material = key_spec ["material" ] # type: Iterable[str]
207
+ material = key_spec ["material" ] # type: str
216
208
return ManualKeySpec (
217
209
encrypt = encrypt ,
218
210
decrypt = decrypt ,
219
211
type_name = type_name ,
220
212
algorithm = algorithm ,
221
213
bits = bits ,
222
214
encoding = encoding ,
223
- line_separator = line_separator ,
224
215
material = material ,
225
216
)
226
217
@@ -242,7 +233,7 @@ class KeysManifest(object):
242
233
@classmethod
243
234
def from_manifest_spec (cls , raw_manifest ):
244
235
# type: (KEYS_MANIFEST) -> KeysManifest
245
- """"""
236
+ """Load from a JSON keys manifest. """
246
237
manifest_version = raw_manifest ["manifest" ] # type: MANIFEST_VERSION
247
238
validate_manifest_type (
248
239
type_name = cls .type_name , manifest_version = manifest_version , supported_versions = SUPPORTED_VERSIONS
0 commit comments