3 lá˜_=ã@sbddlmZmZmZddlmZddlmZddlm Z ddl m Z m Z m Z d dd„Zd d „ZdS) é)Úabsolute_importÚdivisionÚprint_function)Úx509)Ú _get_backend)Ú serialization)ÚdsaÚecÚrsaNcCst|ƒ}|j||ƒS)N)rZ%load_key_and_certificates_from_pkcs12)ÚdataZpasswordÚbackend©r ú/usr/lib64/python3.6/pkcs12.pyÚload_key_and_certificates srcCs¼|dk r(t|tjtjtjfƒ r(tdƒ‚|dk rFt|tj ƒ rFtdƒ‚|dk rpt |ƒ}t dd„|Dƒƒsptdƒ‚t|t j ƒs„tdƒ‚|dkr¢|dkr¢| r¢tdƒ‚tdƒ}|j|||||ƒS)Nz3Key must be RSA, DSA, or EllipticCurve private key.zcert must be a certificatecss|]}t|tjƒVqdS)N)Ú isinstancerÚ Certificate)Ú.0Úvalr r rú !sz1serialize_key_and_certificates..z&all values in cas must be certificateszFKey encryption algorithm must be a KeySerializationEncryption instancez1You must supply at least one of key, cert, or cas)rr ZRSAPrivateKeyWithSerializationrZDSAPrivateKeyWithSerializationr Z(EllipticCurvePrivateKeyWithSerializationÚ TypeErrorrrÚlistÚallrZKeySerializationEncryptionÚ ValueErrorrZ(serialize_key_and_certificates_to_pkcs12)ÚnameÚkeyZcertZcasZencryption_algorithmr r r rÚserialize_key_and_certificatess*   r)N)Z __future__rrrZ cryptographyrZcryptography.hazmat.backendsrZcryptography.hazmat.primitivesrZ)cryptography.hazmat.primitives.asymmetricrr r rrr r r rÚs