1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 //////////////////////////////////////////////////////////////////////////////// 16 package com.google.crypto.tink.prf; 17 18 import com.google.crypto.tink.config.TinkFips; 19 import java.security.GeneralSecurityException; 20 21 /** 22 * Static methods and registering with the {@link Registry} all instances of {@link 23 * com.google.crypto.tink.subtle.prf.StreamingPrf} key types supported in a particular release of 24 * Tink. 25 */ 26 public final class PrfConfig { 27 public static final String PRF_TYPE_URL = HkdfPrfKeyManager.getKeyType(); 28 public static final String HMAC_PRF_TYPE_URL = HmacPrfKeyManager.getKeyType(); 29 30 /** 31 * Tries to register with the {@link Registry} all instances of {@link 32 * com.google.crypto.tink.KeyManager} needed to handle Prf key types supported in Tink. 33 */ register()34 public static void register() throws GeneralSecurityException { 35 PrfSetWrapper.register(); 36 HmacPrfKeyManager.register(/*newKeyAllowed=*/ true); 37 38 if (TinkFips.useOnlyFips()) { 39 // If Tink is built in FIPS-mode do not register algorithms which are not compatible. 40 return; 41 } 42 43 AesCmacPrfKeyManager.register(/*newKeyAllowed=*/ true); 44 HkdfPrfKeyManager.register(/*newKeyAllowed=*/ true); 45 } 46 PrfConfig()47 private PrfConfig() {} 48 } 49