• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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.aead;
18 
19 import com.google.crypto.tink.Key;
20 import com.google.crypto.tink.util.Bytes;
21 
22 /** Represents functions to encrypt and decrypt data using AEAD. */
23 public abstract class AeadKey extends Key {
24   /**
25    * Returns a {@link Bytes} instance which is prefixed to the ciphertext.
26    *
27    * <p>In order to make key rotation more efficient, Tink allows every Aead key to be prefixed with
28    * a sequence of bytes. When decrypting data, only keys with matching prefix have to be tried.
29    *
30    * <p>Note that a priori, the output prefix may not be unique in a keyset (i.e., different keys in
31    * a keyset may have the same prefix or, one prefix may be a prefix of the other). To avoid this,
32    * built in Tink keys use the convention that the prefix is either '0x00<big endian key id>' or
33    * '0x01<big endian key id>'. See the Tink keys for details.
34    */
getOutputPrefix()35   public abstract Bytes getOutputPrefix();
36   /** Returns the parameters of this key. */
37   @Override
getParameters()38   public abstract AeadParameters getParameters();
39 }
40