• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 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 
17 package com.google.crypto.tink.prf;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import com.google.crypto.tink.Key;
22 import com.google.crypto.tink.KeysetHandle;
23 import org.junit.BeforeClass;
24 import org.junit.experimental.theories.DataPoints;
25 import org.junit.experimental.theories.FromDataPoints;
26 import org.junit.experimental.theories.Theories;
27 import org.junit.experimental.theories.Theory;
28 import org.junit.runner.RunWith;
29 
30 @RunWith(Theories.class)
31 public final class PredefinedPrfParametersTest {
32   @BeforeClass
setUp()33   public static void setUp() throws Exception {
34     PrfConfig.register();
35   }
36 
37   @DataPoints("AllParameters")
38   public static final PrfParameters[] TEMPLATES =
39       new PrfParameters[] {
40         PredefinedPrfParameters.HKDF_SHA256,
41         PredefinedPrfParameters.HMAC_SHA256_PRF,
42         PredefinedPrfParameters.HMAC_SHA512_PRF,
43         PredefinedPrfParameters.AES_CMAC_PRF,
44       };
45 
46   @Theory
testInstantiation(@romDataPoints"AllParameters") PrfParameters parameters)47   public void testInstantiation(@FromDataPoints("AllParameters") PrfParameters parameters)
48       throws Exception {
49     Key key = KeysetHandle.generateNew(parameters).getAt(0).getKey();
50     assertThat(key.getParameters()).isEqualTo(parameters);
51   }
52 }
53