Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def from_cc_registry(type_url: Text) -> key_manager.KeyManager[aead.Aead]:
return key_manager.KeyManagerCcToPyWrapper(
cc_key_manager.AeadKeyManager.from_cc_registry(type_url), aead.Aead,
_AeadCcToPyWrapper)
from __future__ import division
from __future__ import print_function
from tink.python.core import crypto_format as _crypto_format
from tink.python.core import key_manager
from tink.python.core import keyset_handle
from tink.python.core import keyset_reader
from tink.python.core import keyset_writer
from tink.python.core import primitive_set
from tink.python.core import primitive_wrapper
from tink.python.core import registry
from tink.python.core import tink_error
KeyManager = key_manager.KeyManager
PrivateKeyManager = key_manager.PrivateKeyManager
KeysetHandle = keyset_handle.KeysetHandle
new_keyset_handle = KeysetHandle.generate_new
read_keyset_handle = KeysetHandle.read
read_no_secret_keyset_handle = KeysetHandle.read_no_secret
KeysetReader = keyset_reader.KeysetReader
JsonKeysetReader = keyset_reader.JsonKeysetReader
BinaryKeysetReader = keyset_reader.BinaryKeysetReader
KeysetWriter = keyset_writer.KeysetWriter
JsonKeysetWriter = keyset_writer.JsonKeysetWriter
BinaryKeysetWriter = keyset_writer.BinaryKeysetWriter
Registry = registry.Registry
def from_cc_registry(
type_url: Text) -> key_manager.KeyManager[streaming_aead.StreamingAead]:
return key_manager.KeyManagerCcToPyWrapper(
cc_key_manager.StreamingAeadKeyManager.from_cc_registry(type_url),
streaming_aead.StreamingAead, _StreamingAeadCcToPyWrapper)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tink.python.core import crypto_format as _crypto_format
from tink.python.core import key_manager
from tink.python.core import keyset_handle
from tink.python.core import keyset_reader
from tink.python.core import keyset_writer
from tink.python.core import primitive_set
from tink.python.core import primitive_wrapper
from tink.python.core import registry
from tink.python.core import tink_error
KeyManager = key_manager.KeyManager
PrivateKeyManager = key_manager.PrivateKeyManager
KeysetHandle = keyset_handle.KeysetHandle
new_keyset_handle = KeysetHandle.generate_new
read_keyset_handle = KeysetHandle.read
read_no_secret_keyset_handle = KeysetHandle.read_no_secret
KeysetReader = keyset_reader.KeysetReader
JsonKeysetReader = keyset_reader.JsonKeysetReader
BinaryKeysetReader = keyset_reader.BinaryKeysetReader
KeysetWriter = keyset_writer.KeysetWriter
JsonKeysetWriter = keyset_writer.JsonKeysetWriter
BinaryKeysetWriter = keyset_writer.BinaryKeysetWriter
Registry = registry.Registry
def public_key_data(cls,
private_key_data: tink_pb2.KeyData) -> tink_pb2.KeyData:
"""Generates a new key for the specified key_template."""
if (private_key_data.key_material_type !=
tink_pb2.KeyData.ASYMMETRIC_PRIVATE):
raise tink_error.TinkError('The keyset contains a non-private key')
key_mgr = cls.key_manager(private_key_data.type_url)
if not isinstance(key_mgr, km_module.PrivateKeyManager):
raise tink_error.TinkError(
'manager for key type {} is not a PrivateKeyManager'
.format(private_key_data.type_url))
return key_mgr.public_key_data(private_key_data)