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

package com.google.crypto.tink.prf;

import com.google.crypto.tink.Parameters;
import com.google.crypto.tink.Key;
import javax.annotation.Nullable;
import com.google.crypto.tink.AccessesPartialKey;
import com.google.errorprone.annotations.RestrictedApi;
import java.security.GeneralSecurityException;
import com.google.crypto.tink.util.SecretBytes;
import com.google.errorprone.annotations.Immutable;

@Immutable
public final class AesCmacPrfKey extends PrfKey
{
    private final AesCmacPrfParameters parameters;
    private final SecretBytes keyBytes;
    
    private AesCmacPrfKey(final AesCmacPrfParameters parameters, final SecretBytes keyBytes) {
        this.parameters = parameters;
        this.keyBytes = keyBytes;
    }
    
    @RestrictedApi(explanation = "Accessing parts of keys can produce unexpected incompatibilities, annotate the function with @AccessesPartialKey", link = "https://developers.google.com/tink/design/access_control#accessing_partial_keys", allowedOnPath = ".*Test\\.java", allowlistAnnotations = { AccessesPartialKey.class })
    public static AesCmacPrfKey create(final AesCmacPrfParameters parameters, final SecretBytes keyBytes) throws GeneralSecurityException {
        if (parameters.getKeySizeBytes() != keyBytes.size()) {
            throw new GeneralSecurityException("Key size mismatch");
        }
        return new AesCmacPrfKey(parameters, keyBytes);
    }
    
    @RestrictedApi(explanation = "Accessing parts of keys can produce unexpected incompatibilities, annotate the function with @AccessesPartialKey", link = "https://developers.google.com/tink/design/access_control#accessing_partial_keys", allowedOnPath = ".*Test\\.java", allowlistAnnotations = { AccessesPartialKey.class })
    public SecretBytes getKeyBytes() {
        return this.keyBytes;
    }
    
    @Override
    public AesCmacPrfParameters getParameters() {
        return this.parameters;
    }
    
    @Nullable
    @Override
    public Integer getIdRequirementOrNull() {
        return null;
    }
    
    @Override
    public boolean equalsKey(final Key o) {
        if (!(o instanceof AesCmacPrfKey)) {
            return false;
        }
        final AesCmacPrfKey that = (AesCmacPrfKey)o;
        return that.parameters.equals(this.parameters) && that.keyBytes.equalsSecretBytes(this.keyBytes);
    }
}
