
    )Jf                         g d Z ddlmZ ddlmZmZmZmZ ddlmZ ddl	Z	e	j
        e	j        z   ZdZdZ ed          Zd	 Zedfd
ZddZdS ))splitmkNoncecheckTimestamp    )	cryptutil)strptimestrftimegmtimetime)timegmNiPF  z%Y-%m-%dT%H:%M:%SZz0000-00-00T00:00:00Zc                     | dt                    }	 t          t          |t                              }n# t          $ r d}Y nw xY w|dk     rt          d          || t           d         fS )aZ  Extract a timestamp from the given nonce string

    @param nonce_string: the nonce from which to extract the timestamp
    @type nonce_string: str

    @returns: A pair of a Unix timestamp and the salt characters
    @returntype: (int, str)

    @raises ValueError: if the nonce does not start with a correctly
        formatted time string
    Nr   ztime out of range)time_str_lenr   r   time_fmtAssertionError
ValueError)nonce_stringtimestamp_str	timestamps      U/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/openid/store/nonce.pyr   r      s     !,/M8M8<<==		   			1}},---l<==111s   "4 AAc                     	 t          |           \  }}|t                      }||z
  }||z   }||cxk    o|k    nc S # t          $ r Y dS w xY w)a8  Is the timestamp that is part of the specified nonce string
    within the allowed clock-skew of the current time?

    @param nonce_string: The nonce that is being checked
    @type nonce_string: str

    @param allowed_skew: How many seconds should be allowed for
        completing the request, allowing for clock skew.
    @type allowed_skew: int

    @param now: The current time, as a Unix timestamp
    @type now: int

    @returntype: bool
    @returns: Whether the timestamp is correctly formatted and within
        the allowed skew of the current time.
    NF)r   r
   r   )r   allowed_skewnowstamp_pastfutures          r   r   r   -   s    $'&&q ;&&C \! |# u&&&&&&&&&    uus   > 
AAc                     t          j        dt                    }| t                      }nt          |           }t	          t
          |          }||z   S )a  Generate a nonce with the current timestamp

    @param when: Unix timestamp representing the issue time of the
        nonce. Defaults to the current time.
    @type when: int

    @returntype: str
    @returns: A string that should be usable as a one-way nonce

    @see: time
       )r   randomStringNONCE_CHARSr	   r   r   )whensaltttime_strs       r   r   r   R   sJ     !![11D|HH4LL!$$Hd?    )N)__all__openidr   r
   r   r   r	   calendarr   stringascii_lettersdigitsr    SKEWr   lenr   r   r   r    r%   r   <module>r/      s            1 1 1 1 1 1 1 1 1 1 1 1       "V]2
 s)**2 2 2, /3 "' "' "' "'J     r%   