Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Fix wrapper registration in Factory classes.
Browse files Browse the repository at this point in the history
In preparation to the switch in the Registry where MutablePrimitiveRegistry will be used under the hood for wrapper registration, and this does not tolerate when a different wrapper object is attempted to be registered for a primitive class for which a wrapper object is already registered.

PiperOrigin-RevId: 495866076
  • Loading branch information
LizaTretyakova authored and copybara-github committed Dec 16, 2022
1 parent ef35b97 commit 3ab33de
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.crypto.tink.Aead;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class AeadFactory {
*/
@Deprecated
public static Aead getPrimitive(KeysetHandle keysetHandle) throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new AeadWrapper());
AeadWrapper.register();
return keysetHandle.getPrimitive(Aead.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ java_library(
deps = [
":aead_wrapper",
"//src/main/java/com/google/crypto/tink:aead",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand Down Expand Up @@ -418,7 +417,6 @@ android_library(
deps = [
":aead_wrapper-android",
"//src/main/java/com/google/crypto/tink:aead-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ java_library(
deps = [
":deterministic_aead_wrapper",
"//src/main/java/com/google/crypto/tink:deterministic_aead",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand All @@ -41,7 +40,6 @@ android_library(
deps = [
":deterministic_aead_wrapper-android",
"//src/main/java/com/google/crypto/tink:deterministic_aead-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.crypto.tink.DeterministicAead;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class DeterministicAeadFactory {
@Deprecated
public static DeterministicAead getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new DeterministicAeadWrapper());
DeterministicAeadWrapper.register();
return keysetHandle.getPrimitive(DeterministicAead.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ java_library(
deps = [
":hybrid_decrypt_wrapper",
"//src/main/java/com/google/crypto/tink:hybrid_decrypt",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand All @@ -168,7 +167,6 @@ java_library(
deps = [
":hybrid_encrypt_wrapper",
"//src/main/java/com/google/crypto/tink:hybrid_encrypt",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand Down Expand Up @@ -337,7 +335,6 @@ android_library(
deps = [
":hybrid_decrypt_wrapper-android",
"//src/main/java/com/google/crypto/tink:hybrid_decrypt-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand All @@ -348,7 +345,6 @@ android_library(
deps = [
":hybrid_encrypt_wrapper-android",
"//src/main/java/com/google/crypto/tink:hybrid_encrypt-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.crypto.tink.HybridDecrypt;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -45,7 +44,7 @@ public final class HybridDecryptFactory {
@Deprecated
public static HybridDecrypt getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new HybridDecryptWrapper());
HybridDecryptWrapper.register();
return keysetHandle.getPrimitive(HybridDecrypt.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.crypto.tink.HybridEncrypt;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class HybridEncryptFactory {
@Deprecated
public static HybridEncrypt getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new HybridEncryptWrapper());
HybridEncryptWrapper.register();
return keysetHandle.getPrimitive(HybridEncrypt.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Mac;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -47,7 +46,7 @@ public final class MacFactory {
*/
@Deprecated
public static Mac getPrimitive(KeysetHandle keysetHandle) throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new MacWrapper());
MacWrapper.register();
return keysetHandle.getPrimitive(Mac.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ java_library(
deps = [
":public_key_sign_wrapper",
"//src/main/java/com/google/crypto/tink:public_key_sign",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand Down Expand Up @@ -274,7 +273,6 @@ java_library(
deps = [
":public_key_verify_wrapper",
"//src/main/java/com/google/crypto/tink:public_key_verify",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
],
)
Expand Down Expand Up @@ -532,7 +530,6 @@ android_library(
deps = [
":public_key_sign_wrapper-android",
"//src/main/java/com/google/crypto/tink:public_key_sign-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand Down Expand Up @@ -630,7 +627,6 @@ android_library(
deps = [
":public_key_verify_wrapper-android",
"//src/main/java/com/google/crypto/tink:public_key_verify-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.PublicKeySign;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class PublicKeySignFactory {
@Deprecated
public static PublicKeySign getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new PublicKeySignWrapper());
PublicKeySignWrapper.register();
return keysetHandle.getPrimitive(PublicKeySign.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.PublicKeyVerify;
import com.google.crypto.tink.Registry;
import java.security.GeneralSecurityException;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public final class PublicKeyVerifyFactory {
@Deprecated
public static PublicKeyVerify getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new PublicKeyVerifyWrapper());
PublicKeyVerifyWrapper.register();
return keysetHandle.getPrimitive(PublicKeyVerify.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ java_library(
srcs = ["StreamingAeadFactory.java"],
deps = [
":streaming_aead_wrapper",
"//src/main/java/com/google/crypto/tink:registry",
"//src/main/java/com/google/crypto/tink:registry_cluster",
"//src/main/java/com/google/crypto/tink:streaming_aead",
],
Expand Down Expand Up @@ -220,7 +219,6 @@ android_library(
srcs = ["StreamingAeadFactory.java"],
deps = [
":streaming_aead_wrapper-android",
"//src/main/java/com/google/crypto/tink:registry-android",
"//src/main/java/com/google/crypto/tink:registry_cluster-android",
"//src/main/java/com/google/crypto/tink:streaming_aead-android",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.crypto.tink.streamingaead;

import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.Registry;
import com.google.crypto.tink.StreamingAead;
import java.security.GeneralSecurityException;

Expand All @@ -43,7 +42,7 @@ public final class StreamingAeadFactory {
*/
public static StreamingAead getPrimitive(KeysetHandle keysetHandle)
throws GeneralSecurityException {
Registry.registerPrimitiveWrapper(new StreamingAeadWrapper());
StreamingAeadWrapper.register();
return keysetHandle.getPrimitive(StreamingAead.class);
}

Expand Down

0 comments on commit 3ab33de

Please sign in to comment.