// 
// Decompiled by Procyon v0.6.0
// 

package com.google.crypto.tink.prf.internal;

import java.security.GeneralSecurityException;
import com.google.crypto.tink.KeyManager;
import com.google.crypto.tink.internal.ProtoKeySerialization;
import com.google.crypto.tink.internal.KeyManagerRegistry;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.internal.LegacyProtoKey;
import com.google.errorprone.annotations.Immutable;
import com.google.crypto.tink.prf.Prf;

@Immutable
public class LegacyFullPrf implements Prf
{
    private final Prf rawPrf;
    
    public static Prf create(final LegacyProtoKey key) throws GeneralSecurityException {
        final ProtoKeySerialization protoKeySerialization = key.getSerialization(InsecureSecretKeyAccess.get());
        final KeyManager<Prf> manager = KeyManagerRegistry.globalInstance().getKeyManager(protoKeySerialization.getTypeUrl(), Prf.class);
        return new LegacyFullPrf(manager.getPrimitive(protoKeySerialization.getValue()));
    }
    
    private LegacyFullPrf(final Prf rawPrf) {
        this.rawPrf = rawPrf;
    }
    
    @Override
    public byte[] compute(final byte[] input, final int outputLength) throws GeneralSecurityException {
        return this.rawPrf.compute(input, outputLength);
    }
}
