use of com.google.crypto.tink.PrimitiveSet in project tink by google.
the class TestUtil method createPrimitiveSet.
/**
* @return a {@code PrimitiveSet} from a {@code KeySet}
*/
public static <P> PrimitiveSet<P> createPrimitiveSet(Keyset keyset, Class<P> inputClass) throws GeneralSecurityException {
PrimitiveSet<P> primitives = PrimitiveSet.newPrimitiveSet(inputClass);
for (Keyset.Key key : keyset.getKeyList()) {
if (key.getStatus() == KeyStatusType.ENABLED) {
P primitive = Registry.getPrimitive(key.getKeyData(), inputClass);
PrimitiveSet.Entry<P> entry = primitives.addPrimitive(primitive, key);
if (key.getKeyId() == keyset.getPrimaryKeyId()) {
primitives.setPrimary(entry);
}
}
}
return primitives;
}
Aggregations