|
9 | 9 | from cryptography.hazmat.primitives.asymmetric import ec |
10 | 10 | from cryptography.hazmat.primitives.ciphers.aead import AESGCM |
11 | 11 |
|
12 | | -from otdf_python.asym_crypto import AsymDecryption, AsymEncryption |
| 12 | +from otdf_python.asym_crypto import AsymDecryption |
13 | 13 | from otdf_python.collection_store import CollectionStore, NoOpCollectionStore |
14 | 14 | from otdf_python.config import KASInfo, NanoTDFConfig |
15 | 15 | from otdf_python.constants import MAGIC_NUMBER_AND_VERSION |
@@ -435,25 +435,13 @@ def create_nano_tdf( |
435 | 435 | ( |
436 | 436 | derived_key, |
437 | 437 | ephemeral_public_key_compressed, |
438 | | - kas_public_key, |
| 438 | + kas_public_key, # noqa: RUF059 |
439 | 439 | ) = self._derive_key_with_ecdh(config) |
440 | 440 |
|
441 | | - # Determine if we're using RSA wrapping or ECDH |
442 | | - use_rsa_wrapping = False |
443 | | - |
444 | | - if kas_public_key and not ephemeral_public_key_compressed: |
445 | | - # We have a KAS key but no ephemeral key - this means RSA mode |
446 | | - use_rsa_wrapping = True |
447 | | - |
448 | | - # If ECDH or RSA worked, use the derived key; otherwise use/generate symmetric key |
| 441 | + # Use ECDH-derived key if available; otherwise use/generate symmetric key |
449 | 442 | # Fallback to symmetric key (for testing or when KAS is not available) |
450 | 443 | key = derived_key or self._prepare_encryption_key(config) |
451 | 444 |
|
452 | | - # If using RSA wrapping, wrap the symmetric key |
453 | | - if use_rsa_wrapping and kas_public_key: |
454 | | - asym_enc = AsymEncryption(kas_public_key) |
455 | | - asym_enc.encrypt(key) |
456 | | - |
457 | 445 | # Create header with ephemeral public key (if ECDH was used) |
458 | 446 | header_bytes = self._create_header( |
459 | 447 | policy_body, policy_type, config, ephemeral_public_key_compressed |
|
0 commit comments