How to use the tink.proto.tink_pb2.KeyTemplate 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 / signature / signature_key_templates.py View on Github external
def create_ecdsa_key_template(hash_type: common_pb2.HashType,
                              curve: common_pb2.EllipticCurveType,
                              encoding: ecdsa_pb2.EcdsaSignatureEncoding
                             ) -> tink_pb2.KeyTemplate:
  """Creates a KeyTemplate containing an EcdsaKeyFormat."""
  params = ecdsa_pb2.EcdsaParams(
      hash_type=hash_type, curve=curve, encoding=encoding)
  key_format = ecdsa_pb2.EcdsaKeyFormat(params=params)
  key_template = tink_pb2.KeyTemplate(
      value=key_format.SerializeToString(),
      type_url=_ECDSA_KEY_TYPE_URL,
      output_prefix_type=tink_pb2.TINK)

  return key_template
github google / tink / python / daead / deterministic_aead_key_templates.py View on Github external
def create_aes_siv_key_template(key_size: int) -> tink_pb2.KeyTemplate:
  """Creates an AES EAX KeyTemplate, and fills in its values."""
  key_format = aes_siv_pb2.AesSivKeyFormat()
  key_format.key_size = key_size
  key_template = tink_pb2.KeyTemplate()
  key_template.type_url = _AES_SIV_KEY_TYPE_URL
  key_template.output_prefix_type = tink_pb2.TINK
  key_template.value = key_format.SerializeToString()
  return key_template
github google / tink / python / hybrid / hybrid_key_templates.py View on Github external
def create_ecies_aead_hkdf_key_template(
    curve_type: common_pb2.EllipticCurveType,
    ec_point_format: common_pb2.EcPointFormat,
    hash_type: common_pb2.HashType,
    dem_key_template: tink_pb2.KeyTemplate) -> tink_pb2.KeyTemplate:
  """Creates a HMAC KeyTemplate, and fills in its values."""
  key_format = ecies_aead_hkdf_pb2.EciesAeadHkdfKeyFormat()
  key_format.params.kem_params.curve_type = curve_type
  key_format.params.kem_params.hkdf_hash_type = hash_type
  key_format.params.dem_params.aead_dem.CopyFrom(dem_key_template)
  key_format.params.ec_point_format = ec_point_format

  key_template = tink_pb2.KeyTemplate()
  key_template.type_url = (
      'type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey')
  key_template.value = key_format.SerializeToString()
  key_template.output_prefix_type = tink_pb2.TINK
  return key_template
github google / tink / python / aead / aead_key_templates.py View on Github external
def create_aes_gcm_key_template(key_size: int) -> tink_pb2.KeyTemplate:
  """Creates an AES GCM KeyTemplate, and fills in its values."""
  key_format = aes_gcm_pb2.AesGcmKeyFormat()
  key_format.key_size = key_size
  key_template = tink_pb2.KeyTemplate()
  key_template.value = key_format.SerializeToString()
  key_template.type_url = _AES_GCM_KEY_TYPE_URL
  key_template.output_prefix_type = tink_pb2.TINK
  return key_template
github google / tink / python / signature / signature_key_templates.py View on Github external
def create_rsa_ssa_pss_key_template(sig_hash: common_pb2.HashType,
                                    mgf1_hash: common_pb2.HashType,
                                    salt_length: int, modulus_size: int,
                                    public_exponent: int
                                   ) -> tink_pb2.KeyTemplate:
  """Creates a KeyTemplate containing an RsaSsaPssKeyFormat."""
  params = rsa_ssa_pss_pb2.RsaSsaPssParams(
      sig_hash=sig_hash, mgf1_hash=mgf1_hash, salt_length=salt_length)
  key_format = rsa_ssa_pss_pb2.RsaSsaPssKeyFormat(
      params=params,
      modulus_size_in_bits=modulus_size,
      public_exponent=_num_to_bytes(public_exponent))
  key_template = tink_pb2.KeyTemplate(
      value=key_format.SerializeToString(),
      type_url=_RSA_PSS_KEY_TYPE_URL,
      output_prefix_type=tink_pb2.TINK)

  return key_template
github google / tink / python / signature / signature_key_templates.py View on Github external
def create_rsa_ssa_pkcs1_key_template(hash_type: common_pb2.HashType,
                                      modulus_size: int, public_exponent: int
                                     ) -> tink_pb2.KeyTemplate:
  """Creates a KeyTemplate containing an RsaSsaPkcs1KeyFormat."""

  params = rsa_ssa_pkcs1_pb2.RsaSsaPkcs1Params(hash_type=hash_type)
  key_format = rsa_ssa_pkcs1_pb2.RsaSsaPkcs1KeyFormat(
      params=params,
      modulus_size_in_bits=modulus_size,
      public_exponent=_num_to_bytes(public_exponent))
  key_template = tink_pb2.KeyTemplate(
      value=key_format.SerializeToString(),
      type_url=_RSA_PKCS1_KEY_TYPE_URL,
      output_prefix_type=tink_pb2.TINK)

  return key_template
github google / tink / python / aead / aead_key_templates.py View on Github external
def create_aes_eax_key_template(key_size: int,
                                iv_size: int) -> tink_pb2.KeyTemplate:
  """Creates an AES EAX KeyTemplate, and fills in its values."""
  key_format = aes_eax_pb2.AesEaxKeyFormat()
  key_format.params.iv_size = iv_size
  key_format.key_size = key_size
  key_template = tink_pb2.KeyTemplate()
  key_template.value = key_format.SerializeToString()
  key_template.type_url = _AES_EAX_KEY_TYPE_URL
  key_template.output_prefix_type = tink_pb2.TINK
  return key_template