Interface StreamingPrf
-
- All Known Implementing Classes:
HkdfStreamingPrf
@Immutable public interface StreamingPrfStreaming API Interface for Pseudo Random Function (Prf)Security guarantees
Pseudorandom functions provide a mapping from an input to an output string which is indistinguishable from a pure random function.
In Tink, the pseudorandom interface produces a stream of pseudorandom bytes, from which the user can read. The resulting stream may be of (virtually) infinite length, producing bytes as long as the user reads from it, or it may produce a finite length stream of a certain length. More formally, ignoring timing, every implementation is indistinguishable in the input/output behavior from the following ideal implementation, for some length
LENGTH.public class IdealPRF { private Map<byte[], byte[]> cache = new ArrayMap<>(); private static final int LENGTH = ...; // Any value; conceptually, Infinite would also be ok. public InputStream apply(final byte[] input) { if (!cache.containsKey(input)) { cache.put(input, Random.getBytes(LENGTH))); } return new ByteArrayInputStream(cache.get(input)); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.InputStreamcomputePrf(byte[] input)Returns anInputStreamwhich is indistinguishable from a stream returning random bytes in the above sense.
-