Skip to content
Snippets Groups Projects
Select Git revision
0 results

cryptography

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    Jakub Stasiak authored
    * Disallow ttl=None in (Multi)Fernet.decrypt_at_time()
    
    Since the introduction of the _at_time() methods in #5256[1] there's
    been this little voice in the back of my mind telling me that maybe it's
    not the best idea to allow ttl=None in decrypt_at_time(). It's been like
    this for convenience and code reuse reasons.
    
    Then I submitted a patch for cryptography stubs in typeshed[2] and I had
    to decide whether to define decrypt_at_time()'s ttl as int and be
    incompatible with cryptography's behavior or Optional[int] and advertise
    an API that can be misused much too easily. I went ahead with int.
    
    Considering the above I decided to propose this patch. Some amount of
    redundancy (and a new test to properly cover the
    MultiFernet.decrypt_at_time() implementation) is a price to prevent
    clients from shooting themselves in the foot with the tll=None gun since
    setting ttl to None disabled timestamp checks even if current_time was
    provided.
    
    [1] https://github.com/pyca/cryptography/pull/5256
    [2] https://github.com/python/typeshed/pull/4238
    
    * Actually test the return value here
    
    * Fix formatting
    7e30f0f9
    History
    Name Last commit Last update