/** @return the entries with primitives identified by the ciphertext prefix of {@code key}. */ protected List<Entry<P>> getPrimitive(Keyset.Key key) throws GeneralSecurityException { return getPrimitive(CryptoFormat.getOutputPrefix(key)); }
/** * Creates an entry in the primitive table. * * @return the added entry */ protected Entry<P> addPrimitive(final P primitive, Keyset.Key key) throws GeneralSecurityException { Entry<P> entry = new Entry<P>( primitive, CryptoFormat.getOutputPrefix(key), key.getStatus(), key.getOutputPrefixType()); List<Entry<P>> list = new ArrayList<Entry<P>>(); list.add(entry); // Cannot use [] as keys in hash map, convert to string. String identifier = new String(entry.getIdentifier(), UTF_8); List<Entry<P>> existing = primitives.put(identifier, Collections.unmodifiableList(list)); if (existing != null) { List<Entry<P>> newList = new ArrayList<Entry<P>>(); newList.addAll(existing); newList.add(entry); primitives.put(identifier, Collections.unmodifiableList(newList)); } return entry; } }