How to use the tink.python.core.primitive_set.PrimitiveSet function in tink

To help you get started, we’ve selected a few tink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / tink / python / core / View on Github external
cls, wrapper: primitive_wrapper.PrimitiveWrapper) -> None:
    """Tries to register a PrimitiveWrapper.

      wrapper: A PrimitiveWrapper object.
      Error if a different wrapper has already been registered for the same
    if (wrapper.primitive_class() in cls._wrappers and
        type(cls._wrappers[wrapper.primitive_class()]) != type(wrapper)):  # pylint: disable=unidiomatic-typecheck
      raise tink_error.TinkError(
          'A wrapper for primitive {} has already been added.'.format(
    wrapped = wrapper.wrap(
    if not isinstance(wrapped, wrapper.primitive_class()):
      raise tink_error.TinkError(
          'Wrapper for primitive {} generates incompatible primitive of type {}'
    cls._wrappers[wrapper.primitive_class()] = wrapper
github google / tink / python / core / View on Github external
Uses the KeyManager and the PrimitiveWrapper objects in the global
    to create the primitive. This function is the most common way of creating a

      primitive_class: The class of the primitive.

      The primitive.
      tink.TinkError if creation of the primitive fails, for example if
      primitive_class cannot be used with this KeysetHandle.
    pset = primitive_set.PrimitiveSet(primitive_class)
    for key in self._keyset.key:
      if key.status == tink_pb2.ENABLED:
        primitive = registry.Registry.primitive(key.key_data, primitive_class)
        entry = pset.add_primitive(primitive, key)
        if key.key_id == self._keyset.primary_key_id:
    return registry.Registry.wrap(pset)
github google / tink / python / core / View on Github external
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

TinkError = tink_error.TinkError

new_primitive_set = primitive_set.new_primitive_set
PrimitiveSet = primitive_set.PrimitiveSet
PrimitiveWrapper = primitive_wrapper.PrimitiveWrapper

crypto_format = _crypto_format