what-the-bank/sources/org/bouncycastle/crypto/params/SkeinParameters.java

152 lines
5.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.params;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.util.Integers;
/* loaded from: classes6.dex */
public class SkeinParameters implements CipherParameters {
public static final int PARAM_TYPE_CONFIG = 4;
public static final int PARAM_TYPE_KEY = 0;
public static final int PARAM_TYPE_KEY_IDENTIFIER = 16;
public static final int PARAM_TYPE_MESSAGE = 48;
public static final int PARAM_TYPE_NONCE = 20;
public static final int PARAM_TYPE_OUTPUT = 63;
public static final int PARAM_TYPE_PERSONALISATION = 8;
public static final int PARAM_TYPE_PUBLIC_KEY = 12;
private Hashtable parameters;
/* loaded from: classes6.dex */
public static class Builder {
private Hashtable parameters = new Hashtable();
public Builder setPublicKey(byte[] bArr) {
return set(12, bArr);
}
public Builder setPersonalisation(byte[] bArr) {
return set(8, bArr);
}
public Builder setPersonalisation(Date date, Locale locale, String str, String str2) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, "UTF-8");
outputStreamWriter.write(new SimpleDateFormat("YYYYMMDD", locale).format(date));
outputStreamWriter.write(" ");
outputStreamWriter.write(str);
outputStreamWriter.write(" ");
outputStreamWriter.write(str2);
outputStreamWriter.close();
return set(8, byteArrayOutputStream.toByteArray());
} catch (IOException e) {
throw new IllegalStateException("Byte I/O failed: ".concat(String.valueOf(e)));
}
}
public Builder setPersonalisation(Date date, String str, String str2) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, "UTF-8");
outputStreamWriter.write(new SimpleDateFormat("YYYYMMDD").format(date));
outputStreamWriter.write(" ");
outputStreamWriter.write(str);
outputStreamWriter.write(" ");
outputStreamWriter.write(str2);
outputStreamWriter.close();
return set(8, byteArrayOutputStream.toByteArray());
} catch (IOException e) {
throw new IllegalStateException("Byte I/O failed: ".concat(String.valueOf(e)));
}
}
public Builder setNonce(byte[] bArr) {
return set(20, bArr);
}
public Builder setKeyIdentifier(byte[] bArr) {
return set(16, bArr);
}
public Builder setKey(byte[] bArr) {
return set(0, bArr);
}
public Builder set(int i, byte[] bArr) {
if (bArr == null) {
throw new IllegalArgumentException("Parameter value must not be null.");
}
if (i != 0 && (i <= 4 || i >= 63 || i == 48)) {
throw new IllegalArgumentException("Parameter types must be in the range 0,5..47,49..62.");
}
if (i == 4) {
throw new IllegalArgumentException("Parameter type 4 is reserved for internal use.");
}
this.parameters.put(Integers.valueOf(i), bArr);
return this;
}
public SkeinParameters build() {
return new SkeinParameters(this.parameters);
}
public Builder(SkeinParameters skeinParameters) {
Enumeration keys = skeinParameters.parameters.keys();
while (keys.hasMoreElements()) {
Integer num = (Integer) keys.nextElement();
this.parameters.put(num, skeinParameters.parameters.get(num));
}
}
public Builder(Hashtable hashtable) {
Enumeration keys = hashtable.keys();
while (keys.hasMoreElements()) {
Integer num = (Integer) keys.nextElement();
this.parameters.put(num, hashtable.get(num));
}
}
public Builder() {
}
}
public byte[] getPublicKey() {
return (byte[]) this.parameters.get(Integers.valueOf(12));
}
public byte[] getPersonalisation() {
return (byte[]) this.parameters.get(Integers.valueOf(8));
}
public Hashtable getParameters() {
return this.parameters;
}
public byte[] getNonce() {
return (byte[]) this.parameters.get(Integers.valueOf(20));
}
public byte[] getKeyIdentifier() {
return (byte[]) this.parameters.get(Integers.valueOf(16));
}
public byte[] getKey() {
return (byte[]) this.parameters.get(Integers.valueOf(0));
}
private SkeinParameters(Hashtable hashtable) {
this.parameters = hashtable;
}
public SkeinParameters() {
this(new Hashtable());
}
}