package org.bouncycastle.crypto.macs; import org.bouncycastle.crypto.CipherParameters; import org.bouncycastle.crypto.Mac; import org.bouncycastle.crypto.digests.SkeinEngine; import org.bouncycastle.crypto.params.KeyParameter; import org.bouncycastle.crypto.params.SkeinParameters; /* loaded from: classes6.dex */ public class SkeinMac implements Mac { public static final int SKEIN_1024 = 1024; public static final int SKEIN_256 = 256; public static final int SKEIN_512 = 512; private SkeinEngine engine; @Override // org.bouncycastle.crypto.Mac public void update(byte[] bArr, int i, int i2) { this.engine.update(bArr, i, i2); } @Override // org.bouncycastle.crypto.Mac public void update(byte b) { this.engine.update(b); } @Override // org.bouncycastle.crypto.Mac public void reset() { this.engine.reset(); } @Override // org.bouncycastle.crypto.Mac public void init(CipherParameters cipherParameters) throws IllegalArgumentException { SkeinParameters build; if (cipherParameters instanceof SkeinParameters) { build = (SkeinParameters) cipherParameters; } else { if (!(cipherParameters instanceof KeyParameter)) { StringBuilder sb = new StringBuilder("Invalid parameter passed to Skein MAC init - "); sb.append(cipherParameters.getClass().getName()); throw new IllegalArgumentException(sb.toString()); } build = new SkeinParameters.Builder().setKey(((KeyParameter) cipherParameters).getKey()).build(); } if (build.getKey() == null) { throw new IllegalArgumentException("Skein MAC requires a key parameter."); } this.engine.init(build); } @Override // org.bouncycastle.crypto.Mac public int getMacSize() { return this.engine.getOutputSize(); } @Override // org.bouncycastle.crypto.Mac public String getAlgorithmName() { StringBuilder sb = new StringBuilder("Skein-MAC-"); sb.append(this.engine.getBlockSize() << 3); sb.append("-"); sb.append(this.engine.getOutputSize() << 3); return sb.toString(); } @Override // org.bouncycastle.crypto.Mac public int doFinal(byte[] bArr, int i) { return this.engine.doFinal(bArr, i); } public SkeinMac(SkeinMac skeinMac) { this.engine = new SkeinEngine(skeinMac.engine); } public SkeinMac(int i, int i2) { this.engine = new SkeinEngine(i, i2); } }