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.streamingaead; 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 PredefinedStreamingAeadParametersTest { 32 @BeforeClass setUp()33 public static void setUp() throws Exception { 34 StreamingAeadConfig.register(); 35 } 36 37 @DataPoints("AllParameters") 38 public static final StreamingAeadParameters[] TEMPLATES = 39 new StreamingAeadParameters[] { 40 PredefinedStreamingAeadParameters.AES128_CTR_HMAC_SHA256_4KB, 41 PredefinedStreamingAeadParameters.AES128_CTR_HMAC_SHA256_1MB, 42 PredefinedStreamingAeadParameters.AES256_CTR_HMAC_SHA256_4KB, 43 PredefinedStreamingAeadParameters.AES256_CTR_HMAC_SHA256_1MB, 44 PredefinedStreamingAeadParameters.AES128_GCM_HKDF_4KB, 45 PredefinedStreamingAeadParameters.AES128_GCM_HKDF_1MB, 46 PredefinedStreamingAeadParameters.AES256_GCM_HKDF_4KB, 47 PredefinedStreamingAeadParameters.AES256_GCM_HKDF_1MB 48 }; 49 50 @Theory testInstantiation(@romDataPoints"AllParameters") StreamingAeadParameters parameters)51 public void testInstantiation(@FromDataPoints("AllParameters") StreamingAeadParameters parameters) 52 throws Exception { 53 Key key = KeysetHandle.generateNew(parameters).getAt(0).getKey(); 54 assertThat(key.getParameters()).isEqualTo(parameters); 55 } 56 } 57