Exemple #1
0
def register():
    """Registers all Hybrid key managers and wrapper in the Python Registry."""
    tink_bindings.register()
    tink_bindings.register_hpke()

    # Register primitive wrappers.
    core.Registry.register_primitive_wrapper(
        _hybrid_wrapper.HybridDecryptWrapper())
    core.Registry.register_primitive_wrapper(
        _hybrid_wrapper.HybridEncryptWrapper())

    # Register ECIES-AEAD-HKDF key managers.
    decrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey')
    decrypt_key_manager = core.PrivateKeyManagerCcToPyWrapper(
        tink_bindings.HybridDecryptKeyManager.from_cc_registry(
            decrypt_type_url), _hybrid_decrypt.HybridDecrypt,
        _HybridDecryptCcToPyWrapper)
    core.Registry.register_key_manager(decrypt_key_manager,
                                       new_key_allowed=True)

    encrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey')
    encrypt_key_manager = core.KeyManagerCcToPyWrapper(
        tink_bindings.HybridEncryptKeyManager.from_cc_registry(
            encrypt_type_url), _hybrid_encrypt.HybridEncrypt,
        _HybridEncryptCcToPyWrapper)
    core.Registry.register_key_manager(encrypt_key_manager,
                                       new_key_allowed=True)

    # Register HPKE key managers.
    hpke_decrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.HpkePrivateKey')
    hpke_decrypt_key_manager = core.PrivateKeyManagerCcToPyWrapper(
        tink_bindings.HybridDecryptKeyManager.from_cc_registry(
            hpke_decrypt_type_url), _hybrid_decrypt.HybridDecrypt,
        _HybridDecryptCcToPyWrapper)
    core.Registry.register_key_manager(hpke_decrypt_key_manager,
                                       new_key_allowed=True)

    hpke_encrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.HpkePublicKey')
    hpke_encrypt_key_manager = core.KeyManagerCcToPyWrapper(
        tink_bindings.HybridEncryptKeyManager.from_cc_registry(
            hpke_encrypt_type_url), _hybrid_encrypt.HybridEncrypt,
        _HybridEncryptCcToPyWrapper)
    core.Registry.register_key_manager(hpke_encrypt_key_manager,
                                       new_key_allowed=True)
def register():
    """Registers all signature key managers in the Python registry."""
    tink_bindings.register()

    for key_type_identifier in (
            'EcdsaPrivateKey',
            'Ed25519PrivateKey',
            'RsaSsaPssPrivateKey',
            'RsaSsaPkcs1PrivateKey',
    ):
        type_url = 'type.googleapis.com/google.crypto.tink.' + key_type_identifier
        key_manager = core.PrivateKeyManagerCcToPyWrapper(
            tink_bindings.PublicKeySignKeyManager.from_cc_registry(type_url),
            _public_key_sign.PublicKeySign, _PublicKeySignCcToPyWrapper)
        core.Registry.register_key_manager(key_manager, new_key_allowed=True)

    for key_type_identifier in (
            'EcdsaPublicKey',
            'Ed25519PublicKey',
            'RsaSsaPssPublicKey',
            'RsaSsaPkcs1PublicKey',
    ):
        type_url = 'type.googleapis.com/google.crypto.tink.' + key_type_identifier
        key_manager = core.KeyManagerCcToPyWrapper(
            tink_bindings.PublicKeyVerifyKeyManager.from_cc_registry(type_url),
            _public_key_verify.PublicKeyVerify, _PublicKeyVerifyCcToPyWrapper)
        core.Registry.register_key_manager(key_manager, new_key_allowed=True)

    core.Registry.register_primitive_wrapper(
        _signature_wrapper.PublicKeySignWrapper())
    core.Registry.register_primitive_wrapper(
        _signature_wrapper.PublicKeyVerifyWrapper())
Exemple #3
0
def register():
    """Registers all Hybrid key managers and wrapper in the Python Registry."""
    cc_tink_config.register()

    decrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey')
    decrypt_key_manager = core.PrivateKeyManagerCcToPyWrapper(
        cc_key_manager.HybridDecryptKeyManager.from_cc_registry(
            decrypt_type_url), _hybrid_decrypt.HybridDecrypt,
        _HybridDecryptCcToPyWrapper)
    core.Registry.register_key_manager(decrypt_key_manager,
                                       new_key_allowed=True)
    core.Registry.register_primitive_wrapper(
        _hybrid_wrapper.HybridDecryptWrapper())

    encrypt_type_url = (
        'type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey')
    encrypt_key_manager = core.KeyManagerCcToPyWrapper(
        cc_key_manager.HybridEncryptKeyManager.from_cc_registry(
            encrypt_type_url), _hybrid_encrypt.HybridEncrypt,
        _HybridEncryptCcToPyWrapper)
    core.Registry.register_key_manager(encrypt_key_manager,
                                       new_key_allowed=True)
    core.Registry.register_primitive_wrapper(
        _hybrid_wrapper.HybridEncryptWrapper())
def from_cc_registry(
    type_url: Text
) -> core.PrivateKeyManager[public_key_sign.PublicKeySign]:
  return core.PrivateKeyManagerCcToPyWrapper(
      cc_key_manager.PublicKeySignKeyManager.from_cc_registry(type_url),
      public_key_sign.PublicKeySign, _PublicKeySignCcToPyWrapper)