Skip to content

Commit

Permalink
test: add invalid nonce test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnderScorer committed Jan 30, 2024
1 parent abc6318 commit 02b4d04
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/test_sealed.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ def test_unseal_empty_data(self):
DecryptionKey(self.invalid_key, DecryptionAlgorithm['Aes256Gcm']),
DecryptionKey(self.valid_key, DecryptionAlgorithm['Aes256Gcm']),
])

def test_unseal_invalid_nonce(self):
sealed_data = bytes([0x9E, 0x85, 0xDC, 0xED, 0xAA, 0xBB, 0xCC])

with self.assertRaisesRegex(Exception, 'Unable to decrypt sealed data') as context:
unseal_events_response(sealed_data, [
DecryptionKey(self.invalid_key, DecryptionAlgorithm['Aes256Gcm']),
DecryptionKey(self.valid_key, DecryptionAlgorithm['Aes256Gcm']),
])

exception: UnsealAggregateError = context.exception
error: UnsealError = exception.errors[1]

self.assertEqual(str(error.exception), 'initialization_vector must be between 8 and 128 bytes (64 and 1024 bits).')


0 comments on commit 02b4d04

Please sign in to comment.