Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / nova / signature_utils.pyc
Size: Mime:
ó
±EYc@s˜dZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZmZejeƒZ iej!ƒd6ej"ƒd6ej#ƒd6ej$ƒd6Z%dZ&dZ'e
j(ƒe
j)ƒe
j*ƒe
j+ƒe
j,ƒe
j-ƒfZ.dZ/e/hZ0iej1d6Z2de3fd„ƒYZ4d„Z5d„Z6d„Z7e4j8e&ej9e5ƒe4j8e'e	j:e7ƒxFe.D]>Z;eƒj<e;ƒre4j8de;j=j>ƒe
j?e6ƒqqWd „Z@d!„ZAd"„ZBd#„ZCd$„ZDd%„ZEdS(&sSupport signature verification.iÿÿÿÿN(tKeyManagerError(tkey_manager(tdefault_backend(tdsa(tec(tpadding(trsa(thashes(tx509(tlog(tbase64(tencodeutils(t	timeutils(t	exception(t_t_LEsSHA-224sSHA-256sSHA-384sSHA-512sRSA-PSStDSAsX.509tMGF1tSignatureKeyTypecBs5eZiZd„Zed„ƒZed„ƒZRS(cCs||_||_||_dS(N(tnametpublic_key_typetcreate_verifier(tselfRRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyt__init__Qs		cCs||||ƒ|j|<dS(sôRegister a signature key type.

        :param name: the name of the signature key type
        :param public_key_type: e.g. RSAPublicKey, DSAPublicKey, etc.
        :param create_verifier: a function to create a verifier for this type
        N(t_REGISTERED_TYPES(tclsRRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytregisterVscCs9||jkr.tjdtdƒ|ƒ‚n|j|S(sÜLook up the signature key type.

        :param name: the name of the signature key type
        :returns: the SignatureKeyType object
        :raises: SignatureVerificationError if signature key type is invalid
        treasonsInvalid signature key type: %s(RR
tSignatureVerificationErrorR(RR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytlookupbs	(t__name__t
__module__RRtclassmethodRR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyRMs	cCs@tj|ƒ}tjj}|j|tjd|d|ƒ|ƒS(sÆCreate the verifier to use when the key type is RSA-PSS.

    :param signature: the decoded signature to use
    :param hash_method: the hash method to use, as a cryptography object
    :param public_key: the public key to use, as a cryptography object
    :raises: SignatureVerificationError if the RSA-PSS specific properties
                                        are invalid
    :returns: the verifier to use to verify the signature for RSA-PSS
    tmgftsalt_length(RRtPSSt
MAX_LENGTHtverifier(t	signaturethash_methodt
public_keyR!R"((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytcreate_verifier_for_pssqscCs|j|tj|ƒƒS(sDCreate the verifier to use when the key type is ECC_*.

    :param signature: the decoded signature to use
    :param hash_method: the hash method to use, as a cryptography object
    :param public_key: the public key to use, as a cryptography object
    :returns: the verifier to use to verify the signature for ECC_*.
    (R%RtECDSA(R&R'R(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytcreate_verifier_for_ecc‰s	cCs|j||ƒS(s>Create the verifier to use when the key type is DSA

    :param signature: the decoded signature to use
    :param hash_method: the hash method to use, as a cryptography object
    :param public_key: the public key to use, as a cryptography object
    :returns: the verifier to use to verify the signature for DSA
    (R%(R&R'R(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytcreate_verifier_for_dsa˜s	tECC_cCsÜi|d6|d6|d6|d6}xC|jƒD]5}||dkr/tjdtdƒ|ƒ‚q/q/Wt|ƒ}t|ƒ}tj|ƒ}	t	|||	ƒ}
|	j
|||
ƒ}|rÀ|Stjdtdƒƒ‚dS(	s«Instantiate signature properties and use them to create a verifier.

    :param context: the user context for authentication
    :param img_signature_certificate_uuid:
           uuid of signing certificate stored in key manager
    :param img_signature_hash_method:
           string denoting hash method used to compute signature
    :param img_signature: string of base64 encoding of signature
    :param img_signature_key_type:
           string denoting type of keypair used to compute signature
    :returns: instance of
       cryptography.hazmat.primitives.asymmetric.AsymmetricVerificationContext
    :raises: SignatureVerificationError if we fail to build the verifier
    timg_signature_uuidtimg_signature_hash_methodt
img_signaturetimg_signature_key_typeRspRequired image properties for signature verification do not exist. Cannot verify signature. Missing property: %ss*Error occurred while creating the verifierN(tkeystNoneR
RRt
get_signaturetget_hash_methodRRtget_public_keyR(tcontexttimg_signature_certificate_uuidR/R0R1timage_meta_propstkeyR&R'tsignature_key_typeR(R%((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pytget_verifier²s,

						cCsLytj|ƒ}Wn2ttjfk
rGtjdtdƒƒ‚nX|S(séDecode the signature data and returns the signature.

    :param signature_data: the base64-encoded signature data
    :returns: the decoded signature
    :raises: SignatureVerificationError if the signature data is malformatted
    Rs8The signature data was not properly encoded using base64(R
tdecode_as_bytest	TypeErrortbinasciitErrorR
RR(tsignature_dataR&((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyR4ás	cCs3|tkr+tjdtdƒ|ƒ‚nt|S(sVerify the hash method name and create the hash method.

    :param hash_method_name: the name of the hash method to retrieve
    :returns: the hash method, a cryptography object
    :raises: SignatureVerificationError if the hash method name is invalid
    Rs!Invalid signature hash method: %s(tHASH_METHODSR
RR(thash_method_name((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyR5òs	cCsSt||ƒ}|jƒ}t||jƒsOtjdtdƒ|jƒ‚n|S(s¤Create the public key object from a retrieved certificate.

    :param context: the user context for authentication
    :param signature_certificate_uuid: the uuid to use to retrieve the
                                       certificate
    :param signature_key_type: a SignatureKeyType object
    :returns: the public key cryptography object
    :raises: SignatureVerificationError if public key format is invalid
    Rs2Invalid public key type for signature key type: %s(tget_certificateR(t
isinstanceRR
RRR(R7tsignature_certificate_uuidR;tcertificateR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyR6s
		cCsútjƒ}y|j||ƒ}Wnctk
r‡}tdƒi|d6tj|ƒd6}tj|ƒt	j
dtdƒ|ƒ‚nX|jt
kr¹t	j
dtdƒ|jƒ‚n|jtkrì|jƒ}tj|tƒƒ}nt|ƒ|S(s‘Create the certificate object from the retrieved certificate data.

    :param context: the user context for authentication
    :param signature_certificate_uuid: the uuid to use to retrieve the
                                       certificate
    :returns: the certificate cryptography object
    :raises: SignatureVerificationError if the retrieval fails or the format
             is invalid
    s4Unable to retrieve certificate with ID %(id)s: %(e)stidteRs*Unable to retrieve certificate with ID: %ssInvalid certificate format: %s(RtAPItgetRRRtexception_to_unicodetLOGterrorR
RRtformattCERTIFICATE_FORMATStX_509tget_encodedRtload_der_x509_certificateRtverify_certificate(R7RFt
keymgr_apitcertRItmsgt	cert_dataRG((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyRDs(
	

				
cCsrtjƒ}||jkr=tjdtdƒ|jƒ‚n1||jkrntjdtdƒ|jƒ‚ndS(sÜVerify that the certificate has not expired.

    :param certificate: the cryptography certificate object
    :raises: SignatureVerificationError if the certificate valid time range
             does not include now
    Rs'Certificate is not valid before: %s UTCs&Certificate is not valid after: %s UTCN(Rtutcnowtnot_valid_beforeR
RRtnot_valid_after(RGtnow((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyRTDs				(Ft__doc__R?tcastellan.common.exceptionRt	castellanRtcryptography.hazmat.backendsRt)cryptography.hazmat.primitives.asymmetricRRRRtcryptography.hazmat.primitivesRtcryptographyRtoslo_logR	tloggingtoslo_serializationR
t
oslo_utilsRRtnovaR
t	nova.i18nRRt	getLoggerRRMtSHA224tSHA256tSHA384tSHA512RBtRSA_PSSRt	SECT571K1t	SECT409K1t	SECT571R1t	SECT409R1t	SECP521R1t	SECP384R1t
ECC_CURVESRQRPRtMASK_GEN_ALGORITHMStobjectRR)R+R,RtRSAPublicKeytDSAPublicKeytcurvetelliptic_curve_supportedRtuppertEllipticCurvePublicKeyR<R4R5R6RDRT(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/nova/signature_utils.pyt<module>sf


						
$			
	/				+