コード例 #1
0
ファイル: helper_test.py プロジェクト: bsmr/google-tink
 def test_fake_hybrid_fail_wrong_dec(self):
   enc = helper.FakeHybridEncrypt('Name')
   dec = helper.FakeHybridDecrypt('Wrong Name')
   ciphertext = enc.encrypt(b'plaintext', b'context_info')
   with self.assertRaisesRegex(tink_error.TinkError,
                               'failed to decrypt ciphertext'):
     dec.decrypt(ciphertext, b'context_info')
コード例 #2
0
ファイル: helper_test.py プロジェクト: bsmr/google-tink
 def test_fake_hybrid_success(self):
   enc = helper.FakeHybridEncrypt('Name')
   dec = helper.FakeHybridDecrypt('Name')
   ciphertext = enc.encrypt(b'plaintext', b'context_info')
   self.assertEqual(
       dec.decrypt(ciphertext, b'context_info'),
       b'plaintext')
コード例 #3
0
def new_primitives_and_keys(key_id, output_prefix_type):
    fake_dec_key = helper.fake_key(
        key_material_type=tink_pb2.KeyData.ASYMMETRIC_PRIVATE,
        key_id=key_id,
        output_prefix_type=output_prefix_type)
    fake_enc_key = helper.fake_key(
        key_material_type=tink_pb2.KeyData.ASYMMETRIC_PUBLIC,
        key_id=key_id,
        output_prefix_type=output_prefix_type)
    fake_hybrid_decrypt = helper.FakeHybridDecrypt(
        'fakeHybrid {}'.format(key_id))
    fake_hybrid_encrypt = helper.FakeHybridEncrypt(
        'fakeHybrid {}'.format(key_id))
    return fake_hybrid_decrypt, fake_hybrid_encrypt, fake_dec_key, fake_enc_key
コード例 #4
0
ファイル: helper_test.py プロジェクト: bsmr/google-tink
 def test_fake_hybrid_fail_wrong_ciphertext(self):
   dec = helper.FakeHybridDecrypt('Name')
   with self.assertRaisesRegex(tink_error.TinkError,
                               'failed to decrypt ciphertext'):
     dec.decrypt(b'wrong ciphertext', b'context_info')