1# Copyright 2022 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS-IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Test for create_keyset.""" 15from absl.testing import absltest 16 17from tink import aead 18 19import create_keyset 20 21 22class CreateKeysetTest(absltest.TestCase): 23 24 def test_create_keyset_produces_a_valid_keyset(self): 25 aead.register() 26 keyset_handle = create_keyset.CreateAead128GcmKeyset() 27 # Make sure that we can use this primitive. 28 aead_primitive = keyset_handle.primitive(aead.Aead) 29 cleartext = b'Some cleartext' 30 associated_data = b'Some associated data' 31 ciphertext = aead_primitive.encrypt(cleartext, associated_data) 32 self.assertEqual( 33 aead_primitive.decrypt(ciphertext, associated_data), cleartext) 34 35 36if __name__ == '__main__': 37 absltest.main() 38