
    Ii                     D    S r SSKrSSKrSSKJr  SSKJr   " S S5      rg)zj
Provides AWS4SigningKey class for generating Amazon Web Services
authentication version 4 signing keys.

    N)warn)datetimec                   \    \ rS rSrSr  S	S jr\ S
S j5       r\S 5       r	\
S 5       rSrg)AWS4SigningKey   a  
AWS signing key. Used to sign AWS authentication strings.

The secret key is stored in the instance after instantiation, this can be
changed via the store_secret_key argument, see below for details.

Methods:
generate_key() -- Generate AWS4 Signing Key string
sign_sha256()  -- Generate SHA256 HMAC signature, encoding message to bytes
                  first if required

Attributes:
region   -- AWS region the key is scoped for
service  -- AWS service the key is scoped for
date     -- Date the key is scoped for
scope    -- The AWS scope string for this key, calculated from the above
            attributes
key      -- The signing key string itself

amz_date -- Deprecated name for 'date'. Use the 'date' attribute instead.
            amz_date will be removed in a future version.

Nc                    X l         X0l        U=(       d$    [        R                  " 5       R	                  S5      U l        SR                  U R
                  U R                   U R                  5      U l        XPl        U R                  (       a  UOSU l	        U R                  XR                   U R                  U R
                  5      U l        g)ag  
>>> AWS4SigningKey(secret_key, region, service[, date]
...                [, store_secret_key])

secret_key -- This is your AWS secret access key
region     -- The region you're connecting to, as per list at
              http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
              e.g. us-east-1. For services which don't require a
              region (e.g. IAM), use us-east-1.
service    -- The name of the service you're connecting to, as per
              endpoints at:
              http://docs.aws.amazon.com/general/latest/gr/rande.html
              e.g. elasticbeanstalk
date       -- 8-digit date of the form YYYYMMDD. Key is only valid for
              requests with a Date or X-Amz-Date header matching this
              date. If date is not supplied the current date is
              used.
store_secret_key
           -- Whether the secret key is stored in the instance. By
              default this is True, meaning the key is stored in
              the secret_key property and is available to any
              code the instance is passed to. Having the secret
              key retained makes it easier to regenerate the key
              if a scope parameter changes (usually the date).
              This is used by the AWS4Auth class to perform its
              automatic key updates when a request date/scope date
              mismatch is encountered.

              If you are passing instances to untrusted code you can
              set this to False. This will cause the secret key to be
              discarded as soon as the signing key has been generated.
              Note though that you will need to manually regenerate
              keys when needed (or if you use the regenerate_key()
              method on an AWS4Auth instance you will need to pass it
              the secret key).

All arguments should be supplied as strings.

z%Y%m%dz{}/{}/{}/aws4_requestN)regionservicer   utcnowstrftimedateformatscopestore_secret_key
secret_keygenerate_keykey)selfr   r	   r
   r   r   s         F/venv/lib/python3.13/site-packages/requests_aws4auth/aws4signingkey.py__init__AWS4SigningKey.__init__)   s    T @HOO-66x@	,33DIIt{{DLLY
 0(,(=(=*4$$ZdllDIIV    c                     SU-   R                  S5      nU R                  Xd5      nU R                  Xr5      nU R                  X5      n	U R                  U	S5      n
U(       a  XX4$ U
$ )a  
Generate the signing key string as bytes.

If intermediate is set to True, returns a 4-tuple containing the key
and the intermediate keys:

( signing_key, date_key, region_key, service_key )

The intermediate keys can be used for testing against examples from
Amazon.

AWS4utf-8aws4_request)encodesign_sha256)clsr   r	   r
   r   intermediatesinit_keydate_key
region_keyservice_keyr   s              r   r   AWS4SigningKey.generate_key[   sf     Z'//8??82__X6
ooj:ook>::;;Jr   c                     [        U[        5      (       a  UR                  S5      n[        R                  " X[
        R                  5      R                  5       $ )z
Generate an SHA256 HMAC, encoding msg to UTF-8 if not
already encoded.

key -- signing key. bytes.
msg -- message to sign. unicode or bytes.

r   )
isinstancestrr   hmacnewhashlibsha256digest)r   msgs     r   r   AWS4SigningKey.sign_sha256t   s=     c3**W%Cxx'..188::r   c                 >    Sn[        U[        5        U R                  $ )NzlThis attribute has been renamed to 'date'. 'amz_date' is deprecated and will be removed in a future version.)r   DeprecationWarningr   )r   r.   s     r   amz_dateAWS4SigningKey.amz_date   s    ES$%yyr   )r   r   r	   r   r   r
   r   )NT)F)__name__
__module____qualname____firstlineno____doc__r   classmethodr   staticmethodr   propertyr2   __static_attributes__ r   r   r   r      sU    0 :>"&0Wd #( 0 ; ;  r   r   )r8   r)   r+   warningsr   r   r   r=   r   r   <module>r?      s$       w wr   