Add support for full Mac primitive creation to AesCmacKeyManager. Remove now-unnecessary setup in the corresponding test.

PiperOrigin-RevId: 544356043
Change-Id: I2c91bb84b4a814ca31f10ef74b87d53392580a20
diff --git a/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java b/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
index 3407f90..28268a6 100644
--- a/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
+++ b/src/main/java/com/google/crypto/tink/mac/AesCmacKeyManager.java
@@ -67,6 +67,12 @@
               ChunkedAesCmacImpl::new,
               com.google.crypto.tink.mac.AesCmacKey.class,
               ChunkedMac.class);
+  private static final PrimitiveConstructor<com.google.crypto.tink.mac.AesCmacKey, Mac>
+      MAC_PRIMITIVE_CONSTRUCTOR =
+      PrimitiveConstructor.create(
+          PrfMac::create,
+          com.google.crypto.tink.mac.AesCmacKey.class,
+          Mac.class);
 
   @Override
   public String getKeyType() {
@@ -172,6 +178,8 @@
     AesCmacProtoSerialization.register();
     MutablePrimitiveRegistry.globalInstance()
         .registerPrimitiveConstructor(CHUNKED_MAC_PRIMITIVE_CONSTRUCTOR);
+    MutablePrimitiveRegistry.globalInstance()
+        .registerPrimitiveConstructor(MAC_PRIMITIVE_CONSTRUCTOR);
   }
 
   /**
diff --git a/src/test/java/com/google/crypto/tink/KeysetHandleFullPrimitiveTest.java b/src/test/java/com/google/crypto/tink/KeysetHandleFullPrimitiveTest.java
index d6eb4c1..3039bdf 100644
--- a/src/test/java/com/google/crypto/tink/KeysetHandleFullPrimitiveTest.java
+++ b/src/test/java/com/google/crypto/tink/KeysetHandleFullPrimitiveTest.java
@@ -33,8 +33,6 @@
 import com.google.crypto.tink.mac.MacConfig;
 import com.google.crypto.tink.proto.KeyData.KeyMaterialType;
 import com.google.crypto.tink.proto.OutputPrefixType;
-import com.google.crypto.tink.subtle.PrfAesCmac;
-import com.google.crypto.tink.subtle.PrfMac;
 import com.google.crypto.tink.util.Bytes;
 import com.google.crypto.tink.util.SecretBytes;
 import com.google.protobuf.ByteString;
@@ -68,9 +66,6 @@
           KeysetHandleFullPrimitiveTest::parseTestKey,
           Bytes.copyFrom("testKeyForFullPrimitiveUrl".getBytes(UTF_8)),
           ProtoKeySerialization.class);
-  private static final PrimitiveConstructor<AesCmacKey, Mac> MAC_PRIMITIVE_CONSTRUCTOR =
-      PrimitiveConstructor.create(
-          KeysetHandleFullPrimitiveTest::createMacPrimitive, AesCmacKey.class, Mac.class);
 
   private static class SingleTestPrimitive {}
 
@@ -209,12 +204,6 @@
     }
   }
 
-  private static Mac createMacPrimitive(AesCmacKey key) throws GeneralSecurityException {
-    return new PrfMac(
-        new PrfAesCmac(key.getAesKey().toByteArray(InsecureSecretKeyAccess.get())),
-        key.getParameters().getTotalTagSizeBytes());
-  }
-
   @Test
   public void getPrimitive_fullPrimitiveWithoutPrimitive_worksCorrectly() throws Exception {
     Registry.reset();
@@ -288,8 +277,6 @@
   @Test
   public void getPrimitive_fullPrimitiveWithPrimitive_worksCorrectly() throws Exception {
     Registry.reset();
-    MutablePrimitiveRegistry.globalInstance()
-        .registerPrimitiveConstructor(MAC_PRIMITIVE_CONSTRUCTOR);
     MacTestWrapper.register();
     MacConfig.register();
     AesCmacParameters parameters =