cosmian-kms 4.17.0__cp37-abi3-manylinux_2_34_x86_64.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import List, Union
3
+
4
+ from .cosmian_kms import *
5
+
6
+ UidOrTags = Union[str, List[str]]
7
+ # KMS Objects (e.g. keys) can either be referenced by an UID using a single string,
8
+ # or by a list of tags using a list of string.
9
+
10
+ __doc__ = cosmian_kms.__doc__
11
+ if hasattr(cosmian_kms, '__all__'):
12
+ __all__ = cosmian_kms.__all__
@@ -0,0 +1,451 @@
1
+ from asyncio import Future
2
+ from typing import List, Optional, Tuple, Union
3
+
4
+ from cloudproof_cover_crypt import Attribute, Policy
5
+
6
+ UidOrTags = Union[str, List[str]]
7
+ """KMS Objects (e.g. keys) can either be referenced by an UID using a single string, or by a list of tags using a list of string."""
8
+
9
+ class KmsObject:
10
+ def object_type(self) -> str:
11
+ """Get the type of the underlying KMIP object.
12
+
13
+ Returns:
14
+ str
15
+ """
16
+
17
+ def key_block(self) -> bytes:
18
+ """Retrieve key bytes
19
+
20
+ Returns:
21
+ bytes
22
+ """
23
+
24
+ class KmsEncryptResponse:
25
+ """Represents the response from a KMS encryption operation."""
26
+
27
+ @staticmethod
28
+ def from_json(data: str) -> KmsEncryptResponse:
29
+ """
30
+ Creates an instance from a JSON string.
31
+
32
+ Args:
33
+ data (str): The JSON string representing the KmsEncryptResponse.
34
+ """
35
+
36
+ def unique_identifier(self) -> str:
37
+ """
38
+ Retrieves the unique identifier of the key used during encryption.
39
+
40
+ Returns:
41
+ str: The unique identifier of the key.
42
+ """
43
+
44
+ def data(self) -> bytes:
45
+ """
46
+ Retrieves the data bytes from the encryption response.
47
+
48
+ Returns:
49
+ bytes.
50
+ """
51
+
52
+ def iv_counter_nonce(self) -> bytes:
53
+ """
54
+ Retrieves the IV, Counter, or Nonce bytes from the encryption response.
55
+
56
+ Returns:
57
+ bytes
58
+ """
59
+
60
+ def authenticated_encryption_tag(self) -> bytes:
61
+ """
62
+ Retrieves the authentication tag bytes from the encryption response.
63
+
64
+ Returns:
65
+ bytes
66
+ """
67
+
68
+ def correlation_value(self) -> bytes:
69
+ """
70
+ Retrieves the correlation value bytes from the encryption response.
71
+
72
+ Returns:
73
+ bytes
74
+ """
75
+
76
+ class KmsClient:
77
+ """Python client for a Key Management System (KMS). The methods return Future object which
78
+ can be used to track and manage the status of the requests asynchronously.
79
+ """
80
+
81
+ def __init__(
82
+ self,
83
+ server_url: str,
84
+ api_key: Optional[str] = None,
85
+ client_pkcs12_path: Optional[str] = None,
86
+ client_pkcs12_password: Optional[str] = None,
87
+ database_secret: Optional[str] = None,
88
+ insecure_mode: bool = False,
89
+ allowed_tee_tls_cert: Optional[bytes] = None,
90
+ ) -> None:
91
+ """Instantiate a KMS Client
92
+
93
+ Args:
94
+ server_url (str): url of the KMS server
95
+ api_key (str, optional): to authenticate to the KMS server
96
+ client_pkcs12_path (Optional[str]): optional path to client PKCS12, to authenticate to the KMS
97
+ client_pkcs12_password (Optional[str]): optional password to client PKCS12
98
+ database_secret (str, optional): to authenticate to the KMS database
99
+ insecure_mode (bool, optional): accept self signed ssl cert. Defaults to False.
100
+ allowed_tee_tls_cert (Optional[bytes]) : PEM certificate of a tee.
101
+ """
102
+
103
+ def create_cover_crypt_master_key_pair(
104
+ self, policy: Union[Policy, bytes]
105
+ ) -> Future[Tuple[str, str]]:
106
+ """Generate the master authority keys for supplied Policy.
107
+
108
+ Args:
109
+ policy (Union[Policy, str]): policy used to generate the keys
110
+
111
+ Returns:
112
+ Future[Tuple[str, str]]: (Public key UID, Master secret key UID)
113
+ """
114
+
115
+ def import_cover_crypt_master_private_key(
116
+ self,
117
+ private_key: bytes,
118
+ replace_existing: bool,
119
+ link_master_public_key_id: str,
120
+ policy: bytes,
121
+ tags: Optional[List[str]],
122
+ is_wrapped: bool,
123
+ wrapping_password: Optional[str] = None,
124
+ unique_identifier: Optional[str] = None,
125
+ ) -> Future[str]:
126
+ """Import a Private Master Key into the KMS.
127
+
128
+ Args:
129
+ private_key (bytes): key bytes
130
+ replace_existing (bool): set to true to replace an existing key with the same identifier
131
+ link_master_public_key_id (str): id of the matching master public key
132
+ policy (bytes): policy related to the key
133
+ is_wrapped (bool): whether the key is wrapped
134
+ wrapping_password (Optional[str]): password used to wrap the key
135
+ unique_identifier (Optional[str]): the unique identifier of the key
136
+
137
+ Returns:
138
+ Future[str]: the unique identifier of the key
139
+ """
140
+
141
+ def import_cover_crypt_public_key(
142
+ self,
143
+ public_key: bytes,
144
+ replace_existing: bool,
145
+ policy: bytes,
146
+ link_master_private_key_id: str,
147
+ unique_identifier: Optional[str] = None,
148
+ ) -> Future[str]:
149
+ """Import a Public Master Key into the KMS.
150
+
151
+ Args:
152
+ public_key (bytes): key bytes
153
+ replace_existing (bool): set to true to replace an existing key with the same identifier
154
+ policy (bytes): policy related to the key
155
+ link_master_private_key_id (str): id of the matching master private key
156
+ unique_identifier (Optional[str]): the unique identifier of the key
157
+
158
+ Returns:
159
+ Future[str]: the unique identifier of the key
160
+ """
161
+
162
+ def rekey_cover_crypt_access_policy(
163
+ self,
164
+ access_policy: str,
165
+ master_secret_key_identifier: UidOrTags,
166
+ ) -> Future[Tuple[str, str]]:
167
+ """Generate new keys associated to the given access policy in the master keys.
168
+ This will automatically refresh the corresponding user keys.
169
+
170
+ Args:
171
+ - `access_policy` (str): describe the keys to renew
172
+ - `master_secret_key_identifier` (Union[str, List[str])): master secret key referenced by its UID or a list of tags
173
+
174
+ Returns:
175
+ Future[Tuple[str, str]]: (Public key UID, Master secret key UID)
176
+ """
177
+
178
+ async def prune_cover_crypt_access_policy(
179
+ self,
180
+ access_policy: str,
181
+ master_secret_key_identifier: UidOrTags,
182
+ ) -> Tuple[str, str]:
183
+ """
184
+ Removes old keys associated to the access policy from the master keys.
185
+ This will automatically refresh the corresponding user keys.
186
+ This will permanently remove access to old ciphertexts.
187
+
188
+ Args:
189
+ - `access_policy` (str): describe the keys to renew
190
+ - `master_secret_key_identifier` (Union[str, List[str])): master secret key referenced by its UID or a list of tags
191
+
192
+ Returns:
193
+ Tuple[str, str]: (Public key UID, Master secret key UID)
194
+ """
195
+
196
+ async def remove_cover_crypt_attribute(
197
+ self,
198
+ attribute: str,
199
+ master_secret_key_identifier: UidOrTags,
200
+ ) -> Tuple[str, str]:
201
+ """
202
+ Remove a specific attribute from a keypair's policy.
203
+ Permanently removes the ability to use this attribute in both encryptions and decryptions.
204
+
205
+ Note that messages whose encryption policy does not contain any other attributes
206
+ belonging to the dimension of the deleted attribute will be lost.
207
+
208
+ This will rekey in the KMS:
209
+ - the master keys
210
+ - all user decryption keys that contain one of these attributes in their policy.
211
+
212
+ Args:
213
+ attributes (Union[Attribute, str]): Attributes to remove e.g. "Department::HR"
214
+ master_secret_key_identifier (Union[str, List[str])): master secret key referenced by its UID or a list of tags
215
+
216
+ Returns:
217
+ Tuple[str, str]: (Public key UID, Master secret key UID)
218
+ """
219
+
220
+ async def disable_cover_crypt_attribute(
221
+ self,
222
+ attribute: str,
223
+ master_secret_key_identifier: UidOrTags,
224
+ ) -> Tuple[str, str]:
225
+ """
226
+ Disable a specific attribute from a keypair's policy.
227
+ Prevents the encryption of new messages for this attribute while keeping the ability to decrypt existing ciphertexts.
228
+
229
+ This will rekey in the KMS:
230
+ - the master keys
231
+
232
+ Args:
233
+ attributes (Union[Attribute, str]): Attributes to disable e.g. "Department::HR"
234
+ master_secret_key_identifier (Union[str, List[str])): master secret key referenced by its UID or a list of tags
235
+
236
+ Returns:
237
+ Tuple[str, str]: (Public key UID, Master secret key UID)
238
+ """
239
+
240
+ async def add_cover_crypt_attribute(
241
+ self,
242
+ attribute: str,
243
+ is_hybridized: bool,
244
+ master_secret_key_identifier: UidOrTags,
245
+ ) -> Tuple[str, str]:
246
+ """
247
+ Add a specific attribute to a keypair's policy.
248
+
249
+ This will rekey in the KMS:
250
+ - the master keys
251
+
252
+ Args:
253
+ attributes (Union[Attribute, str]): Attributes to disable e.g. "Department::HR"
254
+ is_hybridized (bool): hint for encryption
255
+ master_secret_key_identifier (Union[str, List[str])): master secret key referenced by its UID or a list of tags
256
+
257
+
258
+ Returns:
259
+ Tuple[str, str]: (Public key UID, Master secret key UID)
260
+ """
261
+
262
+ async def rename_cover_crypt_attribute(
263
+ self,
264
+ attribute: str,
265
+ new_name: str,
266
+ master_secret_key_identifier: UidOrTags,
267
+ ) -> Tuple[str, str]:
268
+ """
269
+ Add a specific attribute to a keypair's policy.
270
+
271
+ Args:
272
+ attributes (Union[Attribute, str]): Attributes to disable e.g. "Department::HR"
273
+ new_name (str): the new name for the attribute
274
+ master_secret_key_identifier (Union[str, List[str])): master secret key referenced by its UID or a list of tags
275
+
276
+ Returns:
277
+ Tuple[str, str]: (Public key UID, Master secret key UID)
278
+ """
279
+
280
+ def create_cover_crypt_user_decryption_key(
281
+ self,
282
+ access_policy: str,
283
+ master_secret_key_identifier: str,
284
+ tags: Optional[str] = None,
285
+ ) -> Future[str]:
286
+ """Generate a user secret key.
287
+ A new user secret key does NOT include to old (i.e. rotated) partitions.
288
+
289
+ Args:
290
+ access_policy(str): user access policy
291
+ master_secret_key_identifier (str): master secret key UID
292
+ tags (Optional[List[str]]): optional tags to use with the keys
293
+
294
+ Returns:
295
+ Future[str]: User secret key UID
296
+ """
297
+
298
+ def import_cover_crypt_user_decryption_key(
299
+ self,
300
+ private_key: bytes,
301
+ replace_existing: bool,
302
+ link_master_private_key_id: str,
303
+ access_policy: str,
304
+ tags: Optional[List[str]] = None,
305
+ is_wrapped: Optional[bool] = None,
306
+ wrapping_password: Optional[str] = None,
307
+ unique_identifier: Optional[str] = None,
308
+ ) -> Future[str]:
309
+ """Import a user secret key into the KMS.
310
+
311
+ Args:
312
+ private_key (bytes): key bytes
313
+ replace_existing (bool): set to true to replace an existing key with the same identifier
314
+ link_master_private_key_id (str): id of the matching master private key
315
+ access_policy(str): user access policy
316
+ tags (Optional[List[str]]): tags associated to the key
317
+ is_wrapped (bool): whether the key is wrapped
318
+ wrapping_password (Optional[str]): password used to wrap the key
319
+ unique_identifier (Optional[str]): the unique identifier of the key
320
+
321
+ Returns:
322
+ Future[str]: User secret key UID
323
+ """
324
+
325
+ def cover_crypt_encryption(
326
+ self,
327
+ encryption_policy_str: str,
328
+ data: bytes,
329
+ public_key_identifier: UidOrTags,
330
+ header_metadata: Optional[bytes] = None,
331
+ authentication_data: Optional[bytes] = None,
332
+ ) -> Future[bytes]:
333
+ """Hybrid encryption. Concatenates the encrypted header and the symmetric
334
+ ciphertext.
335
+
336
+ Args:
337
+ encryption_policy_str (str): the access policy to use for encryption
338
+ data (bytes): data to encrypt
339
+ public_key_identifier (Union[str, List[str]]): public key unique id or associated tags
340
+ header_metadata (Optional[bytes]): additional data to symmetrically encrypt in the header
341
+ authentication_data (Optional[bytes]): authentication data to use in symmetric encryptions
342
+
343
+ Returns:
344
+ Future[bytes]: ciphertext
345
+ """
346
+
347
+ def cover_crypt_decryption(
348
+ self,
349
+ encrypted_data: bytes,
350
+ user_key_identifier: UidOrTags,
351
+ authentication_data: Optional[bytes] = None,
352
+ ) -> Future[Tuple[bytes, bytes]]:
353
+ """Hybrid decryption.
354
+
355
+ Args:
356
+ encrypted_data (bytes): encrypted header || symmetric ciphertext
357
+ user_key_identifier (Union[str, List[str]]): user secret key unique id or associated tags
358
+ authentication_data (Optional[bytes]): authentication data to use in symmetric decryption
359
+
360
+ Returns:
361
+ Future[Tuple[bytes, bytes]]: (plaintext bytes, header metadata bytes)
362
+ """
363
+
364
+ def get_object(self, unique_identifier: UidOrTags) -> Future[KmsObject]:
365
+ """Fetch KMIP object by UID.
366
+
367
+ Args:
368
+ unique_identifier (Union[str, List[str]]): object unique id or associated tags
369
+
370
+ Returns:
371
+ Future[KmsObject]
372
+ """
373
+
374
+ def revoke_key(
375
+ self,
376
+ revocation_reason: str,
377
+ key_identifier: UidOrTags,
378
+ ) -> Future[str]:
379
+ """Mark a CoverCrypt Key as revoked
380
+
381
+ Args:
382
+ revocation_reason (str): explanation of the revocation
383
+ key_identifier (Union[str, List[str]]): key unique id or associated tags
384
+
385
+ Returns:
386
+ Future[str]: uid of the revoked key
387
+ """
388
+
389
+ def destroy_key(
390
+ self,
391
+ key_identifier: UidOrTags,
392
+ ) -> Future[str]:
393
+ """Mark a CoverCrypt Key as destroyed
394
+
395
+ Args:
396
+ key_identifier (Union[str, List[str]]): key unique id or associated tags
397
+
398
+ Returns:
399
+ Future[str]: uid of the destroyed key
400
+ """
401
+
402
+ def create_symmetric_key(
403
+ self,
404
+ key_len_in_bits: int,
405
+ algorithm: str = "AES",
406
+ tags: Optional[List[str]] = None,
407
+ ) -> Future[str]:
408
+ """Create a symmetric key using the specified key length, cryptographic algorithm, and optional tags
409
+
410
+ Args:
411
+ key_len_in_bits (int): length of the key in bits
412
+ algorithm (str, optional): cryptographic algorithm to be used, supported values are "AES" and "ChaCha20". Defaults to "AES"
413
+ tags (List[str], optional): tags associated with the key
414
+
415
+ Returns:
416
+ Future[str]: uid of the created key.
417
+ """
418
+
419
+ def encrypt(
420
+ self,
421
+ data: bytes,
422
+ key_identifier: UidOrTags,
423
+ ) -> Future[KmsEncryptResponse]:
424
+ """Encrypts the provided binary data using the specified key identifier or tags
425
+
426
+ Args:
427
+ data (bytes): binary data to be encrypted
428
+ key_identifier (Union[str, List[str]]): secret key unique id or associated tags
429
+
430
+ Returns:
431
+ Future[KmsEncryptResponse]: encryption result
432
+ """
433
+
434
+ def decrypt(
435
+ self,
436
+ encrypted_data: bytes,
437
+ key_identifier: UidOrTags,
438
+ iv_counter_nonce: Optional[bytes] = None,
439
+ authentication_encryption_tag: Optional[bytes] = None,
440
+ ) -> Future[bytes]:
441
+ """Hybrid decryption.
442
+
443
+ Args:
444
+ encrypted_data (bytes): ciphertext
445
+ key_identifier (Union[str, List[str]]): secret key unique id or associated tags
446
+ iv_counter_nonce (Optional[bytes]): the initialization vector, counter or nonce to be used
447
+ authentication_encryption_tag (Optional[bytes]): additional binary data used for authentication
448
+
449
+ Returns:
450
+ Future[bytes]: plaintext bytes
451
+ """
Binary file
cosmian_kms/py.typed ADDED
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.1
2
+ Name: cosmian_kms
3
+ Version: 4.17.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Author: Bruno Grieder <bruno.grieder@cosmian.com>, Emmanuel Coste <emmanuel.coste@cosmian.com>, Hugo Rosenkranz-Costa <hugo.rosenkranz@cosmian.com>
8
+ Author-email: Bruno Grieder <bruno.grieder@cosmian.com>, Emmanuel Coste <emmanuel.coste@cosmian.com>, Hugo Rosenkranz-Costa <hugo.rosenkranz@cosmian.com>
9
+ License: BUSL-1.1
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+ Project-URL: Source Code, https://github.com/Cosmian/kms
13
+
14
+ # Cosmian KMS Python
15
+
16
+ This library is part of [CloudProof Python](https://github.com/Cosmian/cloudproof_python).
17
+
18
+ ## Building and testing
19
+
20
+ You need to have `maturin` installed. To install it, run:
21
+
22
+ ```bash
23
+ python3 -m pip install maturin
24
+ ```
25
+
26
+ To build the Python interface, run:
27
+
28
+ ```bash
29
+ maturin build --release
30
+ ```
31
+
32
+ __Note__: when a new function or class is added to the PyO3 interface, its signature needs to be added to [`__init__.pyi`](python/cosmian_kms/__init__.pyi).
33
+
34
+ To run tests on the Python interface, run:
35
+
36
+ ```bash
37
+ ./python/scripts/test.sh
38
+ ```
39
+
@@ -0,0 +1,9 @@
1
+ cosmian_kms-4.17.0.dist-info/METADATA,sha256=wZ_BDWhENJc1lCUfwpzDObY7PIVn89LYBTihSYgPIyc,1263
2
+ cosmian_kms-4.17.0.dist-info/WHEEL,sha256=_YJd0er71EfeXRLuvhF-_nxPqoUcuWh962x8zWv1JC8,106
3
+ cosmian_kms.libs/libssl-6e513d0a.so.1.1,sha256=wCw3nQHUqiZIQmLIs447u-CJQDRg2DrTNmxACZxNN2c,646120
4
+ cosmian_kms.libs/libcrypto-d7a32359.so.1.1,sha256=-ZKNBTcoJmvAnCEvmJ0f4imeA2nY4JcFmykHeB0Dxl0,3087816
5
+ cosmian_kms/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
6
+ cosmian_kms/__init__.pyi,sha256=j6PBX789uUqFLm_v-1GT-YAgSQ9ODQ3YqOUF3RzDxRU,15602
7
+ cosmian_kms/__init__.py,sha256=RFE0iC3agi76L3Tu7aW_qHBzcFMZ-w-In6lPnZpPPL8,350
8
+ cosmian_kms/cosmian_kms.abi3.so,sha256=ugnyhSY6RHIgLousZJ7tKpVz6Sd1_Wn35q3kEnckAVA,4698928
9
+ cosmian_kms-4.17.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.4.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp37-abi3-manylinux_2_34_x86_64
Binary file