public final class PrimitiveSet<P> extends Object
It provides also additional properties for the primitives it holds. In particular, one of the primitives in the set can be distinguished as "the primary" one.
PrimitiveSet is an auxiliary class used for supporting key rotation: primitives in a set correspond to keys in a keyset. Users will usually work with primitive instances, which essentially wrap primitive sets. For example an instance of an Aead-primitive for a given keyset holds a set of Aead-primitives corresponding to the keys in the keyset, and uses the set members to do the actual crypto operations: to encrypt data the primary Aead-primitive from the set is used, and upon decryption the ciphertext's prefix determines the id of the primitive from the set.
PrimitiveSet is a public class to allow its use in implementations of custom primitives.
| Modifier and Type | Class and Description |
|---|---|
static class |
PrimitiveSet.Entry<P>
A single entry in the set.
|
| Modifier and Type | Method and Description |
|---|---|
PrimitiveSet.Entry<P> |
addPrimitive(P primitive,
com.google.crypto.tink.proto.Keyset.Key key)
Creates an entry in the primitive table.
|
Collection<List<PrimitiveSet.Entry<P>>> |
getAll() |
PrimitiveSet.Entry<P> |
getPrimary() |
List<PrimitiveSet.Entry<P>> |
getPrimitive(byte[] identifier) |
protected List<PrimitiveSet.Entry<P>> |
getPrimitive(com.google.crypto.tink.proto.Keyset.Key key)
Returns the entries with primitives identified by the ciphertext prefix of
key. |
Class<P> |
getPrimitiveClass() |
List<PrimitiveSet.Entry<P>> |
getRawPrimitives() |
static <P> PrimitiveSet<P> |
newPrimitiveSet(Class<P> primitiveClass) |
void |
setPrimary(PrimitiveSet.Entry<P> primary)
Sets given Entry
primary as the primary one. |
public PrimitiveSet.Entry<P> getPrimary()
public List<PrimitiveSet.Entry<P>> getRawPrimitives()
public List<PrimitiveSet.Entry<P>> getPrimitive(byte[] identifier)
identifier.protected List<PrimitiveSet.Entry<P>> getPrimitive(com.google.crypto.tink.proto.Keyset.Key key) throws GeneralSecurityException
key.GeneralSecurityExceptionpublic Collection<List<PrimitiveSet.Entry<P>>> getAll()
public static <P> PrimitiveSet<P> newPrimitiveSet(Class<P> primitiveClass)
public void setPrimary(PrimitiveSet.Entry<P> primary)
primary as the primary one.public PrimitiveSet.Entry<P> addPrimitive(P primitive, com.google.crypto.tink.proto.Keyset.Key key) throws GeneralSecurityException
GeneralSecurityException