
    f                         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y))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                    }|dk  rt        d      || t         d fS # t        $ r d}Y (w xY w)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      M/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/openid/store/nonce.pyr   r      sc     !,/M8M8<=	 1},--l<=111	  	s   ? AAc                     	 t        |       \  }}|
t               }||z
  }||z   }||cxk  xr |k  S c S # t        $ r Y y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.
    F)r   r
   r   )r   allowed_skewnowstamp_pastfutures          r   r   r   -   sg    $'&q ;&C \! |# u&&&&&  s   6 	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   sA     !!![1D|H4L!$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  ""V]]2
 )*2, /3 "'Jr%   