5757from pq_logic .keys .xwing import XWingPrivateKey , XWingPublicKey
5858from pq_logic .tmp_oids import (
5959 CHEMPAT_OID_2_NAME ,
60- COMPOSITE_KEM07_NAME_2_OID ,
61- COMPOSITE_KEM07_OID_2_NAME ,
60+ COMPOSITE_KEM_NAME_2_OID ,
61+ COMPOSITE_KEM_OID_2_NAME ,
6262 COMPOSITE_SIG_OID_TO_NAME ,
6363 id_rsa_kem_spki ,
6464)
@@ -94,7 +94,11 @@ def _any_string_in_string(string: str, options: List[str]) -> str:
9494class CombinedKeyFactory :
9595 """Factory for creating all known key types."""
9696
97- _composite_prefixes = ["sig-13" , "kem-07" , "kem07" , "dhkem" , "kem" , "sig" ]
97+ _composite_prefixes = [
98+ "dhkem" ,
99+ "kem" ,
100+ "sig" ,
101+ ]
98102
99103 @staticmethod
100104 def get_stateful_sig_algorithms () -> Dict [str , List [str ]]:
@@ -278,16 +282,16 @@ def _get_pq_and_trad_names(
278282 return pq_name , trad_name , curve , length
279283
280284 @staticmethod
281- def _load_composite_kem07_public_key (oid : univ .ObjectIdentifier , public_key : bytes ):
282- """Load a composite KEM 06 public key from the provided OID and public key bytes.
285+ def _load_composite_kem_public_key (oid : univ .ObjectIdentifier , public_key : bytes ):
286+ """Load a composite KEM public key from the provided OID and public key bytes.
283287
284288 :param oid: The OID of the key.
285289 :param public_key: The public key bytes.
286290 :return: The loaded public key.
287291 :raises BadAsn1Data: If the public key structure is invalid or cannot be decoded.
288292 :raises InvalidKeyCombination: If the key is invalid or the combination is not supported.
289293 """
290- orig_name = COMPOSITE_KEM07_OID_2_NAME [oid ]
294+ orig_name = COMPOSITE_KEM_OID_2_NAME [oid ]
291295
292296 pq_name , trad_name = CombinedKeyFactory .get_pq_and_trad_name_form_hybrid_name (orig_name )
293297 pq_key , rest = PQKeyFactory .from_public_bytes (pq_name , public_key , allow_rest = True )
@@ -338,8 +342,8 @@ def _load_hybrid_key_from_spki(spki: rfc5280.SubjectPublicKeyInfo):
338342 public_key_bytes = spki ["subjectPublicKey" ].asOctets (),
339343 )
340344
341- if oid in COMPOSITE_KEM07_OID_2_NAME :
342- return CombinedKeyFactory ._load_composite_kem07_public_key (oid , spki ["subjectPublicKey" ].asOctets ())
345+ if oid in COMPOSITE_KEM_OID_2_NAME :
346+ return CombinedKeyFactory ._load_composite_kem_public_key (oid , spki ["subjectPublicKey" ].asOctets ())
343347
344348 if oid in CHEMPAT_OID_2_NAME or oid in CHEMPAT_OID_2_NAME :
345349 return CombinedKeyFactory .load_chempat_key (spki )
@@ -363,7 +367,7 @@ def load_public_key_from_spki(spki: Union[rfc5280.SubjectPublicKeyInfo, bytes]):
363367 if str (oid ) == XWING_OID_STR :
364368 return XWingPublicKey .from_public_bytes (spki ["subjectPublicKey" ].asOctets ())
365369
366- if oid in COMPOSITE_SIG_OID_TO_NAME or oid in COMPOSITE_KEM07_OID_2_NAME or oid in CHEMPAT_OID_2_NAME :
370+ if oid in COMPOSITE_SIG_OID_TO_NAME or oid in COMPOSITE_KEM_OID_2_NAME or oid in CHEMPAT_OID_2_NAME :
367371 return CombinedKeyFactory ._load_hybrid_key_from_spki (spki )
368372
369373 if oid in PQ_STATEFUL_HASH_SIG_OID_2_NAME :
@@ -444,14 +448,14 @@ def _load_trad_private_key_from_data(name, trad_data, curve: Optional[str] = Non
444448 return trad_key
445449
446450 @staticmethod
447- def _load_composite_kem07_from_private_bytes (algorithm : str , private_key : bytes ) -> CompositeKEMPrivateKey :
448- """Load a Composite KEM v7 public key from private key bytes.
451+ def _load_composite_kem_from_private_bytes (algorithm : str , private_key : bytes ) -> CompositeKEMPrivateKey :
452+ """Load a Composite KEM public key from private key bytes.
449453
450454 :param algorithm: The name of the algorithm.
451455 :param private_key: The private key bytes.
452456 :return: A CompositeKEMPublicKey instance.
453457 """
454- logging .info ("Loading composite KEM-07 private key: %s" , algorithm )
458+ logging .info ("Loading composite KEM private key: %s" , algorithm )
455459
456460 pq_name , trad_name = CombinedKeyFactory .get_pq_and_trad_name_form_hybrid_name (algorithm )
457461 tmp_pq_key = PQKeyFactory .generate_pq_key (pq_name )
@@ -468,7 +472,7 @@ def _load_composite_kem07_from_private_bytes(algorithm: str, private_key: bytes)
468472 trad_key = CombinedKeyFactory ._load_trad_composite_private_key (
469473 trad_name = trad_name ,
470474 trad_key_bytes = trad_bytes ,
471- prefix = "KEM v7 " if "dhkem" not in algorithm .lower () else "dhkem v7 " ,
475+ prefix = "KEM" if "dhkem" not in algorithm .lower () else "DHKEM " ,
472476 )
473477
474478 if not isinstance (trad_key , rsa .RSAPrivateKey ):
@@ -496,20 +500,20 @@ def _load_composite_kem07_from_private_bytes(algorithm: str, private_key: bytes)
496500 return composite_key
497501
498502 @staticmethod
499- def _decode_composite_kem07 (
503+ def _decode_composite_kem (
500504 name : str ,
501505 private_key_bytes : bytes ,
502506 public_key : Optional [bytes ],
503507 ) -> CompositeKEMPrivateKey :
504- """Decode a composite KEM-07 private key."""
505- private_key = CombinedKeyFactory ._load_composite_kem07_from_private_bytes (
508+ """Decode a composite KEM private key."""
509+ private_key = CombinedKeyFactory ._load_composite_kem_from_private_bytes (
506510 algorithm = name ,
507511 private_key = private_key_bytes ,
508512 )
509513
510514 if public_key is not None :
511515 spki = rfc5280 .SubjectPublicKeyInfo ()
512- spki ["algorithm" ]["algorithm" ] = COMPOSITE_KEM07_NAME_2_OID [name ]
516+ spki ["algorithm" ]["algorithm" ] = COMPOSITE_KEM_NAME_2_OID [name ]
513517 spki ["subjectPublicKey" ] = univ .BitString .fromOctetString (public_key )
514518 try :
515519 pub_key = CombinedKeyFactory .load_public_key_from_spki (spki )
@@ -575,9 +579,9 @@ def load_private_key_from_one_asym_key(
575579 name = COMPOSITE_SIG_OID_TO_NAME [oid ]
576580 return CombinedKeyFactory ._load_composite_sig_key (name , private_bytes , public_bytes )
577581
578- if oid in COMPOSITE_KEM07_OID_2_NAME :
579- _name = COMPOSITE_KEM07_OID_2_NAME [oid ]
580- return CombinedKeyFactory ._decode_composite_kem07 (_name , private_bytes , public_bytes )
582+ if oid in COMPOSITE_KEM_OID_2_NAME :
583+ _name = COMPOSITE_KEM_OID_2_NAME [oid ]
584+ return CombinedKeyFactory ._decode_composite_kem (_name , private_bytes , public_bytes )
581585
582586 if oid == id_rsa_kem_spki :
583587 return RSADecapKey .from_pkcs8 (one_asym_key )
@@ -826,14 +830,8 @@ def get_pq_and_trad_name_form_hybrid_name(hybrid_name: str) -> Tuple[str, str]:
826830 # Determine the prefix based on the algorithm name
827831 if alg .startswith ("chempat-" ):
828832 prefix = "chempat-"
829- elif alg .startswith ("composite-sig-13-" ):
830- prefix = "composite-sig-13-"
831833 elif alg .startswith ("composite-sig-" ):
832834 prefix = "composite-sig-"
833- elif alg .startswith ("composite-kem-07-" ):
834- prefix = "composite-kem-07-"
835- elif alg .startswith ("composite-kem07-" ):
836- prefix = "composite-kem07-"
837835 elif alg .startswith ("composite-dhkem-" ):
838836 prefix = "composite-dhkem-"
839837 elif alg .startswith ("composite-kem-" ):
@@ -877,7 +875,7 @@ def _load_composite_sig_from_private_bytes(algorithm: str, private_key: bytes) -
877875 pq_key = MLDSAPrivateKey .from_private_bytes (pq_bytes , name = pq_name )
878876
879877 trad_key = CombinedKeyFactory ._load_trad_composite_private_key (
880- trad_name = trad_name , trad_key_bytes = trad_bytes , prefix = "Sig v13 "
878+ trad_name = trad_name , trad_key_bytes = trad_bytes , prefix = "Sig"
881879 )
882880
883881 use_pss = trad_name .endswith ("-pss" )
@@ -943,15 +941,15 @@ def _load_trad_raw_key(
943941
944942 @staticmethod
945943 def _load_trad_composite_private_key (
946- trad_name : str , trad_key_bytes : bytes , prefix : str = "Sig v13 "
944+ trad_name : str , trad_key_bytes : bytes , prefix : str = "Sig"
947945 ) -> Union [
948946 RSAPrivateKey , Ed25519PrivateKey , Ed448PrivateKey , X25519PrivateKey , X448PrivateKey , ec .EllipticCurvePrivateKey
949947 ]:
950948 """Load a composite signature key from the given bytes.
951949
952950 :param trad_name: The name of the algorithm, e.g., "rsa2048-pss".
953951 :param trad_key_bytes: The traditional key bytes for RSA, ECDH, ECDSA, or EdDSA keys.
954- :param prefix: The prefix for the algorithm, e.g., "Sig v13 ".
952+ :param prefix: The prefix for the algorithm, e.g., "Sig".
955953 """
956954 try :
957955 if trad_name .startswith ("ecdsa" ) or trad_name .startswith ("ecdh" ):
0 commit comments