Make all remaining symmetric key managers public; their constructor package private, and add a static method "register()".

Also do the same transformation to the wrappers and use the new functions in the config.

PiperOrigin-RevId: 269555278
diff --git a/java/src/main/java/com/google/crypto/tink/daead/AesSivKeyManager.java b/java/src/main/java/com/google/crypto/tink/daead/AesSivKeyManager.java
index 58abdaa..311dcb9 100644
--- a/java/src/main/java/com/google/crypto/tink/daead/AesSivKeyManager.java
+++ b/java/src/main/java/com/google/crypto/tink/daead/AesSivKeyManager.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.DeterministicAead;
 import com.google.crypto.tink.KeyTypeManager;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.proto.AesSivKey;
 import com.google.crypto.tink.proto.AesSivKeyFormat;
 import com.google.crypto.tink.proto.KeyData.KeyMaterialType;
@@ -34,8 +35,8 @@
  * This key manager generates new {@code AesSivKey} keys and produces new instances of {@code
  * AesSiv}.
  */
-class AesSivKeyManager extends KeyTypeManager<AesSivKey> {
-  public AesSivKeyManager() {
+public class AesSivKeyManager extends KeyTypeManager<AesSivKey> {
+  AesSivKeyManager() {
     super(
         AesSivKey.class,
         new PrimitiveFactory<DeterministicAead, AesSivKey>(DeterministicAead.class) {
@@ -101,4 +102,8 @@
       }
     };
   }
+
+  public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
+    Registry.registerKeyManager(new AesSivKeyManager(), newKeyAllowed);
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadConfig.java b/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadConfig.java
index 2b77369..b81a9e1 100644
--- a/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadConfig.java
+++ b/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadConfig.java
@@ -80,7 +80,7 @@
    * @since 1.2.0
    */
   public static void register() throws GeneralSecurityException {
-    Registry.registerKeyManager(new AesSivKeyManager(), /* newKeyAllowed = */ true);
-    Registry.registerPrimitiveWrapper(new DeterministicAeadWrapper());
+    AesSivKeyManager.register(/* newKeyAllowed = */ true);
+    DeterministicAeadWrapper.register();
   }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadWrapper.java b/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadWrapper.java
index 04cccf1..089561a 100644
--- a/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadWrapper.java
+++ b/java/src/main/java/com/google/crypto/tink/daead/DeterministicAeadWrapper.java
@@ -20,6 +20,7 @@
 import com.google.crypto.tink.DeterministicAead;
 import com.google.crypto.tink.PrimitiveSet;
 import com.google.crypto.tink.PrimitiveWrapper;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.subtle.Bytes;
 import java.security.GeneralSecurityException;
 import java.util.Arrays;
@@ -35,7 +36,7 @@
  * select the right key in the set. If the keys associated with the prefix do not work, the
  * primitive tries all keys with {@link com.google.crypto.tink.proto.OutputPrefixType#RAW}.
  */
-class DeterministicAeadWrapper implements PrimitiveWrapper<DeterministicAead> {
+public class DeterministicAeadWrapper implements PrimitiveWrapper<DeterministicAead> {
   private static final Logger logger = Logger.getLogger(DeterministicAeadWrapper.class.getName());
 
   private static class WrappedDeterministicAead implements DeterministicAead {
@@ -90,6 +91,8 @@
     }
   }
 
+  DeterministicAeadWrapper() {}
+
   @Override
   public DeterministicAead wrap(final PrimitiveSet<DeterministicAead> primitives) {
     return new WrappedDeterministicAead(primitives);
@@ -99,4 +102,8 @@
   public Class<DeterministicAead> getPrimitiveClass() {
     return DeterministicAead.class;
   }
+
+  public static void register() throws GeneralSecurityException {
+    Registry.registerPrimitiveWrapper(new DeterministicAeadWrapper());
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java b/java/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
index 95d5c42..5823b32 100644
--- a/java/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
+++ b/java/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.KeyTypeManager;
 import com.google.crypto.tink.Mac;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.proto.AesCmacKey;
 import com.google.crypto.tink.proto.AesCmacKeyFormat;
 import com.google.crypto.tink.proto.AesCmacParams;
@@ -33,9 +34,9 @@
  * This key manager generates new {@code AesCmacKey} keys and produces new instances of {@code
  * AesCmac}.
  */
-class AesCmacKeyManager extends KeyTypeManager<AesCmacKey> {
+public class AesCmacKeyManager extends KeyTypeManager<AesCmacKey> {
 
-  public AesCmacKeyManager() {
+  AesCmacKeyManager() {
     super(
         AesCmacKey.class,
         new PrimitiveFactory<Mac, AesCmacKey>(Mac.class) {
@@ -118,4 +119,8 @@
       }
     };
   }
+
+  public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
+    Registry.registerKeyManager(new AesCmacKeyManager(), newKeyAllowed);
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/mac/HmacKeyManager.java b/java/src/main/java/com/google/crypto/tink/mac/HmacKeyManager.java
index 73f43cc..cd9429c 100644
--- a/java/src/main/java/com/google/crypto/tink/mac/HmacKeyManager.java
+++ b/java/src/main/java/com/google/crypto/tink/mac/HmacKeyManager.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.KeyTypeManager;
 import com.google.crypto.tink.Mac;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.proto.HashType;
 import com.google.crypto.tink.proto.HmacKey;
 import com.google.crypto.tink.proto.HmacKeyFormat;
@@ -148,4 +149,8 @@
       }
     };
   }
+
+  public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
+    Registry.registerKeyManager(new HmacKeyManager(), newKeyAllowed);
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/mac/MacConfig.java b/java/src/main/java/com/google/crypto/tink/mac/MacConfig.java
index 29fd052..802a70a 100644
--- a/java/src/main/java/com/google/crypto/tink/mac/MacConfig.java
+++ b/java/src/main/java/com/google/crypto/tink/mac/MacConfig.java
@@ -83,9 +83,9 @@
    * @since 1.2.0
    */
   public static void register() throws GeneralSecurityException {
-    Registry.registerKeyManager(new HmacKeyManager(), true);
-    Registry.registerKeyManager(new AesCmacKeyManager(), true);
-    Registry.registerPrimitiveWrapper(new MacWrapper());
+    HmacKeyManager.register(true);
+    AesCmacKeyManager.register(true);
+    MacWrapper.register();
   }
 
   /**
diff --git a/java/src/main/java/com/google/crypto/tink/mac/MacWrapper.java b/java/src/main/java/com/google/crypto/tink/mac/MacWrapper.java
index ee04630..1d0f68b 100644
--- a/java/src/main/java/com/google/crypto/tink/mac/MacWrapper.java
+++ b/java/src/main/java/com/google/crypto/tink/mac/MacWrapper.java
@@ -20,6 +20,7 @@
 import com.google.crypto.tink.Mac;
 import com.google.crypto.tink.PrimitiveSet;
 import com.google.crypto.tink.PrimitiveWrapper;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.proto.OutputPrefixType;
 import com.google.crypto.tink.subtle.Bytes;
 import java.security.GeneralSecurityException;
@@ -100,6 +101,8 @@
     }
   }
 
+  MacWrapper() {}
+
   @Override
   public Mac wrap(final PrimitiveSet<Mac> primitives) throws GeneralSecurityException {
     return new WrappedMac(primitives);
@@ -109,4 +112,8 @@
   public Class<Mac> getPrimitiveClass() {
     return Mac.class;
   }
+
+ public static void register() throws GeneralSecurityException {
+    Registry.registerPrimitiveWrapper(new MacWrapper());
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/streamingaead/AesCtrHmacStreamingKeyManager.java b/java/src/main/java/com/google/crypto/tink/streamingaead/AesCtrHmacStreamingKeyManager.java
index 75bfe83..a8aaeee 100644
--- a/java/src/main/java/com/google/crypto/tink/streamingaead/AesCtrHmacStreamingKeyManager.java
+++ b/java/src/main/java/com/google/crypto/tink/streamingaead/AesCtrHmacStreamingKeyManager.java
@@ -17,6 +17,7 @@
 package com.google.crypto.tink.streamingaead;
 
 import com.google.crypto.tink.KeyTypeManager;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.StreamingAead;
 import com.google.crypto.tink.proto.AesCtrHmacStreamingKey;
 import com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat;
@@ -35,8 +36,8 @@
  * This key manager generates new {@code AesCtrHmacStreamingKey} keys and produces new instances of
  * {@code AesCtrHmacStreaming}.
  */
-class AesCtrHmacStreamingKeyManager extends KeyTypeManager<AesCtrHmacStreamingKey> {
-  public AesCtrHmacStreamingKeyManager() {
+public class AesCtrHmacStreamingKeyManager extends KeyTypeManager<AesCtrHmacStreamingKey> {
+  AesCtrHmacStreamingKeyManager() {
     super(
         AesCtrHmacStreamingKey.class,
         new PrimitiveFactory<StreamingAead, AesCtrHmacStreamingKey>(StreamingAead.class) {
@@ -171,4 +172,8 @@
         throw new GeneralSecurityException("unknown hash type");
     }
   }
+
+  public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
+    Registry.registerKeyManager(new AesCtrHmacStreamingKeyManager(), newKeyAllowed);
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.java b/java/src/main/java/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.java
index c9ccf6c..7c15647 100644
--- a/java/src/main/java/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.java
+++ b/java/src/main/java/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.java
@@ -17,6 +17,7 @@
 package com.google.crypto.tink.streamingaead;
 
 import com.google.crypto.tink.KeyTypeManager;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.StreamingAead;
 import com.google.crypto.tink.proto.AesGcmHkdfStreamingKey;
 import com.google.crypto.tink.proto.AesGcmHkdfStreamingKeyFormat;
@@ -34,8 +35,8 @@
  * This key manager generates new {@code AesGcmHkdfStreamingKey} keys and produces new instances of
  * {@code AesGcmHkdfStreaming}.
  */
-class AesGcmHkdfStreamingKeyManager extends KeyTypeManager<AesGcmHkdfStreamingKey> {
-  public AesGcmHkdfStreamingKeyManager() {
+public class AesGcmHkdfStreamingKeyManager extends KeyTypeManager<AesGcmHkdfStreamingKey> {
+  AesGcmHkdfStreamingKeyManager() {
     super(
         AesGcmHkdfStreamingKey.class,
         new PrimitiveFactory<StreamingAead, AesGcmHkdfStreamingKey>(StreamingAead.class) {
@@ -126,4 +127,8 @@
               + "TAG_SIZE_IN_BYTES + 2)");
     }
   }
+
+  public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
+    Registry.registerKeyManager(new AesGcmHkdfStreamingKeyManager(), newKeyAllowed);
+  }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadConfig.java b/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadConfig.java
index cad2dae..7994922 100644
--- a/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadConfig.java
+++ b/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadConfig.java
@@ -74,8 +74,8 @@
    * @since 1.2.0
    */
   public static void register() throws GeneralSecurityException {
-    Registry.registerKeyManager(new AesCtrHmacStreamingKeyManager(), /* newKeyAllowed = */ true);
-    Registry.registerKeyManager(new AesGcmHkdfStreamingKeyManager(), /* newKeyAllowed = */ true);
-    Registry.registerPrimitiveWrapper(new StreamingAeadWrapper());
+    AesCtrHmacStreamingKeyManager.register(/* newKeyAllowed = */ true);
+    AesGcmHkdfStreamingKeyManager.register(/* newKeyAllowed = */ true);
+    StreamingAeadWrapper.register();
   }
 }
diff --git a/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadWrapper.java b/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadWrapper.java
index ab4cc55..c619ad5 100644
--- a/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadWrapper.java
+++ b/java/src/main/java/com/google/crypto/tink/streamingaead/StreamingAeadWrapper.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.PrimitiveSet;
 import com.google.crypto.tink.PrimitiveWrapper;
+import com.google.crypto.tink.Registry;
 import com.google.crypto.tink.StreamingAead;
 import java.security.GeneralSecurityException;
 
@@ -29,7 +30,9 @@
  * keyset to select the right key for decryption. All keys in a keyset of StreamingAead have type
  * {@link com.google.crypto.tink.proto.OutputPrefixType#RAW}.
  */
-class StreamingAeadWrapper implements PrimitiveWrapper<StreamingAead> {
+public class StreamingAeadWrapper implements PrimitiveWrapper<StreamingAead> {
+  StreamingAeadWrapper() {}
+
   /**
    * @return a StreamingAead primitive from a {@code keysetHandle}.
    * @throws GeneralSecurityException
@@ -44,4 +47,8 @@
   public Class<StreamingAead> getPrimitiveClass() {
     return StreamingAead.class;
   }
+
+  public static void register() throws GeneralSecurityException {
+    Registry.registerPrimitiveWrapper(new StreamingAeadWrapper());
+  }
 }