9(Zc@ sdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZddlmZmZddlmZmZddlmZddlmZmZmZdd lmZdd lmZmZm Z m!Z!m"Z"ddl#Z$ddl%Z$ddl&Z$ddl'Z$dd l(m)Z)dd l*m+Z+m,Z,dd l-m.Z.ddl/m0Z0ddl1m2Z2ej3e4Z5ej6de7ej8ej9de:fdYZ;dej<fdYZ=ej6de7de;fdYZ>de=fdYZ?ej6de7de;fdYZ@de=fdYZAddddfZBdS(s;High level AWS Encryption SDK client for streaming objects.i(tdivisionN(tActionNotAllowedErrortAWSEncryptionSDKClientErrortCustomMaximumValueExceededtNotSupportedErrortSerializationError(t Algorithmt ContentType(tSignertVerifier(tderive_data_encryption_key(tdecryptt Decryptort Encryptor(tnon_framed_body_iv(t FRAME_LENGTHt LINE_LENGTHtMAX_NON_FRAMED_SIZEtTYPEtVERSION(tMasterKeyProvider(tDecryptionMaterialsRequesttEncryptionMaterialsRequest(tCryptoMaterialsManager(tDefaultCryptoMaterialsManager(t MessageHeaderthasht _ClientConfigc B s eZdZejdedejjj Z ejdedddej j ej jeZejdedddej j ej jeZejdedddej j ej jejZejdededej jejZdZRS(sParent configuration object for StreamEncryptor and StreamDecryptor objects. :param source: Source data to encrypt or decrypt :type source: str, bytes, io.IOBase, or file :param materials_manager: `CryptoMaterialsManager` from which to obtain cryptographic materials (either `materials_manager` or `key_provider` required) :type materials_manager: aws_encryption_sdk.materials_manager.base.CryptoMaterialsManager :param key_provider: `MasterKeyProvider` from which to obtain data keys for encryption (either `materials_manager` or `key_provider` required) :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider :param int source_length: Length of source data (optional) .. note:: If source_length is not provided and unframed message is being written or read() is called, will attempt to seek() to the end of the stream and tell() to find the length of source data. Rtconverttdefaultt validatorcC s|jdk o|jdk }|jdko9|jdk}|sH|rWtdn|jdkr~td|j|_ndS(s,Normalize inputs to crypto material manager.sAExactly one of materials_manager or key_provider must be providedtmaster_key_providerN(tmaterials_managertNonet key_providert TypeErrorR(tselftboth_cmm_and_mkp_definedtneither_cmm_nor_mkp_defined((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt__attrs_post_init__Ys  N(t__name__t __module__t__doc__tattrtibtTruetaws_encryption_sdktinternaltutilstprep_stream_datatsourceR!t validatorstoptionalt instance_ofRR RR"tsixt integer_typest source_lengthRt line_lengthR'(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR/s&! ! ! $ t_EncryptionStreamcB seZdZeZdZedZedZdZ dZ ddZ dZ dZd Zd Zd d Zd ZdZdZdZeZRS(sParent class for StreamEncryptor and StreamDecryptor classes. :param config: Client configuration object :type config: aws_encryption_sdk.streaming_client._ClientConfig cK st|dot|j sNt|do:t|j sNt|d ritdj|jntt|j|}|j dd}t ||j s|j |}n||_ d|_d|_t|_|j j|_|j j|_|S( sEPatch for abstractmethod-like enforcement in io.IOBase grandchildren.t _read_bytest _prep_messaget _config_classs#Can't instantiate abstract class {}tconfigitN(thasattrtcallableR;R#tformatR(tsuperR:t__new__tpopR!t isinstanceR=R>t bytes_readt output_buffertFalset_message_preppedR2t source_streamR8t_stream_length(tclstkwargstinstanceR>((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRDs    cC s|jdkryK|jj}|jjdd|jj|_|jj|dWqtk r{}t|qXn|jS(sMReturns the length of the source stream, determining it if not already known.iiN(RLR!RKttelltseekt ExceptionR(R$tcurrent_positionterror((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt stream_lengthscC s|js|jn|jS(sReturns the message header, reading it if it is not already read. :returns: Parsed message header :rtype: aws_encryption_sdk.structures.MessageHeader (RJR<t_header(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pytheaders  cC s|S(sHandles entry to with block.((R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt __enter__scC s3y|jWntk r.tjdnXtS(s3Handles closing of stream upon exist of with block.sError on closing(tcloseRt_LOGGERt exceptionRI(R$texc_typet exc_valuet traceback((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt__exit__s  cC stjd|tj}|js2|jn|jrJtdn|r|j||j |j | |j ||_ n9x6|j js|jt |j |j d|_ qW|j |j7_ tjd|j||jS(sReturns either the requested number of bytes or the entire stream. :param int b: Number of bytes to read :returns: Processed (encrypted or decrypted) bytes from source stream :rtype: bytes s'Stream read called, requesting %s bytessI/O operation on closed fileR?s(Returning %s bytes of %s bytes requested(RZtdebugtiotBytesIORJR<tclosedt ValueErrorR;twriteRHRKRRGRPtgetvalue(R$tbtoutput((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pytreads"       cC s|jS(s+Returns the current position in the stream.(RG(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRPscC stS(s%Overwrites the parent writable method(RI(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pytwritablescC stddS(s'Overwrites the parent writelines methods+writelines is not available for this objectN(tNotImplementedError(R$tlines((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt writelinesscC stddS(s"Overwrites the parent write methods&write is not available for this objectN(Rk(R$Rg((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyResicC stddS(s!Overwrites the parent seek methods%seek is not available for this objectN(Rk(R$toffsettwhence((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRQscC sHtjd|j|j}t||jkrDtjdn|S(sRead a chunk of the outputs reading linesall lines read(RZtinfoRiR9tlen(R$tline((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pytreadlines  cC sg|D] }|^qS(sUReads all chunks of output, outputting a list as defined in the IOBase specification.((R$Rr((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt readlinesscC s|S(s5Make this class and subclasses identify as iterators.((R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt__iter__scC shtjd|jr/tjdtn|jjr^|j r^tjdtn|jS(s1Provides hook for Python2 iterator functionality.s reading nextsstream is closedsnothing more to read(RZR`Rct StopIterationRKRHRs(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pytnexts      N(R(R)R*RR9RDtpropertyRURWRXR_R!RiRPRjRmReRQRsRtRuRwt__next__(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR:ds$            tEncryptorConfigc B seZdZejdedejedejj eZ ejde dddejj ejj eZejde dedejj ejZRS(sConfiguration object for StreamEncryptor class. :param source: Source data to encrypt or decrypt :type source: str, bytes, io.IOBase, or file :param materials_manager: `CryptoMaterialsManager` from which to obtain cryptographic materials (either `materials_manager` or `key_provider` required) :type materials_manager: aws_encryption_sdk.materials_manager.base.CryptoMaterialsManager :param key_provider: `MasterKeyProvider` from which to obtain data keys for encryption (either `materials_manager` or `key_provider` required) :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider :param int source_length: Length of source data (optional) .. note:: If source_length is not provided and unframed message is being written or read() is called, will attempt to seek() to the end of the stream and tell() to find the length of source data. .. note:: .. versionadded:: 1.3.0 If `source_length` and `materials_manager` are both provided, the total plaintext bytes encrypted will not be allowed to exceed `source_length`. To maintain backwards compatibility, this is not enforced if a `key_provider` is provided. :param dict encryption_context: Dictionary defining encryption context :param algorithm: Algorithm to use for encryption (optional) :type algorithm: aws_encryption_sdk.identifiers.Algorithm :param int frame_length: Frame length in bytes (optional) RRRN(R(R)R*R+R,RItFactorytdictR3R5tencryption_contextR-R!R4Rt algorithmRR6R7t frame_length(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRz s  ! tStreamEncryptorcB seeZdZeZdZdZdZdZdZ dZ dZ dZ d Z RS( sProvides a streaming encryptor for encrypting a stream source. Behaves as a standard file-like object. .. note:: Take care when encrypting framed messages with large frame length and large non-framed messages. See :class:`aws_encryption_sdk.stream` for more details. .. note:: If config is provided, all other parameters are ignored. :param config: Client configuration object (config or individual parameters required) :type config: aws_encryption_sdk.streaming_client.EncryptorConfig :param source: Source data to encrypt or decrypt :type source: str, bytes, io.IOBase, or file :param materials_manager: `CryptoMaterialsManager` from which to obtain cryptographic materials (either `materials_manager` or `key_provider` required) :type materials_manager: aws_encryption_sdk.materials_manager.base.CryptoMaterialsManager :param key_provider: `MasterKeyProvider` from which to obtain data keys for encryption (either `materials_manager` or `key_provider` required) :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider :param int source_length: Length of source data (optional) .. note:: If source_length is not provided and unframed message is being written or read() is called, will attempt to seek() to the end of the stream and tell() to find the length of source data. .. note:: .. versionadded:: 1.3.0 If `source_length` and `materials_manager` are both provided, the total plaintext bytes encrypted will not be allowed to exceed `source_length`. To maintain backwards compatibility, this is not enforced if a `key_provider` is provided. :param dict encryption_context: Dictionary defining encryption context :param algorithm: Algorithm to use for encryption :type algorithm: aws_encryption_sdk.identifiers.Algorithm :param int frame_length: Frame length in bytes cK syd|_tjjj|jj|_d|_|jjdkru|jjdk ru|jjt krut dndS(s"Prepares necessary initial values.iis'Source too large for non-framed messageN( tsequence_numberR.R/R0t content_typeR>Rt_bytes_encryptedR8R!RR(R$RN((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt__init__gs  cC s"tjjjd|jd|jS(s^Returns the length of the resulting ciphertext message in bytes. :rtype: int RWtplaintext_length(R.R/t formattingtciphertext_lengthRWRU(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRws cC s;tjjj}y |j}Wntk r8d}nXtd|jj d|jj j d|jj dtjjj j|jd|}|jjjd||_|jj dk r|jj |jj krtdjd|jj d |jj n|jjdkrd|_n'tjd|jj d |jj|_tjjjd|jj d|jj td |jjjd|jj d ||_td tdt d|jj d |d|jj d|jj!d|j"ddd|jj j#d|jj |_$|j%|j"t&j'kr.|j(nt)|_*dS(sPerforms initial message setup. :raises MasterKeyProviderError: if primary master key is not a member of supplied MasterKeyProvider :raises MasterKeyProviderError: if no Master Keys are returned from key_provider R~R}Rtplaintext_rostreamRtrequestsCryptographic materials manager provided algorithm suite differs from algorithm suite in request. Required: {requested} Provided: {provided}t requestedtprovidedt key_bytest source_keyt message_idtversionttypetencrypted_data_keysRtcontent_aad_lengthitheader_iv_lengthN(+R.R/R0RRURR!RR>R~R}tcopyRtstreamstROStreamRKR tget_encryption_materialst_encryption_materialsRRBt signing_keytsignerRtfrom_key_bytestvalidate_frame_lengthR tdata_encryption_keytdata_keyt_derived_data_keyRRRRRtiv_lenRVt _write_headerRt NO_FRAMINGt_prep_non_framedR-RJ(R$RRtencryption_materials_request((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR<sZ       *               c C sy|jtjjjjd|jd|j7_|jtjjjjd|j j d|jd|j d|j7_dS(s=Builds the message header and writes it to the output stream.RWRR~RN( RHR.R/Rt serializetserialize_headerRVRtserialize_header_authRR~R(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRs    c C stjjjd|jdt}tjjjjd|j j d|ddd|j }t d|j jd |jd |d t|j j|_|jtjjjjd|j jd |jjd |j d |j7_dS(s2Prepare the opening data for a non-framed message.Rtis_final_frameRtaad_content_stringtseq_numitlengthR~tkeytassociated_datativRRN(R.R/R0tget_aad_content_stringRR-RR}tassemble_content_aadRVRRUR RR~RRt encryptorRHRtserialize_non_framed_openRR(R$RR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRs$         cC sdtjd||jj|}|jt|tkrMtdn|jj |}|j t|7_ |j dk r|j j |nt||kr`tjd|||jj |jj}|j dk r|j j |n|tjjjjd|jjd|j 7}|j dk rX|tjjjj|j 7}n||S|S(sReads the requested number of bytes from source to a streaming non-framed message body. :param int b: Number of bytes to read :returns: Encrypted bytes from source stream :rtype: bytes sReading %s bytess'Source too large for non-framed messagesEClosing encryptor after receiving only %s bytes of %s bytes requestedttagRN(RZR`RKRiRPRqRRRtupdateRRR!RYtfinalizeR.R/RRtserialize_non_framed_closeRtserialize_footer(R$Rgt plaintextt ciphertexttclosing((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt_read_bytes_to_non_framed_bodys*   "c C s%tjd||}ttj|t|jj|jj}tjd|||jj |}tjdt |t }t ||krtjdt }nd}t }x| r|s|r| r|ot ||jjk}t t ||jj}tjd||r(dnd|j|j|7_tjjjjd|jjd |d |jjd |jd |jjd |jd|d|j\} }|}|| 7}|jd7_qW|r!tjd|jdk r|tjjjj|j7}n|jjn|S(sReads the requested number of bytes from source to a streaming framed message body. :param int b: Number of bytes to read :returns: Bytes read from source stream, encrypted, and serialized :rtype: bytes scollecting %s bytessF%s bytes requested; reading %s bytes after normalizing to frame lengths%s bytes read from sources Final plaintext read from sourceR?s Writing %s bytes into%s frame %ss finalR~RRRRRRRisWriting footerN(RZR`tinttmathtceiltfloatR>RRKRiRqRIR-tminRRR.R/RRtserialize_frameRR~RVRRRR!RRY( R$Rgt_bRRRhtfinal_frame_writtenRtbytes_in_frameR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt_read_bytes_to_framed_bodysR/            "cC s2tjd||j|t|jks7|jjrHtjddS|jtjkrtjd|j|j |7_nF|jtj krtjd|j|j |7_n t d|j jdkr.|j jdk r.|j|j jkr.tdjd|jd |j jq.ndS( sReads the requested number of bytes from a streaming message body. :param int b: Number of bytes to read :raises NotSupportedError: if content type is not supported s4%s bytes requested from stream with content type: %ss:No need to read from source stream or source stream closedNsReading to framed bodysReading to non-framed bodysUnsupported content typesRBytes encrypted has exceeded stated source length estimate: {actual} > {estimated}tactualt estimated(RZR`RRqRHRKRcRt FRAMED_DATARRRRR>R"R!R8RRRBR2(R$Rg((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR;Fs"!    $  cC s$tjdtt|jdS(sCloses out the stream.sClosing streamN(RZR`RCRRY(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRYfs (R(R)R*RzR=RRR<RRRRR;RY(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR=s&  G  8 tDecryptorConfigc B sGeZdZejdedddejjejj e j Z RS(sConfiguration object for StreamDecryptor class. :param source: Source data to encrypt or decrypt :type source: str, bytes, io.IOBase, or file :param materials_manager: `CryptoMaterialsManager` from which to obtain cryptographic materials (either `materials_manager` or `key_provider` required) :type materials_manager: aws_encryption_sdk.materials_managers.base.CryptoMaterialsManager :param key_provider: `MasterKeyProvider` from which to obtain data keys for decryption (either `materials_manager` or `key_provider` required) :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider :param int source_length: Length of source data (optional) .. note:: If source_length is not provided and read() is called, will attempt to seek() to the end of the stream and tell() to find the length of source data. :param int max_body_length: Maximum frame size (or content length for non-framed messages) in bytes to read from ciphertext message. RRRN( R(R)R*R+R,R-R!R3R4R5R6R7tmax_body_length(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRls  tStreamDecryptorcB s\eZdZeZdZdZdZdZdZ dZ dZ dZ RS( sProvides a streaming encryptor for encrypting a stream source. Behaves as a standard file-like object. .. note:: Take care when decrypting framed messages with large frame length and large non-framed messages. See :class:`aws_encryption_sdk.stream` for more details. .. note:: If config is provided, all other parameters are ignored. :param config: Client configuration object (config or individual parameters required) :type config: aws_encryption_sdk.streaming_client.DecryptorConfig :param source: Source data to encrypt or decrypt :type source: str, bytes, io.IOBase, or file :param materials_manager: `CryptoMaterialsManager` from which to obtain cryptographic materials (either `materials_manager` or `key_provider` required) :type materials_manager: aws_encryption_sdk.materials_managers.base.CryptoMaterialsManager :param key_provider: `MasterKeyProvider` from which to obtain data keys for decryption (either `materials_manager` or `key_provider` required) :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider :param int source_length: Length of source data (optional) .. note:: If source_length is not provided and read() is called, will attempt to seek() to the end of the stream and tell() to find the length of source data. :param int max_body_length: Maximum frame size (or content length for non-framed messages) in bytes to read from ciphertext message. cK s d|_dS(s"Prepares necessary initial values.iN(tlast_sequence_number(R$RN((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRscC sG|j\|_|_|jjtjkr:|jnt|_dS(sPerforms initial message setup.N( t _read_headerRVt header_authRRRRR-RJ(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR<s c C stjjjj|j\}}|jjdk r|j t j kr|j |jjkrt djd|j d|jjntd|jd|jd|j}|jjjd|}|jdkrd|_n!tjd|jd|j|_|jdk r|jj|ntjjjjd |jd|jd |j}td |jjd|jd |j|_tjjjjd |d|d|d|j||fS(sReads the message header from the input stream. :returns: tuple containing deserialized header and header_auth objects :rtype: tuple of aws_encryption_sdk.structures.MessageHeader and aws_encryption_sdk.internal.structures.MessageHeaderAuthentication :raises CustomMaximumValueExceeded: if frame length is greater than the custom max value sGFrame Size in header found larger than custom value: {found} > {custom}tfoundtcustomRR~R}RRtstreamtverifierRRRWRt raw_headerRN( R.R/Rt deserializetdeserialize_headerRKR>RR!RRRRRRBRRR~R}R tdecrypt_materialstverification_keyRR RRtdeserialize_header_authR RRRtvalidate_header(R$RWRtdecrypt_materials_requesttdecryption_materialsR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRsD!              c C sCtjjjjd|jd|jd|j\}}|_|j j dk r|j|j j krt dj d|jd|j j ntjjjd|jjdt}tjjjjd |jjd |d d d |j}td|jjd|jd|d|d||_|jj|_|j|j|_dS(s2Prepare the opening data for a non-framed message.RRWRsTNon-framed message content length found larger than custom value: {found} > {custom}RRRRRRRiRR~RRRRN(R.R/RRtdeserialize_non_framed_valuesRKRVRt body_lengthR>RR!RRBR0RRR-R}RRR R~Rt decryptorRPt body_starttbody_end(R$RRRR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRs2  '         cC s)tjd|j|jj}tjd|||jj|}t|jt||jkryt dn|j dk r|j j |n|j j |}||j j7}tjjjjd|jd|jd|j tjjjjd|jd|j |_|jj|S(sReads the requested number of bytes from a streaming non-framed message body. :param int b: Number of bytes to read :returns: Decrypted bytes from source stream :rtype: bytes sstarting non-framed body reads$%s bytes requested; reading %s bytessCTotal message body contents less than specified in body descriptionRRWRN(RZR`RRKRPRiRqRHRRRR!RRRR.R/RRtupdate_verifier_with_tagRVtdeserialize_footertfooterRY(R$Rgt bytes_to_readRR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt _read_bytes_from_non_framed_bodys& "     c C sd}t}tjd|xQt||kro| rotjdtjjjjd|j d|j d|j \}}tjd|j |j |j dkrtd n|j d7_ tjjjd |j jd |j}tjjjjd |j jd |d|j dt|j}|td|j jd|jd|d|7}tjdt|qW|rtjdtjjjjd|j d|j |_|j jn|S(sReads the requested number of bytes from a streaming framed message body. :param int b: Number of bytes to read :returns: Bytes read from source stream and decrypted :rtype: bytes R?scollecting %s bytess Reading frameRRWRsRead complete for frame %sis&Malformed message: frames out of orderRRRRRRR~Rtencrypted_dataRsbytes collected: %ssReading footer(RIRZR`RqR.R/RRtdeserialize_frameRKRVRRRRR0RRt final_frameR}RRRR R~RRRRY(R$RgRRt frame_dataRR((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt_read_bytes_from_framed_body/sD             cC s|jjrtjddS|t|jkrRtjd|t|jdS|jjtj kr|j|j |7_n<|jjtj kr|j|j |7_n t ddS(sReads the requested number of bytes from a streaming message body. :param int b: Number of bytes to read :raises NotSupportedError: if content type is not supported sSource stream closedNsF%s bytes requested less than or equal to current output buffer size %ssUnsupported content type(RKRcRZR`RqRHRVRRRRRRR(R$Rg((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyR;^s  cC sBtjdt|ds+tdntt|jdS(sCloses out the stream.sClosing streamRsFooter not readN(RZR`R@RRCRRY(R$((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRYws ( R(R)R*RR=RR<RRRRR;RY(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyRs   8 $  / (CR*t __future__RtabcRatloggingRR+R6taws_encryption_sdk.exceptionsRRRRRtaws_encryption_sdk.identifiersRRt1aws_encryption_sdk.internal.crypto.authenticationRR t,aws_encryption_sdk.internal.crypto.data_keysR t-aws_encryption_sdk.internal.crypto.encryptionR R R t%aws_encryption_sdk.internal.crypto.ivRt$aws_encryption_sdk.internal.defaultsRRRRRt2aws_encryption_sdk.internal.formatting.deserializeR.t9aws_encryption_sdk.internal.formatting.encryption_contextt0aws_encryption_sdk.internal.formatting.serializet!aws_encryption_sdk.internal.utilst%aws_encryption_sdk.key_providers.baseRt%aws_encryption_sdk.materials_managersRRt*aws_encryption_sdk.materials_managers.baseRt-aws_encryption_sdk.materials_managers.defaultRtaws_encryption_sdk.structuresRt getLoggerR(RZtsR-t add_metaclasstABCMetatobjectRtIOBaseR:RzRRRt__all__(((sO/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/streaming_client.pyt sN      ((    3/0