fard (does not compile)
This commit is contained in:
parent
be8c0c8007
commit
698dde0809
26434
javascript/classes.js
26434
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -1,3 +1,8 @@
|
||||||
|
ayuncraft is a modded version of eaglercraft. check it out for yourself to see what's different!
|
||||||
|
|
||||||
|
|
||||||
|
-=-The following is the original README file-=-
|
||||||
|
|
||||||
eaglercraft is an AOT compiled port of mojang's minecraft 1.5.2 designed to run in an html5/javascript environment, using TeaVM and my opengl 1.3 emulator to simulate a desktop java enviroment fully compatible with minecraft java edition
|
eaglercraft is an AOT compiled port of mojang's minecraft 1.5.2 designed to run in an html5/javascript environment, using TeaVM and my opengl 1.3 emulator to simulate a desktop java enviroment fully compatible with minecraft java edition
|
||||||
|
|
||||||
§1this §1was §1created §1by §1calder §1young §1(LAX1DUDE), §1submit §1complaints §1and §1bug §1reports §1to §1cgiacun@gmail.com §1or §1hmu §1on §1discord §1at §1LAX1DUDE#6306 §1or §1on §1instagram §1@calderyounggg§r
|
§1this §1was §1created §1by §1calder §1young §1(LAX1DUDE), §1submit §1complaints §1and §1bug §1reports §1to §1cgiacun@gmail.com §1or §1hmu §1on §1discord §1at §1LAX1DUDE#6306 §1or §1on §1instagram §1@calderyounggg§r
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions);
|
this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GuiButton button0, button1, button2;
|
private GuiButton button0, button1, button2, button3;
|
||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
@ -81,6 +81,8 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
this.buttonList.add(button0 = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
|
this.buttonList.add(button0 = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
|
||||||
this.buttonList.add(button1 = new GuiButton(2, this.width / 2 - 21, this.height / 6 + 110, 71, 20, var1.translateKey("profile.addSkin")));
|
this.buttonList.add(button1 = new GuiButton(2, this.width / 2 - 21, this.height / 6 + 110, 71, 20, var1.translateKey("profile.addSkin")));
|
||||||
this.buttonList.add(button2 = new GuiButton(3, this.width / 2 - 21 + 71, this.height / 6 + 110, 72, 20, var1.translateKey("profile.clearSkin")));
|
this.buttonList.add(button2 = new GuiButton(3, this.width / 2 - 21 + 71, this.height / 6 + 110, 72, 20, var1.translateKey("profile.clearSkin")));
|
||||||
|
|
||||||
|
this.buttonList.add(button3 = new GuiButton(4, this.width / 2 - 21 + 71, this.height / 6 + 134, 72, 20, this.mc.gameSettings.useDefaultProtocol?"Switch to Eaglercraft":"Switch to Vanilla"));
|
||||||
//this.buttonList.add(new GuiButton(200, this.width / 2, this.height / 6 + 72, 150, 20, var1.translateKey("gui.done")));
|
//this.buttonList.add(new GuiButton(200, this.width / 2, this.height / 6 + 72, 150, 20, var1.translateKey("gui.done")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +216,10 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
EaglerProfile.glTex.clear();
|
EaglerProfile.glTex.clear();
|
||||||
this.dropDownOptions = defaultOptions;
|
this.dropDownOptions = defaultOptions;
|
||||||
this.selectedSlot = 0;
|
this.selectedSlot = 0;
|
||||||
|
}else if (par1GuiButton.id == 4) {
|
||||||
|
//toggle version mode
|
||||||
|
this.mc.gameSettings.useDefaultProtocol=!this.mc.gameSettings.useDefaultProtocol;
|
||||||
|
button3.displayString=this.mc.gameSettings.useDefaultProtocol?"Switch to Eaglercraft":"Switch to Vanilla";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,39 @@
|
||||||
package net.lax1dude.eaglercraft;
|
package net.lax1dude.eaglercraft;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.security.PrivateKey;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.src.INetworkManager;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.src.NetHandler;
|
import net.minecraft.src.*;
|
||||||
import net.minecraft.src.Packet;
|
import org.bouncycastle.crypto.BufferedBlockCipher;
|
||||||
|
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
public class WebsocketNetworkManager implements INetworkManager {
|
public class WebsocketNetworkManager implements INetworkManager {
|
||||||
|
private boolean isInputBeingDecrypted;
|
||||||
|
private boolean isOutputEncrypted;
|
||||||
|
private SecretKey sharedKeyForEncryption;
|
||||||
|
private PrivateKey privateKey;
|
||||||
|
|
||||||
|
private BufferedBlockCipher inputBufferedBlockCipher=null;
|
||||||
|
private BufferedBlockCipher outputBufferedBlockCipher=null;
|
||||||
|
|
||||||
private NetHandler netHandler;
|
private NetHandler netHandler;
|
||||||
|
|
||||||
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler) throws IOException {
|
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler) throws IOException {
|
||||||
|
this(uri,eagler,netHandler,(PrivateKey)null);
|
||||||
|
//this(uri,eagler,netHandler,CryptManager.createNewKeyPair().getPrivate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler, PrivateKey privKey) throws IOException {
|
||||||
this.netHandler = netHandler;
|
this.netHandler = netHandler;
|
||||||
|
this.privateKey = privKey;
|
||||||
|
//this.sharedKeyForEncryption = CryptManager.createNewSharedKey();
|
||||||
|
this.sharedKeyForEncryption = null;
|
||||||
|
this.isInputBeingDecrypted = false;
|
||||||
|
this.isOutputEncrypted = false;
|
||||||
if(!EaglerAdapter.startConnection(uri)) {
|
if(!EaglerAdapter.startConnection(uri)) {
|
||||||
throw new IOException("websocket to "+uri+" failed");
|
throw new IOException("websocket to "+uri+" failed");
|
||||||
}
|
}
|
||||||
|
@ -34,8 +49,26 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
public void addToSendQueue(Packet var1) {
|
public void addToSendQueue(Packet var1) {
|
||||||
try {
|
try {
|
||||||
sendBuffer.reset();
|
sendBuffer.reset();
|
||||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
//the following attempts to keep packets encrypted because i forgot that last code i sent lol
|
||||||
|
DataOutputStream yee;
|
||||||
|
if(this.isOutputEncrypted&&!(var1 instanceof Packet252SharedKey)){
|
||||||
|
yee = this.encryptOuputStream();
|
||||||
|
}else{
|
||||||
|
yee = new DataOutputStream(sendBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Minecraft.getMinecraft().gameSettings.useDefaultProtocol && var1 instanceof Packet252SharedKey && !this.isOutputEncrypted)
|
||||||
|
{
|
||||||
|
if (!this.netHandler.isServerHandler())
|
||||||
|
{
|
||||||
|
this.sharedKeyForEncryption = ((Packet252SharedKey)var1).getSharedKey();
|
||||||
|
}
|
||||||
|
this.isOutputEncrypted=true;
|
||||||
|
//yee=this.encryptOuputStream(yee);
|
||||||
|
}
|
||||||
Packet.writePacket(var1, yee);
|
Packet.writePacket(var1, yee);
|
||||||
|
//System.out.println("SENDING: "+var1);
|
||||||
|
yee.flush();
|
||||||
EaglerAdapter.writePacket(sendBuffer.toByteArray());
|
EaglerAdapter.writePacket(sendBuffer.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -65,6 +98,9 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
private ByteBuffer oldChunkBuffer = null;
|
private ByteBuffer oldChunkBuffer = null;
|
||||||
private LinkedList<ByteBuffer> readChunks = new LinkedList();
|
private LinkedList<ByteBuffer> readChunks = new LinkedList();
|
||||||
|
|
||||||
|
private ByteBuffer oldDecryptedChunkBuffer = null;
|
||||||
|
private LinkedList<ByteBuffer> decryptedReadChunks = new LinkedList();
|
||||||
|
|
||||||
public void processReadPackets() {
|
public void processReadPackets() {
|
||||||
readChunks.clear();
|
readChunks.clear();
|
||||||
|
|
||||||
|
@ -89,29 +125,98 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
}
|
}
|
||||||
stream.flip();
|
stream.flip();
|
||||||
|
|
||||||
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
if(this.isInputBeingDecrypted){
|
||||||
while(stream.hasRemaining()) {
|
decryptedReadChunks.clear();
|
||||||
stream.mark();
|
|
||||||
try {
|
if (oldDecryptedChunkBuffer != null) {
|
||||||
Packet pkt = Packet.readPacket(packetStream, false);
|
decryptedReadChunks.add(oldDecryptedChunkBuffer);
|
||||||
//System.out.println(pkt.toString());
|
oldDecryptedChunkBuffer = null;
|
||||||
pkt.processPacket(this.netHandler);
|
}
|
||||||
} catch (EOFException e) {
|
|
||||||
stream.reset();
|
byte[] block = new byte[2048];
|
||||||
break;
|
byte[] decryp = new byte[this.inputBufferedBlockCipher.getOutputSize(2048)];
|
||||||
} catch (IOException e) {
|
while (stream.remaining() >= 2048) {
|
||||||
continue;
|
stream.get(block);
|
||||||
} catch (Throwable e2) {
|
int i = this.inputBufferedBlockCipher.processByte(block, 0, 2048, decryp, 0);
|
||||||
e2.printStackTrace();
|
ByteBuffer chunk = ByteBuffer.allocate(i);
|
||||||
|
chunk.put(decryp, 0, i);
|
||||||
|
chunk.flip();
|
||||||
|
decryptedReadChunks.add(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldChunkBuffer = stream.remaining() > 0 ? stream.slice() : null;
|
||||||
|
|
||||||
|
int cap2 = 0;
|
||||||
|
for (ByteBuffer b : decryptedReadChunks) {
|
||||||
|
cap2 += b.limit();
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuffer decStream = ByteBuffer.allocate(cap2);
|
||||||
|
for (ByteBuffer b : decryptedReadChunks) {
|
||||||
|
decStream.put(b);
|
||||||
|
}
|
||||||
|
decStream.flip();
|
||||||
|
|
||||||
|
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(decStream));
|
||||||
|
while (decStream.hasRemaining()) {
|
||||||
|
decStream.mark();
|
||||||
|
try {
|
||||||
|
Packet pkt = Packet.readPacket(packetStream, false);
|
||||||
|
//System.out.println("RECEIVING: " + pkt);
|
||||||
|
pkt.processPacket(this.netHandler);
|
||||||
|
} catch (EOFException e) {
|
||||||
|
decStream.reset();
|
||||||
|
break;
|
||||||
|
} catch (IOException e) {
|
||||||
|
continue;
|
||||||
|
} catch (Throwable e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decStream.hasRemaining()) {
|
||||||
|
oldDecryptedChunkBuffer = decStream.slice();
|
||||||
|
} else {
|
||||||
|
oldDecryptedChunkBuffer = null;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
||||||
|
while (stream.hasRemaining()) {
|
||||||
|
stream.mark();
|
||||||
|
try {
|
||||||
|
Packet pkt = Packet.readPacket(packetStream, false);
|
||||||
|
boolean change=false;
|
||||||
|
if (pkt != null) {
|
||||||
|
if (Minecraft.getMinecraft().gameSettings.useDefaultProtocol && pkt instanceof Packet252SharedKey && !this.isInputBeingDecrypted) {
|
||||||
|
if (this.netHandler.isServerHandler()) {
|
||||||
|
this.sharedKeyForEncryption = ((Packet252SharedKey) pkt).getSharedKey(this.privateKey);
|
||||||
|
}
|
||||||
|
packetStream = this.decryptInputStream(new ByteBufferDirectInputStream(stream));
|
||||||
|
change=true;
|
||||||
|
}
|
||||||
|
//System.out.println("RECEIVING: " + pkt);
|
||||||
|
pkt.processPacket(this.netHandler);
|
||||||
|
if(change){
|
||||||
|
processReadPackets();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (EOFException e) {
|
||||||
|
stream.reset();
|
||||||
|
break;
|
||||||
|
} catch (IOException e) {
|
||||||
|
continue;
|
||||||
|
} catch (Throwable e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream.hasRemaining()) {
|
||||||
|
oldChunkBuffer = stream.slice();
|
||||||
|
} else {
|
||||||
|
oldChunkBuffer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stream.hasRemaining()) {
|
|
||||||
oldChunkBuffer = stream.slice();
|
|
||||||
}else {
|
|
||||||
oldChunkBuffer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +227,34 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DataInputStream decryptInputStream(ByteBufferDirectInputStream var1) throws IOException
|
||||||
|
{
|
||||||
|
this.isInputBeingDecrypted = true;
|
||||||
|
if(this.inputBufferedBlockCipher==null){
|
||||||
|
this.inputBufferedBlockCipher = CryptManager.createBufferedBlockCipher(false,this.sharedKeyForEncryption);
|
||||||
|
}
|
||||||
|
return new DataInputStream(CryptManager.decryptInputStream(this.inputBufferedBlockCipher, var1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flushes the stream and replaces it with an encryptedOutputStream
|
||||||
|
*/
|
||||||
|
private DataOutputStream encryptOuputStream(DataOutputStream var0) throws IOException
|
||||||
|
{
|
||||||
|
var0.flush();
|
||||||
|
this.isOutputEncrypted = true;
|
||||||
|
BufferedOutputStream var1 = new BufferedOutputStream(CryptManager.encryptOuputStream(this.sharedKeyForEncryption, var0), 5120);
|
||||||
|
return new DataOutputStream(var1);
|
||||||
|
}
|
||||||
|
private DataOutputStream encryptOuputStream() throws IOException
|
||||||
|
{
|
||||||
|
if(this.outputBufferedBlockCipher==null){
|
||||||
|
this.outputBufferedBlockCipher = CryptManager.createBufferedBlockCipher(true,this.sharedKeyForEncryption);
|
||||||
|
}
|
||||||
|
BufferedOutputStream var1 = new BufferedOutputStream(CryptManager.encryptOuputStream(this.outputBufferedBlockCipher, sendBuffer), 5120);
|
||||||
|
return new DataOutputStream(var1);
|
||||||
|
}
|
||||||
|
|
||||||
public int packetSize() {
|
public int packetSize() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
242
src/main/java/net/minecraft/src/CryptManager.java
Normal file
242
src/main/java/net/minecraft/src/CryptManager.java
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.Key;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyPairGenerator;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import javax.crypto.BadPaddingException;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import org.bouncycastle.crypto.BufferedBlockCipher;
|
||||||
|
import org.bouncycastle.crypto.CipherKeyGenerator;
|
||||||
|
import org.bouncycastle.crypto.KeyGenerationParameters;
|
||||||
|
import org.bouncycastle.crypto.engines.AESFastEngine;
|
||||||
|
import org.bouncycastle.crypto.io.CipherInputStream;
|
||||||
|
import org.bouncycastle.crypto.io.CipherOutputStream;
|
||||||
|
import org.bouncycastle.crypto.modes.CFBBlockCipher;
|
||||||
|
import org.bouncycastle.crypto.params.KeyParameter;
|
||||||
|
import org.bouncycastle.crypto.params.ParametersWithIV;
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
|
||||||
|
public class CryptManager
|
||||||
|
{
|
||||||
|
/** ISO_8859_1 */
|
||||||
|
public static final Charset charSet = Charset.forName("ISO_8859_1");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a new shared secret AES key from a secure random source
|
||||||
|
*/
|
||||||
|
public static SecretKey createNewSharedKey()
|
||||||
|
{
|
||||||
|
CipherKeyGenerator var0 = new CipherKeyGenerator();
|
||||||
|
var0.init(new KeyGenerationParameters(new SecureRandom(), 128));
|
||||||
|
return new SecretKeySpec(var0.generateKey(), "AES");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KeyPair createNewKeyPair()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
KeyPairGenerator var0 = KeyPairGenerator.getInstance("RSA");
|
||||||
|
var0.initialize(1024);
|
||||||
|
return var0.generateKeyPair();
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException var1)
|
||||||
|
{
|
||||||
|
var1.printStackTrace();
|
||||||
|
System.err.println("Key pair generation failed!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute a serverId hash for use by sendSessionRequest()
|
||||||
|
*/
|
||||||
|
public static byte[] getServerIdHash(String par0Str, PublicKey par1PublicKey, SecretKey par2SecretKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return digestOperation("SHA-1", new byte[][] {par0Str.getBytes("ISO_8859_1"), par2SecretKey.getEncoded(), par1PublicKey.getEncoded()});
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException var4)
|
||||||
|
{
|
||||||
|
var4.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute a message digest on arbitrary byte[] data
|
||||||
|
*/
|
||||||
|
private static byte[] digestOperation(String par0Str, byte[] ... par1ArrayOfByte)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MessageDigest var2 = MessageDigest.getInstance(par0Str);
|
||||||
|
byte[][] var3 = par1ArrayOfByte;
|
||||||
|
int var4 = par1ArrayOfByte.length;
|
||||||
|
|
||||||
|
for (int var5 = 0; var5 < var4; ++var5)
|
||||||
|
{
|
||||||
|
byte[] var6 = var3[var5];
|
||||||
|
var2.update(var6);
|
||||||
|
}
|
||||||
|
|
||||||
|
return var2.digest();
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException var7)
|
||||||
|
{
|
||||||
|
var7.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new PublicKey from encoded X.509 data
|
||||||
|
*/
|
||||||
|
public static PublicKey decodePublicKey(byte[] par0ArrayOfByte)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
X509EncodedKeySpec var1 = new X509EncodedKeySpec(par0ArrayOfByte);
|
||||||
|
KeyFactory var2 = KeyFactory.getInstance("RSA");
|
||||||
|
return var2.generatePublic(var1);
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException var3)
|
||||||
|
{
|
||||||
|
var3.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (InvalidKeySpecException var4)
|
||||||
|
{
|
||||||
|
var4.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.err.println("Public key reconstitute failed!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt shared secret AES key using RSA private key
|
||||||
|
*/
|
||||||
|
public static SecretKey decryptSharedKey(PrivateKey par0PrivateKey, byte[] par1ArrayOfByte)
|
||||||
|
{
|
||||||
|
return new SecretKeySpec(decryptData(par0PrivateKey, par1ArrayOfByte), "AES");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt byte[] data with RSA public key
|
||||||
|
*/
|
||||||
|
public static byte[] encryptData(Key par0Key, byte[] par1ArrayOfByte)
|
||||||
|
{
|
||||||
|
return cipherOperation(1, par0Key, par1ArrayOfByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt byte[] data with RSA private key
|
||||||
|
*/
|
||||||
|
public static byte[] decryptData(Key par0Key, byte[] par1ArrayOfByte)
|
||||||
|
{
|
||||||
|
return cipherOperation(2, par0Key, par1ArrayOfByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt or decrypt byte[] data using the specified key
|
||||||
|
*/
|
||||||
|
private static byte[] cipherOperation(int par0, Key par1Key, byte[] par2ArrayOfByte)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return createTheCipherInstance(par0, par1Key.getAlgorithm(), par1Key).doFinal(par2ArrayOfByte);
|
||||||
|
}
|
||||||
|
catch (IllegalBlockSizeException var4)
|
||||||
|
{
|
||||||
|
var4.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (BadPaddingException var5)
|
||||||
|
{
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.err.println("Cipher data failed!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the Cipher Instance.
|
||||||
|
*/
|
||||||
|
private static Cipher createTheCipherInstance(int par0, String par1Str, Key par2Key)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Cipher var3 = Cipher.getInstance(par1Str);
|
||||||
|
var3.init(par0, par2Key);
|
||||||
|
return var3;
|
||||||
|
}
|
||||||
|
catch (InvalidKeyException var4)
|
||||||
|
{
|
||||||
|
var4.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException var5)
|
||||||
|
{
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (NoSuchPaddingException var6)
|
||||||
|
{
|
||||||
|
var6.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.err.println("Cipher creation failed!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new BufferedBlockCipher instance
|
||||||
|
*/
|
||||||
|
public static BufferedBlockCipher createBufferedBlockCipher(boolean par0, Key par1Key)
|
||||||
|
{
|
||||||
|
BufferedBlockCipher var2 = new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 8));
|
||||||
|
var2.init(par0, new ParametersWithIV(new KeyParameter(par1Key.getEncoded()), par1Key.getEncoded(), 0, 16));
|
||||||
|
return var2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OutputStream encryptOuputStream(SecretKey par0SecretKey, OutputStream par1OutputStream)
|
||||||
|
{
|
||||||
|
return new CipherOutputStream(par1OutputStream, createBufferedBlockCipher(true, par0SecretKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream decryptInputStream(SecretKey par0SecretKey, InputStream par1InputStream)
|
||||||
|
{
|
||||||
|
return new CipherInputStream(par1InputStream, createBufferedBlockCipher(false, par0SecretKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OutputStream encryptOuputStream(BufferedBlockCipher bufferedBlockCipher, OutputStream par1OutputStream)
|
||||||
|
{
|
||||||
|
return new CipherOutputStream(par1OutputStream, bufferedBlockCipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream decryptInputStream(BufferedBlockCipher bufferedBlockCipher, InputStream par1InputStream)
|
||||||
|
{
|
||||||
|
return new CipherInputStream(par1InputStream, bufferedBlockCipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,9 @@ import net.lax1dude.eaglercraft.LocalStorageManager;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class GameSettings {
|
public class GameSettings {
|
||||||
|
public static boolean useDefaultProtocol = false;
|
||||||
|
|
||||||
|
|
||||||
private static final String[] RENDER_DISTANCES = new String[] { "options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny" };
|
private static final String[] RENDER_DISTANCES = new String[] { "options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny" };
|
||||||
private static final String[] DIFFICULTIES = new String[] { "options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard" };
|
private static final String[] DIFFICULTIES = new String[] { "options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard" };
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,12 @@ public class GuiConnecting extends GuiScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clientHandler = new NetClientHandler(this.mc, uri, 0);
|
this.clientHandler = new NetClientHandler(this.mc, uri, 0);
|
||||||
this.clientHandler.addToSendQueue(new Packet2ClientProtocol(69, EaglerProfile.username, uria, port));
|
if(this.mc.gameSettings.useDefaultProtocol) {
|
||||||
this.clientHandler.addToSendQueue(new Packet250CustomPayload("EAG|MySkin", EaglerProfile.getSkinPacket()));
|
this.clientHandler.addToSendQueue(new Packet2ClientProtocol(61, EaglerProfile.username, uria, port));
|
||||||
|
}else{
|
||||||
|
this.clientHandler.addToSendQueue(new Packet2ClientProtocol(69, EaglerProfile.username, uria, port));
|
||||||
|
this.clientHandler.addToSendQueue(new Packet250CustomPayload("EAG|MySkin", EaglerProfile.getSkinPacket()));
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.mc.displayGuiScreen(new GuiDisconnected(this.field_98098_c, "connect.failed", "disconnect.genericReason", "could not connect to "+uri, e.toString()));
|
this.mc.displayGuiScreen(new GuiDisconnected(this.field_98098_c, "connect.failed", "disconnect.genericReason", "could not connect to "+uri, e.toString()));
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class GuiMainMenu extends GuiScreen {
|
||||||
* RunnableTitleScreen(this), "1.6 Update Check Thread")).start(); }
|
* RunnableTitleScreen(this), "1.6 Update Check Thread")).start(); }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.field_92025_p = EaglerAdapter._wisWebGL() ? ("eaglercraft javascript runtime") : ("eaglercraft desktop runtime");
|
this.field_92025_p = EaglerAdapter._wisWebGL() ? ("ayuncraft javascript runtime") : ("ayuncraft desktop runtime");
|
||||||
this.start = System.currentTimeMillis() + System.currentTimeMillis() % 10000l;
|
this.start = System.currentTimeMillis() + System.currentTimeMillis() % 10000l;
|
||||||
this.ackLines = new ArrayList();
|
this.ackLines = new ArrayList();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class GuiMainMenu extends GuiScreen {
|
||||||
Calendar var1 = Calendar.getInstance();
|
Calendar var1 = Calendar.getInstance();
|
||||||
var1.setTime(new Date());
|
var1.setTime(new Date());
|
||||||
|
|
||||||
this.splashText = "darviglet!";
|
this.splashText = "fard!";
|
||||||
|
|
||||||
StringTranslate var2 = StringTranslate.getInstance();
|
StringTranslate var2 = StringTranslate.getInstance();
|
||||||
int var4 = this.height / 4 + 48;
|
int var4 = this.height / 4 + 48;
|
||||||
|
@ -464,7 +464,7 @@ public class GuiMainMenu extends GuiScreen {
|
||||||
// 16777215);
|
// 16777215);
|
||||||
}
|
}
|
||||||
|
|
||||||
var10 = "eaglercraft readme.txt";
|
var10 = "ayuncraft readme.txt";
|
||||||
int w = this.fontRenderer.getStringWidth(var10) * 3 / 4;
|
int w = this.fontRenderer.getStringWidth(var10) * 3 / 4;
|
||||||
if(!showAck && par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) {
|
if(!showAck && par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) {
|
||||||
drawRect((this.width - w - 4), 0, this.width, 9, 0x55000099);
|
drawRect((this.width - w - 4), 0, this.width, 9, 0x55000099);
|
||||||
|
|
|
@ -3,19 +3,21 @@ package net.minecraft.src;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.security.PrivateKey;
|
||||||
import java.util.Iterator;
|
import java.security.PublicKey;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.DefaultSkinRenderer;
|
import net.lax1dude.eaglercraft.DefaultSkinRenderer;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
|
import net.lax1dude.eaglercraft.EaglerProfile;
|
||||||
import net.lax1dude.eaglercraft.WebsocketNetworkManager;
|
import net.lax1dude.eaglercraft.WebsocketNetworkManager;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
public class NetClientHandler extends NetHandler {
|
public class NetClientHandler extends NetHandler {
|
||||||
|
|
||||||
/** True if kicked or disconnected from the server. */
|
/** True if kicked or disconnected from the server. */
|
||||||
private boolean disconnected = false;
|
private boolean disconnected = false;
|
||||||
|
|
||||||
|
@ -87,8 +89,11 @@ public class NetClientHandler extends NetHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleServerAuthData(Packet253ServerAuthData par1Packet253ServerAuthData) {
|
public void handleServerAuthData(Packet253ServerAuthData par1Packet253ServerAuthData) {
|
||||||
|
String var2 = par1Packet253ServerAuthData.getServerId().trim();
|
||||||
|
PublicKey var3 = par1Packet253ServerAuthData.getPublicKey();
|
||||||
|
SecretKey var4 = CryptManager.createNewSharedKey();
|
||||||
|
|
||||||
this.addToSendQueue(new Packet252SharedKey());
|
this.addToSendQueue(new Packet252SharedKey(var4, var3, par1Packet253ServerAuthData.getVerifyToken()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey) {
|
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey) {
|
||||||
|
@ -1113,7 +1118,7 @@ public class NetClientHandler extends NetHandler {
|
||||||
} catch (IOException var7) {
|
} catch (IOException var7) {
|
||||||
var7.printStackTrace();
|
var7.printStackTrace();
|
||||||
}
|
}
|
||||||
}else if("EAG|UserSkin".equals(par1Packet250CustomPayload.channel)) {
|
}else if(!this.mc.gameSettings.useDefaultProtocol&&"EAG|UserSkin".equals(par1Packet250CustomPayload.channel)) {
|
||||||
DefaultSkinRenderer.skinResponse(par1Packet250CustomPayload.data);
|
DefaultSkinRenderer.skinResponse(par1Packet250CustomPayload.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,39 +3,84 @@ package net.minecraft.src;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
public class Packet252SharedKey extends Packet {
|
public class Packet252SharedKey extends Packet
|
||||||
|
{
|
||||||
|
private byte[] sharedSecret = new byte[0];
|
||||||
|
private byte[] verifyToken = new byte[0];
|
||||||
|
|
||||||
public Packet252SharedKey() {
|
/**
|
||||||
|
* Secret AES key decrypted from sharedSecret via the server's private RSA key
|
||||||
|
*/
|
||||||
|
private SecretKey sharedKey;
|
||||||
|
|
||||||
|
public Packet252SharedKey() {}
|
||||||
|
|
||||||
|
public Packet252SharedKey(SecretKey par1SecretKey, PublicKey par2PublicKey, byte[] par3ArrayOfByte)
|
||||||
|
{
|
||||||
|
this.sharedKey = par1SecretKey;
|
||||||
|
this.sharedSecret = CryptManager.encryptData(par2PublicKey, par1SecretKey.getEncoded());
|
||||||
|
this.verifyToken = CryptManager.encryptData(par2PublicKey, par3ArrayOfByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Reads the raw packet data from the data stream.
|
* Abstract. Reads the raw packet data from the data stream.
|
||||||
*/
|
*/
|
||||||
public void readPacketData(DataInputStream par1DataInputStream) throws IOException {
|
public void readPacketData(DataInputStream par1DataInputStream) throws IOException
|
||||||
readBytesFromStream(par1DataInputStream);
|
{
|
||||||
readBytesFromStream(par1DataInputStream);
|
this.sharedSecret = readBytesFromStream(par1DataInputStream);
|
||||||
|
this.verifyToken = readBytesFromStream(par1DataInputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Writes the raw packet data to the data stream.
|
* Abstract. Writes the raw packet data to the data stream.
|
||||||
*/
|
*/
|
||||||
public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException {
|
public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
|
||||||
writeByteArray(par1DataOutputStream, new byte[162]);
|
{
|
||||||
writeByteArray(par1DataOutputStream, new byte[4]);
|
writeByteArray(par1DataOutputStream, this.sharedSecret);
|
||||||
|
writeByteArray(par1DataOutputStream, this.verifyToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes this Packet on to the NetHandler for processing.
|
* Passes this Packet on to the NetHandler for processing.
|
||||||
*/
|
*/
|
||||||
public void processPacket(NetHandler par1NetHandler) {
|
public void processPacket(NetHandler par1NetHandler)
|
||||||
|
{
|
||||||
par1NetHandler.handleSharedKey(this);
|
par1NetHandler.handleSharedKey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Return the size of the packet (not counting the header).
|
* Abstract. Return the size of the packet (not counting the header).
|
||||||
*/
|
*/
|
||||||
public int getPacketSize() {
|
public int getPacketSize()
|
||||||
return 2 + 162 + 2 + 4;
|
{
|
||||||
|
return 2 + this.sharedSecret.length + 2 + this.verifyToken.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return secretKey, decrypting it from the sharedSecret byte array if needed
|
||||||
|
*/
|
||||||
|
public SecretKey getSharedKey(PrivateKey par1PrivateKey)
|
||||||
|
{
|
||||||
|
return par1PrivateKey == null ? this.sharedKey : (this.sharedKey = CryptManager.decryptSharedKey(par1PrivateKey, this.sharedSecret));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the secret AES sharedKey (used by client only)
|
||||||
|
*/
|
||||||
|
public SecretKey getSharedKey()
|
||||||
|
{
|
||||||
|
return this.getSharedKey((PrivateKey)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return verifyToken
|
||||||
|
*/
|
||||||
|
public byte[] getVerifyToken(PrivateKey par1PrivateKey)
|
||||||
|
{
|
||||||
|
return par1PrivateKey == null ? this.verifyToken : CryptManager.decryptData(par1PrivateKey, this.verifyToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,56 +3,71 @@ package net.minecraft.src;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
|
||||||
public class Packet253ServerAuthData extends Packet {
|
public class Packet253ServerAuthData extends Packet
|
||||||
|
{
|
||||||
private String serverId;
|
private String serverId;
|
||||||
|
private PublicKey publicKey;
|
||||||
private byte[] verifyToken = new byte[0];
|
private byte[] verifyToken = new byte[0];
|
||||||
|
|
||||||
public Packet253ServerAuthData() {
|
public Packet253ServerAuthData() {}
|
||||||
}
|
|
||||||
|
|
||||||
public Packet253ServerAuthData(String par1Str, byte[] par3ArrayOfByte) {
|
public Packet253ServerAuthData(String par1Str, PublicKey par2PublicKey, byte[] par3ArrayOfByte)
|
||||||
|
{
|
||||||
this.serverId = par1Str;
|
this.serverId = par1Str;
|
||||||
|
this.publicKey = par2PublicKey;
|
||||||
this.verifyToken = par3ArrayOfByte;
|
this.verifyToken = par3ArrayOfByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Reads the raw packet data from the data stream.
|
* Abstract. Reads the raw packet data from the data stream.
|
||||||
*/
|
*/
|
||||||
public void readPacketData(DataInputStream par1DataInputStream) throws IOException {
|
public void readPacketData(DataInputStream par1DataInputStream) throws IOException
|
||||||
|
{
|
||||||
this.serverId = readString(par1DataInputStream, 20);
|
this.serverId = readString(par1DataInputStream, 20);
|
||||||
readBytesFromStream(par1DataInputStream);
|
this.publicKey = CryptManager.decodePublicKey(readBytesFromStream(par1DataInputStream));
|
||||||
this.verifyToken = readBytesFromStream(par1DataInputStream);
|
this.verifyToken = readBytesFromStream(par1DataInputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Writes the raw packet data to the data stream.
|
* Abstract. Writes the raw packet data to the data stream.
|
||||||
*/
|
*/
|
||||||
public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException {
|
public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
|
||||||
|
{
|
||||||
writeString(this.serverId, par1DataOutputStream);
|
writeString(this.serverId, par1DataOutputStream);
|
||||||
writeByteArray(par1DataOutputStream, new byte[0]);
|
writeByteArray(par1DataOutputStream, this.publicKey.getEncoded());
|
||||||
writeByteArray(par1DataOutputStream, this.verifyToken);
|
writeByteArray(par1DataOutputStream, this.verifyToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes this Packet on to the NetHandler for processing.
|
* Passes this Packet on to the NetHandler for processing.
|
||||||
*/
|
*/
|
||||||
public void processPacket(NetHandler par1NetHandler) {
|
public void processPacket(NetHandler par1NetHandler)
|
||||||
|
{
|
||||||
par1NetHandler.handleServerAuthData(this);
|
par1NetHandler.handleServerAuthData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract. Return the size of the packet (not counting the header).
|
* Abstract. Return the size of the packet (not counting the header).
|
||||||
*/
|
*/
|
||||||
public int getPacketSize() {
|
public int getPacketSize()
|
||||||
return 2 + this.serverId.length() * 2 + 2 + 0 + 2 + this.verifyToken.length;
|
{
|
||||||
|
return 2 + this.serverId.length() * 2 + 2 + this.publicKey.getEncoded().length + 2 + this.verifyToken.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerId() {
|
public String getServerId()
|
||||||
|
{
|
||||||
return this.serverId;
|
return this.serverId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getVerifyToken() {
|
public PublicKey getPublicKey()
|
||||||
|
{
|
||||||
|
return this.publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getVerifyToken()
|
||||||
|
{
|
||||||
return this.verifyToken;
|
return this.verifyToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -324,7 +324,7 @@ public class SoundManager {
|
||||||
|
|
||||||
public void playTheTitleMusic() {
|
public void playTheTitleMusic() {
|
||||||
if(titleMusic == -1 || !EaglerAdapter.isPlaying(titleMusic)) {
|
if(titleMusic == -1 || !EaglerAdapter.isPlaying(titleMusic)) {
|
||||||
titleMusic = EaglerAdapter.beginPlaybackStatic("/sounds/gta.mp3", 1.0f, 1.0f);
|
titleMusic = EaglerAdapter.beginPlaybackStatic("/sounds/gta.mp3", this.options.musicVolume, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
src/main/java/org/bouncycastle/asn1/ASN1Encodable.java
Normal file
6
src/main/java/org/bouncycastle/asn1/ASN1Encodable.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package org.bouncycastle.asn1;
|
||||||
|
|
||||||
|
public interface ASN1Encodable
|
||||||
|
{
|
||||||
|
ASN1Primitive toASN1Primitive();
|
||||||
|
}
|
28
src/main/java/org/bouncycastle/asn1/ASN1Object.java
Normal file
28
src/main/java/org/bouncycastle/asn1/ASN1Object.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package org.bouncycastle.asn1;
|
||||||
|
|
||||||
|
public abstract class ASN1Object implements ASN1Encodable
|
||||||
|
{
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.toASN1Primitive().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object par1Obj)
|
||||||
|
{
|
||||||
|
if (this == par1Obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!(par1Obj instanceof ASN1Encodable))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASN1Encodable var2 = (ASN1Encodable)par1Obj;
|
||||||
|
return this.toASN1Primitive().equals(var2.toASN1Primitive());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract ASN1Primitive toASN1Primitive();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.bouncycastle.asn1;
|
||||||
|
|
||||||
|
public class ASN1ObjectIdentifier extends DERObjectIdentifier
|
||||||
|
{
|
||||||
|
public ASN1ObjectIdentifier(String par1Str)
|
||||||
|
{
|
||||||
|
super(par1Str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ASN1ObjectIdentifier branch(String par1Str)
|
||||||
|
{
|
||||||
|
return new ASN1ObjectIdentifier(this.getId() + "." + par1Str);
|
||||||
|
}
|
||||||
|
}
|
18
src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
Normal file
18
src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package org.bouncycastle.asn1;
|
||||||
|
|
||||||
|
public abstract class ASN1Primitive extends ASN1Object
|
||||||
|
{
|
||||||
|
public final boolean equals(Object par1Obj)
|
||||||
|
{
|
||||||
|
return this == par1Obj ? true : par1Obj instanceof ASN1Encodable && this.asn1Equals(((ASN1Encodable)par1Obj).toASN1Primitive());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ASN1Primitive toASN1Primitive()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int hashCode();
|
||||||
|
|
||||||
|
abstract boolean asn1Equals(ASN1Primitive var1);
|
||||||
|
}
|
86
src/main/java/org/bouncycastle/asn1/DERObjectIdentifier.java
Normal file
86
src/main/java/org/bouncycastle/asn1/DERObjectIdentifier.java
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
package org.bouncycastle.asn1;
|
||||||
|
|
||||||
|
public class DERObjectIdentifier extends ASN1Primitive
|
||||||
|
{
|
||||||
|
String identifier;
|
||||||
|
private static ASN1ObjectIdentifier[][] cache = new ASN1ObjectIdentifier[255][];
|
||||||
|
|
||||||
|
public DERObjectIdentifier(String par1Str)
|
||||||
|
{
|
||||||
|
if (!isValidIdentifier(par1Str))
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("string " + par1Str + " not an OID");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.identifier = par1Str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId()
|
||||||
|
{
|
||||||
|
return this.identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.identifier.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean asn1Equals(ASN1Primitive par1ASN1Primitive)
|
||||||
|
{
|
||||||
|
return !(par1ASN1Primitive instanceof DERObjectIdentifier) ? false : this.identifier.equals(((DERObjectIdentifier)par1ASN1Primitive).identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isValidIdentifier(String par0Str)
|
||||||
|
{
|
||||||
|
if (par0Str.length() >= 3 && par0Str.charAt(1) == 46)
|
||||||
|
{
|
||||||
|
char var1 = par0Str.charAt(0);
|
||||||
|
|
||||||
|
if (var1 >= 48 && var1 <= 50)
|
||||||
|
{
|
||||||
|
boolean var2 = false;
|
||||||
|
|
||||||
|
for (int var3 = par0Str.length() - 1; var3 >= 2; --var3)
|
||||||
|
{
|
||||||
|
char var4 = par0Str.charAt(var3);
|
||||||
|
|
||||||
|
if (48 <= var4 && var4 <= 57)
|
||||||
|
{
|
||||||
|
var2 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (var4 != 46)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!var2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var2 = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return var2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.bouncycastle.asn1.bc;
|
||||||
|
|
||||||
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||||
|
|
||||||
|
public interface BCObjectIdentifiers
|
||||||
|
{
|
||||||
|
ASN1ObjectIdentifier bc = new ASN1ObjectIdentifier("1.3.6.1.4.1.22554");
|
||||||
|
ASN1ObjectIdentifier bc_pbe = new ASN1ObjectIdentifier(bc.getId() + ".1");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1 = new ASN1ObjectIdentifier(bc_pbe.getId() + ".1");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256 = new ASN1ObjectIdentifier(bc_pbe.getId() + ".2.1");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha384 = new ASN1ObjectIdentifier(bc_pbe.getId() + ".2.2");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha512 = new ASN1ObjectIdentifier(bc_pbe.getId() + ".2.3");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha224 = new ASN1ObjectIdentifier(bc_pbe.getId() + ".2.4");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1_pkcs5 = new ASN1ObjectIdentifier(bc_pbe_sha1.getId() + ".1");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1_pkcs12 = new ASN1ObjectIdentifier(bc_pbe_sha1.getId() + ".2");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256_pkcs5 = new ASN1ObjectIdentifier(bc_pbe_sha256.getId() + ".1");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256_pkcs12 = new ASN1ObjectIdentifier(bc_pbe_sha256.getId() + ".2");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1_pkcs12_aes128_cbc = new ASN1ObjectIdentifier(bc_pbe_sha1_pkcs12.getId() + ".1.2");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1_pkcs12_aes192_cbc = new ASN1ObjectIdentifier(bc_pbe_sha1_pkcs12.getId() + ".1.22");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha1_pkcs12_aes256_cbc = new ASN1ObjectIdentifier(bc_pbe_sha1_pkcs12.getId() + ".1.42");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256_pkcs12_aes128_cbc = new ASN1ObjectIdentifier(bc_pbe_sha256_pkcs12.getId() + ".1.2");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256_pkcs12_aes192_cbc = new ASN1ObjectIdentifier(bc_pbe_sha256_pkcs12.getId() + ".1.22");
|
||||||
|
ASN1ObjectIdentifier bc_pbe_sha256_pkcs12_aes256_cbc = new ASN1ObjectIdentifier(bc_pbe_sha256_pkcs12.getId() + ".1.42");
|
||||||
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
package org.bouncycastle.asn1.pkcs;
|
||||||
|
|
||||||
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||||
|
|
||||||
|
public interface PKCSObjectIdentifiers
|
||||||
|
{
|
||||||
|
ASN1ObjectIdentifier pkcs_1 = new ASN1ObjectIdentifier("1.2.840.113549.1.1");
|
||||||
|
ASN1ObjectIdentifier rsaEncryption = pkcs_1.branch("1");
|
||||||
|
ASN1ObjectIdentifier md2WithRSAEncryption = pkcs_1.branch("2");
|
||||||
|
ASN1ObjectIdentifier md4WithRSAEncryption = pkcs_1.branch("3");
|
||||||
|
ASN1ObjectIdentifier md5WithRSAEncryption = pkcs_1.branch("4");
|
||||||
|
ASN1ObjectIdentifier sha1WithRSAEncryption = pkcs_1.branch("5");
|
||||||
|
ASN1ObjectIdentifier srsaOAEPEncryptionSET = pkcs_1.branch("6");
|
||||||
|
ASN1ObjectIdentifier id_RSAES_OAEP = pkcs_1.branch("7");
|
||||||
|
ASN1ObjectIdentifier id_mgf1 = pkcs_1.branch("8");
|
||||||
|
ASN1ObjectIdentifier id_pSpecified = pkcs_1.branch("9");
|
||||||
|
ASN1ObjectIdentifier id_RSASSA_PSS = pkcs_1.branch("10");
|
||||||
|
ASN1ObjectIdentifier sha256WithRSAEncryption = pkcs_1.branch("11");
|
||||||
|
ASN1ObjectIdentifier sha384WithRSAEncryption = pkcs_1.branch("12");
|
||||||
|
ASN1ObjectIdentifier sha512WithRSAEncryption = pkcs_1.branch("13");
|
||||||
|
ASN1ObjectIdentifier sha224WithRSAEncryption = pkcs_1.branch("14");
|
||||||
|
ASN1ObjectIdentifier pkcs_3 = new ASN1ObjectIdentifier("1.2.840.113549.1.3");
|
||||||
|
ASN1ObjectIdentifier dhKeyAgreement = pkcs_3.branch("1");
|
||||||
|
ASN1ObjectIdentifier pkcs_5 = new ASN1ObjectIdentifier("1.2.840.113549.1.5");
|
||||||
|
ASN1ObjectIdentifier pbeWithMD2AndDES_CBC = pkcs_5.branch("1");
|
||||||
|
ASN1ObjectIdentifier pbeWithMD2AndRC2_CBC = pkcs_5.branch("4");
|
||||||
|
ASN1ObjectIdentifier pbeWithMD5AndDES_CBC = pkcs_5.branch("3");
|
||||||
|
ASN1ObjectIdentifier pbeWithMD5AndRC2_CBC = pkcs_5.branch("6");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHA1AndDES_CBC = pkcs_5.branch("10");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHA1AndRC2_CBC = pkcs_5.branch("11");
|
||||||
|
ASN1ObjectIdentifier id_PBES2 = pkcs_5.branch("13");
|
||||||
|
ASN1ObjectIdentifier id_PBKDF2 = pkcs_5.branch("12");
|
||||||
|
ASN1ObjectIdentifier encryptionAlgorithm = new ASN1ObjectIdentifier("1.2.840.113549.3");
|
||||||
|
ASN1ObjectIdentifier des_EDE3_CBC = encryptionAlgorithm.branch("7");
|
||||||
|
ASN1ObjectIdentifier RC2_CBC = encryptionAlgorithm.branch("2");
|
||||||
|
ASN1ObjectIdentifier digestAlgorithm = new ASN1ObjectIdentifier("1.2.840.113549.2");
|
||||||
|
ASN1ObjectIdentifier md2 = digestAlgorithm.branch("2");
|
||||||
|
ASN1ObjectIdentifier md4 = digestAlgorithm.branch("4");
|
||||||
|
ASN1ObjectIdentifier md5 = digestAlgorithm.branch("5");
|
||||||
|
ASN1ObjectIdentifier id_hmacWithSHA1 = digestAlgorithm.branch("7");
|
||||||
|
ASN1ObjectIdentifier id_hmacWithSHA224 = digestAlgorithm.branch("8");
|
||||||
|
ASN1ObjectIdentifier id_hmacWithSHA256 = digestAlgorithm.branch("9");
|
||||||
|
ASN1ObjectIdentifier id_hmacWithSHA384 = digestAlgorithm.branch("10");
|
||||||
|
ASN1ObjectIdentifier id_hmacWithSHA512 = digestAlgorithm.branch("11");
|
||||||
|
ASN1ObjectIdentifier data = new ASN1ObjectIdentifier("1.2.840.113549.1.7.1");
|
||||||
|
ASN1ObjectIdentifier signedData = new ASN1ObjectIdentifier("1.2.840.113549.1.7.2");
|
||||||
|
ASN1ObjectIdentifier envelopedData = new ASN1ObjectIdentifier("1.2.840.113549.1.7.3");
|
||||||
|
ASN1ObjectIdentifier signedAndEnvelopedData = new ASN1ObjectIdentifier("1.2.840.113549.1.7.4");
|
||||||
|
ASN1ObjectIdentifier digestedData = new ASN1ObjectIdentifier("1.2.840.113549.1.7.5");
|
||||||
|
ASN1ObjectIdentifier encryptedData = new ASN1ObjectIdentifier("1.2.840.113549.1.7.6");
|
||||||
|
ASN1ObjectIdentifier pkcs_9 = new ASN1ObjectIdentifier("1.2.840.113549.1.9");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_emailAddress = pkcs_9.branch("1");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_unstructuredName = pkcs_9.branch("2");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_contentType = pkcs_9.branch("3");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_messageDigest = pkcs_9.branch("4");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_signingTime = pkcs_9.branch("5");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_counterSignature = pkcs_9.branch("6");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_challengePassword = pkcs_9.branch("7");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_unstructuredAddress = pkcs_9.branch("8");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_extendedCertificateAttributes = pkcs_9.branch("9");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_signingDescription = pkcs_9.branch("13");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_extensionRequest = pkcs_9.branch("14");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_smimeCapabilities = pkcs_9.branch("15");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_friendlyName = pkcs_9.branch("20");
|
||||||
|
ASN1ObjectIdentifier pkcs_9_at_localKeyId = pkcs_9.branch("21");
|
||||||
|
ASN1ObjectIdentifier x509certType = pkcs_9.branch("22.1");
|
||||||
|
ASN1ObjectIdentifier certTypes = pkcs_9.branch("22");
|
||||||
|
ASN1ObjectIdentifier x509Certificate = certTypes.branch("1");
|
||||||
|
ASN1ObjectIdentifier sdsiCertificate = certTypes.branch("2");
|
||||||
|
ASN1ObjectIdentifier crlTypes = pkcs_9.branch("23");
|
||||||
|
ASN1ObjectIdentifier x509Crl = crlTypes.branch("1");
|
||||||
|
ASN1ObjectIdentifier id_alg_PWRI_KEK = pkcs_9.branch("16.3.9");
|
||||||
|
ASN1ObjectIdentifier preferSignedData = pkcs_9.branch("15.1");
|
||||||
|
ASN1ObjectIdentifier canNotDecryptAny = pkcs_9.branch("15.2");
|
||||||
|
ASN1ObjectIdentifier sMIMECapabilitiesVersions = pkcs_9.branch("15.3");
|
||||||
|
ASN1ObjectIdentifier id_ct = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.1");
|
||||||
|
ASN1ObjectIdentifier id_ct_authData = id_ct.branch("2");
|
||||||
|
ASN1ObjectIdentifier id_ct_TSTInfo = id_ct.branch("4");
|
||||||
|
ASN1ObjectIdentifier id_ct_compressedData = id_ct.branch("9");
|
||||||
|
ASN1ObjectIdentifier id_ct_authEnvelopedData = id_ct.branch("23");
|
||||||
|
ASN1ObjectIdentifier id_ct_timestampedData = id_ct.branch("31");
|
||||||
|
ASN1ObjectIdentifier id_cti = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.6");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfOrigin = id_cti.branch("1");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfReceipt = id_cti.branch("2");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfDelivery = id_cti.branch("3");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfSender = id_cti.branch("4");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfApproval = id_cti.branch("5");
|
||||||
|
ASN1ObjectIdentifier id_cti_ets_proofOfCreation = id_cti.branch("6");
|
||||||
|
ASN1ObjectIdentifier id_aa = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.2");
|
||||||
|
ASN1ObjectIdentifier id_aa_receiptRequest = id_aa.branch("1");
|
||||||
|
ASN1ObjectIdentifier id_aa_contentHint = id_aa.branch("4");
|
||||||
|
ASN1ObjectIdentifier id_aa_msgSigDigest = id_aa.branch("5");
|
||||||
|
ASN1ObjectIdentifier id_aa_contentReference = id_aa.branch("10");
|
||||||
|
ASN1ObjectIdentifier id_aa_encrypKeyPref = id_aa.branch("11");
|
||||||
|
ASN1ObjectIdentifier id_aa_signingCertificate = id_aa.branch("12");
|
||||||
|
ASN1ObjectIdentifier id_aa_signingCertificateV2 = id_aa.branch("47");
|
||||||
|
ASN1ObjectIdentifier id_aa_contentIdentifier = id_aa.branch("7");
|
||||||
|
ASN1ObjectIdentifier id_aa_signatureTimeStampToken = id_aa.branch("14");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_sigPolicyId = id_aa.branch("15");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_commitmentType = id_aa.branch("16");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_signerLocation = id_aa.branch("17");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_signerAttr = id_aa.branch("18");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_otherSigCert = id_aa.branch("19");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_contentTimestamp = id_aa.branch("20");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_certificateRefs = id_aa.branch("21");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_revocationRefs = id_aa.branch("22");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_certValues = id_aa.branch("23");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_revocationValues = id_aa.branch("24");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_escTimeStamp = id_aa.branch("25");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_certCRLTimestamp = id_aa.branch("26");
|
||||||
|
ASN1ObjectIdentifier id_aa_ets_archiveTimestamp = id_aa.branch("27");
|
||||||
|
ASN1ObjectIdentifier id_aa_sigPolicyId = id_aa_ets_sigPolicyId;
|
||||||
|
ASN1ObjectIdentifier id_aa_commitmentType = id_aa_ets_commitmentType;
|
||||||
|
ASN1ObjectIdentifier id_aa_signerLocation = id_aa_ets_signerLocation;
|
||||||
|
ASN1ObjectIdentifier id_aa_otherSigCert = id_aa_ets_otherSigCert;
|
||||||
|
ASN1ObjectIdentifier id_spq_ets_uri = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.5.1");
|
||||||
|
ASN1ObjectIdentifier id_spq_ets_unotice = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.5.2");
|
||||||
|
ASN1ObjectIdentifier pkcs_12 = new ASN1ObjectIdentifier("1.2.840.113549.1.12");
|
||||||
|
ASN1ObjectIdentifier bagtypes = pkcs_12.branch("10.1");
|
||||||
|
ASN1ObjectIdentifier keyBag = bagtypes.branch("1");
|
||||||
|
ASN1ObjectIdentifier pkcs8ShroudedKeyBag = bagtypes.branch("2");
|
||||||
|
ASN1ObjectIdentifier certBag = bagtypes.branch("3");
|
||||||
|
ASN1ObjectIdentifier crlBag = bagtypes.branch("4");
|
||||||
|
ASN1ObjectIdentifier secretBag = bagtypes.branch("5");
|
||||||
|
ASN1ObjectIdentifier safeContentsBag = bagtypes.branch("6");
|
||||||
|
ASN1ObjectIdentifier pkcs_12PbeIds = pkcs_12.branch("1");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd128BitRC4 = pkcs_12PbeIds.branch("1");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd40BitRC4 = pkcs_12PbeIds.branch("2");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd3_KeyTripleDES_CBC = pkcs_12PbeIds.branch("3");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd2_KeyTripleDES_CBC = pkcs_12PbeIds.branch("4");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd128BitRC2_CBC = pkcs_12PbeIds.branch("5");
|
||||||
|
ASN1ObjectIdentifier pbeWithSHAAnd40BitRC2_CBC = pkcs_12PbeIds.branch("6");
|
||||||
|
ASN1ObjectIdentifier pbewithSHAAnd40BitRC2_CBC = pkcs_12PbeIds.branch("6");
|
||||||
|
ASN1ObjectIdentifier id_alg_CMS3DESwrap = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.3.6");
|
||||||
|
ASN1ObjectIdentifier id_alg_CMSRC2wrap = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.3.7");
|
||||||
|
}
|
20
src/main/java/org/bouncycastle/crypto/BlockCipher.java
Normal file
20
src/main/java/org/bouncycastle/crypto/BlockCipher.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public interface BlockCipher
|
||||||
|
{
|
||||||
|
void init(boolean var1, CipherParameters var2) throws IllegalArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the algorithm the cipher implements.
|
||||||
|
*/
|
||||||
|
String getAlgorithmName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the block size for this cipher (in bytes).
|
||||||
|
*/
|
||||||
|
int getBlockSize();
|
||||||
|
|
||||||
|
int processBlock(byte[] var1, int var2, byte[] var3, int var4) throws DataLengthException, IllegalStateException;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
}
|
161
src/main/java/org/bouncycastle/crypto/BufferedBlockCipher.java
Normal file
161
src/main/java/org/bouncycastle/crypto/BufferedBlockCipher.java
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public class BufferedBlockCipher
|
||||||
|
{
|
||||||
|
protected byte[] buf;
|
||||||
|
protected int bufOff;
|
||||||
|
protected boolean forEncryption;
|
||||||
|
protected BlockCipher cipher;
|
||||||
|
protected boolean partialBlockOkay;
|
||||||
|
protected boolean pgpCFB;
|
||||||
|
|
||||||
|
protected BufferedBlockCipher() {}
|
||||||
|
|
||||||
|
public BufferedBlockCipher(BlockCipher par1BlockCipher)
|
||||||
|
{
|
||||||
|
this.cipher = par1BlockCipher;
|
||||||
|
this.buf = new byte[par1BlockCipher.getBlockSize()];
|
||||||
|
this.bufOff = 0;
|
||||||
|
String var2 = par1BlockCipher.getAlgorithmName();
|
||||||
|
int var3 = var2.indexOf(47) + 1;
|
||||||
|
this.pgpCFB = var3 > 0 && var2.startsWith("PGP", var3);
|
||||||
|
|
||||||
|
if (this.pgpCFB)
|
||||||
|
{
|
||||||
|
this.partialBlockOkay = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.partialBlockOkay = var3 > 0 && (var2.startsWith("CFB", var3) || var2.startsWith("OFB", var3) || var2.startsWith("OpenPGP", var3) || var2.startsWith("SIC", var3) || var2.startsWith("GCTR", var3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(boolean par1, CipherParameters par2CipherParameters) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
this.forEncryption = par1;
|
||||||
|
this.reset();
|
||||||
|
this.cipher.init(par1, par2CipherParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockSize()
|
||||||
|
{
|
||||||
|
return this.cipher.getBlockSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUpdateOutputSize(int par1)
|
||||||
|
{
|
||||||
|
int var2 = par1 + this.bufOff;
|
||||||
|
int var3;
|
||||||
|
|
||||||
|
if (this.pgpCFB)
|
||||||
|
{
|
||||||
|
var3 = var2 % this.buf.length - (this.cipher.getBlockSize() + 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var3 = var2 % this.buf.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return var2 - var3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOutputSize(int par1)
|
||||||
|
{
|
||||||
|
return par1 + this.bufOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int processByte(byte[] par1ArrayOfByte, int par2, int par3, byte[] par4ArrayOfByte, int par5) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
if (par3 < 0)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Can\'t have a negative input length!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int var6 = this.getBlockSize();
|
||||||
|
int var7 = this.getUpdateOutputSize(par3);
|
||||||
|
|
||||||
|
if (var7 > 0 && par5 + var7 > par4ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("output buffer too short");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int var8 = 0;
|
||||||
|
int var9 = this.buf.length - this.bufOff;
|
||||||
|
|
||||||
|
if (par3 > var9)
|
||||||
|
{
|
||||||
|
System.arraycopy(par1ArrayOfByte, par2, this.buf, this.bufOff, var9);
|
||||||
|
var8 += this.cipher.processBlock(this.buf, 0, par4ArrayOfByte, par5);
|
||||||
|
this.bufOff = 0;
|
||||||
|
par3 -= var9;
|
||||||
|
|
||||||
|
for (par2 += var9; par3 > this.buf.length; par2 += var6)
|
||||||
|
{
|
||||||
|
var8 += this.cipher.processBlock(par1ArrayOfByte, par2, par4ArrayOfByte, par5 + var8);
|
||||||
|
par3 -= var6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.arraycopy(par1ArrayOfByte, par2, this.buf, this.bufOff, par3);
|
||||||
|
this.bufOff += par3;
|
||||||
|
|
||||||
|
if (this.bufOff == this.buf.length)
|
||||||
|
{
|
||||||
|
var8 += this.cipher.processBlock(this.buf, 0, par4ArrayOfByte, par5 + var8);
|
||||||
|
this.bufOff = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return var8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int doFinal(byte[] par1ArrayOfByte, int par2) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
int var4;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int var3 = 0;
|
||||||
|
|
||||||
|
if (par2 + this.bufOff > par1ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("output buffer too short for doFinal()");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.bufOff != 0)
|
||||||
|
{
|
||||||
|
if (!this.partialBlockOkay)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("data not block size aligned");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cipher.processBlock(this.buf, 0, this.buf, 0);
|
||||||
|
var3 = this.bufOff;
|
||||||
|
this.bufOff = 0;
|
||||||
|
System.arraycopy(this.buf, 0, par1ArrayOfByte, par2, var3);
|
||||||
|
}
|
||||||
|
|
||||||
|
var4 = var3;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return var4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
for (int var1 = 0; var1 < this.buf.length; ++var1)
|
||||||
|
{
|
||||||
|
this.buf[var1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bufOff = 0;
|
||||||
|
this.cipher.reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
public class CipherKeyGenerator
|
||||||
|
{
|
||||||
|
protected SecureRandom random;
|
||||||
|
protected int strength;
|
||||||
|
|
||||||
|
public void init(KeyGenerationParameters par1)
|
||||||
|
{
|
||||||
|
this.random = par1.getRandom();
|
||||||
|
this.strength = (par1.getStrength() + 7) / 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] generateKey()
|
||||||
|
{
|
||||||
|
byte[] var1 = new byte[this.strength];
|
||||||
|
this.random.nextBytes(var1);
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public interface CipherParameters
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public class DataLengthException extends RuntimeCryptoException
|
||||||
|
{
|
||||||
|
public DataLengthException() {}
|
||||||
|
|
||||||
|
public DataLengthException(String par1Str)
|
||||||
|
{
|
||||||
|
super(par1Str);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
public class KeyGenerationParameters
|
||||||
|
{
|
||||||
|
private SecureRandom random;
|
||||||
|
private int strength;
|
||||||
|
|
||||||
|
public KeyGenerationParameters(SecureRandom par1SecureRandom, int par2)
|
||||||
|
{
|
||||||
|
this.random = par1SecureRandom;
|
||||||
|
this.strength = par2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the random source associated with this generator.
|
||||||
|
*/
|
||||||
|
public SecureRandom getRandom()
|
||||||
|
{
|
||||||
|
return this.random;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the bit strength for keys produced by this generator.
|
||||||
|
*/
|
||||||
|
public int getStrength()
|
||||||
|
{
|
||||||
|
return this.strength;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public class RuntimeCryptoException extends RuntimeException
|
||||||
|
{
|
||||||
|
public RuntimeCryptoException() {}
|
||||||
|
|
||||||
|
public RuntimeCryptoException(String par1Str)
|
||||||
|
{
|
||||||
|
super(par1Str);
|
||||||
|
}
|
||||||
|
}
|
11
src/main/java/org/bouncycastle/crypto/StreamCipher.java
Normal file
11
src/main/java/org/bouncycastle/crypto/StreamCipher.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package org.bouncycastle.crypto;
|
||||||
|
|
||||||
|
public interface StreamCipher
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Encrypt/decrypt a single byte, returning the result.
|
||||||
|
*/
|
||||||
|
byte returnByte(byte var1);
|
||||||
|
|
||||||
|
void processBytes(byte[] var1, int var2, int var3, byte[] var4, int var5) throws DataLengthException;
|
||||||
|
}
|
279
src/main/java/org/bouncycastle/crypto/engines/AESFastEngine.java
Normal file
279
src/main/java/org/bouncycastle/crypto/engines/AESFastEngine.java
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
package org.bouncycastle.crypto.engines;
|
||||||
|
|
||||||
|
import org.bouncycastle.crypto.BlockCipher;
|
||||||
|
import org.bouncycastle.crypto.CipherParameters;
|
||||||
|
import org.bouncycastle.crypto.DataLengthException;
|
||||||
|
import org.bouncycastle.crypto.params.KeyParameter;
|
||||||
|
|
||||||
|
public class AESFastEngine implements BlockCipher
|
||||||
|
{
|
||||||
|
private static final byte[] S = new byte[] {(byte)99, (byte)124, (byte)119, (byte)123, (byte) - 14, (byte)107, (byte)111, (byte) - 59, (byte)48, (byte)1, (byte)103, (byte)43, (byte) - 2, (byte) - 41, (byte) - 85, (byte)118, (byte) - 54, (byte) - 126, (byte) - 55, (byte)125, (byte) - 6, (byte)89, (byte)71, (byte) - 16, (byte) - 83, (byte) - 44, (byte) - 94, (byte) - 81, (byte) - 100, (byte) - 92, (byte)114, (byte) - 64, (byte) - 73, (byte) - 3, (byte) - 109, (byte)38, (byte)54, (byte)63, (byte) - 9, (byte) - 52, (byte)52, (byte) - 91, (byte) - 27, (byte) - 15, (byte)113, (byte) - 40, (byte)49, (byte)21, (byte)4, (byte) - 57, (byte)35, (byte) - 61, (byte)24, (byte) - 106, (byte)5, (byte) - 102, (byte)7, (byte)18, (byte) - 128, (byte) - 30, (byte) - 21, (byte)39, (byte) - 78, (byte)117, (byte)9, (byte) - 125, (byte)44, (byte)26, (byte)27, (byte)110, (byte)90, (byte) - 96, (byte)82, (byte)59, (byte) - 42, (byte) - 77, (byte)41, (byte) - 29, (byte)47, (byte) - 124, (byte)83, (byte) - 47, (byte)0, (byte) - 19, (byte)32, (byte) - 4, (byte) - 79, (byte)91, (byte)106, (byte) - 53, (byte) - 66, (byte)57, (byte)74, (byte)76, (byte)88, (byte) - 49, (byte) - 48, (byte) - 17, (byte) - 86, (byte) - 5, (byte)67, (byte)77, (byte)51, (byte) - 123, (byte)69, (byte) - 7, (byte)2, (byte)127, (byte)80, (byte)60, (byte) - 97, (byte) - 88, (byte)81, (byte) - 93, (byte)64, (byte) - 113, (byte) - 110, (byte) - 99, (byte)56, (byte) - 11, (byte) - 68, (byte) - 74, (byte) - 38, (byte)33, (byte)16, (byte) - 1, (byte) - 13, (byte) - 46, (byte) - 51, (byte)12, (byte)19, (byte) - 20, (byte)95, (byte) - 105, (byte)68, (byte)23, (byte) - 60, (byte) - 89, (byte)126, (byte)61, (byte)100, (byte)93, (byte)25, (byte)115, (byte)96, (byte) - 127, (byte)79, (byte) - 36, (byte)34, (byte)42, (byte) - 112, (byte) - 120, (byte)70, (byte) - 18, (byte) - 72, (byte)20, (byte) - 34, (byte)94, (byte)11, (byte) - 37, (byte) - 32, (byte)50, (byte)58, (byte)10, (byte)73, (byte)6, (byte)36, (byte)92, (byte) - 62, (byte) - 45, (byte) - 84, (byte)98, (byte) - 111, (byte) - 107, (byte) - 28, (byte)121, (byte) - 25, (byte) - 56, (byte)55, (byte)109, (byte) - 115, (byte) - 43, (byte)78, (byte) - 87, (byte)108, (byte)86, (byte) - 12, (byte) - 22, (byte)101, (byte)122, (byte) - 82, (byte)8, (byte) - 70, (byte)120, (byte)37, (byte)46, (byte)28, (byte) - 90, (byte) - 76, (byte) - 58, (byte) - 24, (byte) - 35, (byte)116, (byte)31, (byte)75, (byte) - 67, (byte) - 117, (byte) - 118, (byte)112, (byte)62, (byte) - 75, (byte)102, (byte)72, (byte)3, (byte) - 10, (byte)14, (byte)97, (byte)53, (byte)87, (byte) - 71, (byte) - 122, (byte) - 63, (byte)29, (byte) - 98, (byte) - 31, (byte) - 8, (byte) - 104, (byte)17, (byte)105, (byte) - 39, (byte) - 114, (byte) - 108, (byte) - 101, (byte)30, (byte) - 121, (byte) - 23, (byte) - 50, (byte)85, (byte)40, (byte) - 33, (byte) - 116, (byte) - 95, (byte) - 119, (byte)13, (byte) - 65, (byte) - 26, (byte)66, (byte)104, (byte)65, (byte) - 103, (byte)45, (byte)15, (byte) - 80, (byte)84, (byte) - 69, (byte)22};
|
||||||
|
private static final byte[] Si = new byte[] {(byte)82, (byte)9, (byte)106, (byte) - 43, (byte)48, (byte)54, (byte) - 91, (byte)56, (byte) - 65, (byte)64, (byte) - 93, (byte) - 98, (byte) - 127, (byte) - 13, (byte) - 41, (byte) - 5, (byte)124, (byte) - 29, (byte)57, (byte) - 126, (byte) - 101, (byte)47, (byte) - 1, (byte) - 121, (byte)52, (byte) - 114, (byte)67, (byte)68, (byte) - 60, (byte) - 34, (byte) - 23, (byte) - 53, (byte)84, (byte)123, (byte) - 108, (byte)50, (byte) - 90, (byte) - 62, (byte)35, (byte)61, (byte) - 18, (byte)76, (byte) - 107, (byte)11, (byte)66, (byte) - 6, (byte) - 61, (byte)78, (byte)8, (byte)46, (byte) - 95, (byte)102, (byte)40, (byte) - 39, (byte)36, (byte) - 78, (byte)118, (byte)91, (byte) - 94, (byte)73, (byte)109, (byte) - 117, (byte) - 47, (byte)37, (byte)114, (byte) - 8, (byte) - 10, (byte)100, (byte) - 122, (byte)104, (byte) - 104, (byte)22, (byte) - 44, (byte) - 92, (byte)92, (byte) - 52, (byte)93, (byte)101, (byte) - 74, (byte) - 110, (byte)108, (byte)112, (byte)72, (byte)80, (byte) - 3, (byte) - 19, (byte) - 71, (byte) - 38, (byte)94, (byte)21, (byte)70, (byte)87, (byte) - 89, (byte) - 115, (byte) - 99, (byte) - 124, (byte) - 112, (byte) - 40, (byte) - 85, (byte)0, (byte) - 116, (byte) - 68, (byte) - 45, (byte)10, (byte) - 9, (byte) - 28, (byte)88, (byte)5, (byte) - 72, (byte) - 77, (byte)69, (byte)6, (byte) - 48, (byte)44, (byte)30, (byte) - 113, (byte) - 54, (byte)63, (byte)15, (byte)2, (byte) - 63, (byte) - 81, (byte) - 67, (byte)3, (byte)1, (byte)19, (byte) - 118, (byte)107, (byte)58, (byte) - 111, (byte)17, (byte)65, (byte)79, (byte)103, (byte) - 36, (byte) - 22, (byte) - 105, (byte) - 14, (byte) - 49, (byte) - 50, (byte) - 16, (byte) - 76, (byte) - 26, (byte)115, (byte) - 106, (byte) - 84, (byte)116, (byte)34, (byte) - 25, (byte) - 83, (byte)53, (byte) - 123, (byte) - 30, (byte) - 7, (byte)55, (byte) - 24, (byte)28, (byte)117, (byte) - 33, (byte)110, (byte)71, (byte) - 15, (byte)26, (byte)113, (byte)29, (byte)41, (byte) - 59, (byte) - 119, (byte)111, (byte) - 73, (byte)98, (byte)14, (byte) - 86, (byte)24, (byte) - 66, (byte)27, (byte) - 4, (byte)86, (byte)62, (byte)75, (byte) - 58, (byte) - 46, (byte)121, (byte)32, (byte) - 102, (byte) - 37, (byte) - 64, (byte) - 2, (byte)120, (byte) - 51, (byte)90, (byte) - 12, (byte)31, (byte) - 35, (byte) - 88, (byte)51, (byte) - 120, (byte)7, (byte) - 57, (byte)49, (byte) - 79, (byte)18, (byte)16, (byte)89, (byte)39, (byte) - 128, (byte) - 20, (byte)95, (byte)96, (byte)81, (byte)127, (byte) - 87, (byte)25, (byte) - 75, (byte)74, (byte)13, (byte)45, (byte) - 27, (byte)122, (byte) - 97, (byte) - 109, (byte) - 55, (byte) - 100, (byte) - 17, (byte) - 96, (byte) - 32, (byte)59, (byte)77, (byte) - 82, (byte)42, (byte) - 11, (byte) - 80, (byte) - 56, (byte) - 21, (byte) - 69, (byte)60, (byte) - 125, (byte)83, (byte) - 103, (byte)97, (byte)23, (byte)43, (byte)4, (byte)126, (byte) - 70, (byte)119, (byte) - 42, (byte)38, (byte) - 31, (byte)105, (byte)20, (byte)99, (byte)85, (byte)33, (byte)12, (byte)125};
|
||||||
|
private static final int[] rcon = new int[] {1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145};
|
||||||
|
private static final int[] T0 = new int[] { -1520213050, -2072216328, -1720223762, -1921287178, 234025727, -1117033514, -1318096930, 1422247313, 1345335392, 50397442, -1452841010, 2099981142, 436141799, 1658312629, -424957107, -1703512340, 1170918031, -1652391393, 1086966153, -2021818886, 368769775, -346465870, -918075506, 200339707, -324162239, 1742001331, -39673249, -357585083, -1080255453, -140204973, -1770884380, 1539358875, -1028147339, 486407649, -1366060227, 1780885068, 1513502316, 1094664062, 49805301, 1338821763, 1546925160, -190470831, 887481809, 150073849, -1821281822, 1943591083, 1395732834, 1058346282, 201589768, 1388824469, 1696801606, 1589887901, 672667696, -1583966665, 251987210, -1248159185, 151455502, 907153956, -1686077413, 1038279391, 652995533, 1764173646, -843926913, -1619692054, 453576978, -1635548387, 1949051992, 773462580, 756751158, -1301385508, -296068428, -73359269, -162377052, 1295727478, 1641469623, -827083907, 2066295122, 1055122397, 1898917726, -1752923117, -179088474, 1758581177, 0, 753790401, 1612718144, 536673507, -927878791, -312779850, -1100322092, 1187761037, -641810841, 1262041458, -565556588, -733197160, -396863312, 1255133061, 1808847035, 720367557, -441800113, 385612781, -985447546, -682799718, 1429418854, -1803188975, -817543798, 284817897, 100794884, -2122350594, -263171936, 1144798328, -1163944155, -475486133, -212774494, -22830243, -1069531008, -1970303227, -1382903233, -1130521311, 1211644016, 83228145, -541279133, -1044990345, 1977277103, 1663115586, 806359072, 452984805, 250868733, 1842533055, 1288555905, 336333848, 890442534, 804056259, -513843266, -1567123659, -867941240, 957814574, 1472513171, -223893675, -2105639172, 1195195770, -1402706744, -413311558, 723065138, -1787595802, -1604296512, -1736343271, -783331426, 2145180835, 1713513028, 2116692564, -1416589253, -2088204277, -901364084, 703524551, -742868885, 1007948840, 2044649127, -497131844, 487262998, 1994120109, 1004593371, 1446130276, 1312438900, 503974420, -615954030, 168166924, 1814307912, -463709000, 1573044895, 1859376061, -273896381, -1503501628, -1466855111, -1533700815, 937747667, -1954973198, 854058965, 1137232011, 1496790894, -1217565222, -1936880383, 1691735473, -766620004, -525751991, -1267962664, -95005012, 133494003, 636152527, -1352309302, -1904575756, -374428089, 403179536, -709182865, -2005370640, 1864705354, 1915629148, 605822008, -240736681, -944458637, 1371981463, 602466507, 2094914977, -1670089496, 555687742, -582268010, -591544991, -2037675251, -2054518257, -1871679264, 1111375484, -994724495, -1436129588, -666351472, 84083462, 32962295, 302911004, -1553899070, 1597322602, -111716434, -793134743, -1853454825, 1489093017, 656219450, -1180787161, 954327513, 335083755, -1281845205, 856756514, -1150719534, 1893325225, -1987146233, -1483434957, -1231316179, 572399164, -1836611819, 552200649, 1238290055, -11184726, 2015897680, 2061492133, -1886614525, -123625127, -2138470135, 386731290, -624967835, 837215959, -968736124, -1201116976, -1019133566, -1332111063, 1999449434, 286199582, -877612933, -61582168, -692339859, 974525996};
|
||||||
|
private static final int[] T1 = new int[] {1667483301, 2088564868, 2004348569, 2071721613, -218956019, 1802229437, 1869602481, -976907948, 808476752, 16843267, 1734856361, 724260477, -16849127, -673729182, -1414836762, 1987505306, -892694715, -2105401443, -909539008, 2105408135, -84218091, 1499050731, 1195871945, -252642549, -1381154324, -724257945, -1566416899, -1347467798, -1667488833, -1532734473, 1920132246, -1061119141, -1212713534, -33693412, -1819066962, 640044138, 909536346, 1061125697, -134744830, -859012273, 875849820, -1515892236, -437923532, -235800312, 1903288979, -656888973, 825320019, 353708607, 67373068, -943221422, 589514341, -1010590370, 404238376, -1768540255, 84216335, -1701171275, 117902857, 303178806, -2139087973, -488448195, -336868058, 656887401, -1296924723, 1970662047, 151589403, -2088559202, 741103732, 437924910, 454768173, 1852759218, 1515893998, -1600103429, 1381147894, 993752653, -690571423, -1280082482, 690573947, -471605954, 791633521, -2071719017, 1397991157, -774784664, 0, -303185620, 538984544, -50535649, -1313769016, 1532737261, 1785386174, -875852474, -1094817831, 960066123, 1246401758, 1280088276, 1482207464, -808483510, -791626901, -269499094, -1431679003, -67375850, 1128498885, 1296931543, 859006549, -2054876780, 1162185423, -101062384, 33686534, 2139094657, 1347461360, 1010595908, -1616960070, -1465365533, 1364304627, -1549574658, 1077969088, -1886452342, -1835909203, -1650646596, 943222856, -168431356, -1128504353, -1229555775, -623202443, 555827811, 269492272, -6886, -202113778, -757940371, -842170036, 202119188, 320022069, -320027857, 1600110305, -1751698014, 1145342156, 387395129, -993750185, -1482205710, 2122251394, 1027439175, 1684326572, 1566423783, 421081643, 1936975509, 1616953504, -2122245736, 1330618065, -589520001, 572671078, 707417214, -1869595733, -2004350077, 1179028682, -286341335, -1195873325, 336865340, -555833479, 1583267042, 185275933, -606360202, -522134725, 842163286, 976909390, 168432670, 1229558491, 101059594, 606357612, 1549580516, -1027432611, -741098130, -1397996561, 1650640038, -1852753496, -1785384540, -454765769, 2038035083, -404237006, -926381245, 926379609, 1835915959, -1920138868, -707415708, 1313774802, -1448523296, 1819072692, 1448520954, -185273593, -353710299, 1701169839, 2054878350, -1364310039, 134746136, -1162186795, 2021191816, 623200879, 774790258, 471611428, -1499047951, -1263242297, -960063663, -387396829, -572677764, 1953818780, 522141217, 1263245021, -1111662116, -1953821306, -1970663547, 1886445712, 1044282434, -1246400060, 1718013098, 1212715224, 50529797, -151587071, 235805714, 1633796771, 892693087, 1465364217, -1179031088, -2038032495, -1044276904, 488454695, -1633802311, -505292488, -117904621, -1734857805, 286335539, 1768542907, -640046736, -1903294583, -1802226777, -1684329034, 505297954, -2021190254, -370554592, -825325751, 1431677695, 673730680, -538991238, -1936981105, -1583261192, -1987507840, 218962455, -1077975590, -421079247, 1111655622, 1751699640, 1094812355, -1718015568, 757946999, 252648977, -1330611253, 1414834428, -1145344554, 370551866};
|
||||||
|
private static final int[] T2 = new int[] {1673962851, 2096661628, 2012125559, 2079755643, -218165774, 1809235307, 1876865391, -980331323, 811618352, 16909057, 1741597031, 727088427, -18408962, -675978537, -1420958037, 1995217526, -896580150, -2111857278, -913751863, 2113570685, -84994566, 1504897881, 1200539975, -251982864, -1388188499, -726439980, -1570767454, -1354372433, -1675378788, -1538000988, 1927583346, -1063560256, -1217019209, -35578627, -1824674157, 642542118, 913070646, 1065238847, -134937865, -863809588, 879254580, -1521355611, -439274267, -235337487, 1910674289, -659852328, 828527409, 355090197, 67636228, -946515257, 591815971, -1013096765, 405809176, -1774739050, 84545285, -1708149350, 118360327, 304363026, -2145674368, -488686110, -338876693, 659450151, -1300247118, 1978310517, 152181513, -2095210877, 743994412, 439627290, 456535323, 1859957358, 1521806938, -1604584544, 1386542674, 997608763, -692624938, -1283600717, 693271337, -472039709, 794718511, -2079090812, 1403450707, -776378159, 0, -306107155, 541089824, -52224004, -1317418831, 1538714971, 1792327274, -879933749, -1100490306, 963791673, 1251270218, 1285084236, 1487988824, -813348145, -793023536, -272291089, -1437604438, -68348165, 1132905795, 1301993293, 862344499, -2062445435, 1166724933, -102166279, 33818114, 2147385727, 1352724560, 1014514748, -1624917345, -1471421528, 1369633617, -1554121053, 1082179648, -1895462257, -1841320558, -1658733411, 946882616, -168753931, -1134305348, -1233665610, -626035238, 557998881, 270544912, -1762561, -201519373, -759206446, -847164211, 202904588, 321271059, -322752532, 1606345055, -1758092649, 1149815876, 388905239, -996976700, -1487539545, 2130477694, 1031423805, 1690872932, 1572530013, 422718233, 1944491379, 1623236704, -2129028991, 1335808335, -593264676, 574907938, 710180394, -1875137648, -2012511352, 1183631942, -288937490, -1200893000, 338181140, -559449634, 1589437022, 185998603, -609388837, -522503200, 845436466, 980700730, 169090570, 1234361161, 101452294, 608726052, 1555620956, -1029743166, -742560045, -1404833876, 1657054818, -1858492271, -1791908715, -455919644, 2045938553, -405458201, -930397240, 929978679, 1843050349, -1929278323, -709794603, 1318900302, -1454776151, 1826141292, 1454176854, -185399308, -355523094, 1707781989, 2062847610, -1371018834, 135272456, -1167075910, 2029029496, 625635109, 777810478, 473441308, -1504185946, -1267480652, -963161658, -389340184, -576619299, 1961401460, 524165407, 1268178251, -1117659971, -1962047861, -1978694262, 1893765232, 1048330814, -1250835275, 1724688998, 1217452104, 50726147, -151584266, 236720654, 1640145761, 896163637, 1471084887, -1184247623, -2045275770, -1046914879, 490350365, -1641563746, -505857823, -118811656, -1741966440, 287453969, 1775418217, -643206951, -1912108658, -1808554092, -1691502949, 507257374, -2028629369, -372694807, -829994546, 1437269845, 676362280, -542803233, -1945923700, -1587939167, -1995865975, 219813645, -1083843905, -422104602, 1115997762, 1758509160, 1099088705, -1725321063, 760903469, 253628687, -1334064208, 1420360788, -1150429509, 371997206};
|
||||||
|
private static final int[] T3 = new int[] { -962239645, -125535108, -291932297, -158499973, -15863054, -692229269, -558796945, -1856715323, 1615867952, 33751297, -827758745, 1451043627, -417726722, -1251813417, 1306962859, -325421450, -1891251510, 530416258, -1992242743, -91783811, -283772166, -1293199015, -1899411641, -83103504, 1106029997, -1285040940, 1610457762, 1173008303, 599760028, 1408738468, -459902350, -1688485696, 1975695287, -518193667, 1034851219, 1282024998, 1817851446, 2118205247, -184354825, -2091922228, 1750873140, 1374987685, -785062427, -116854287, -493653647, -1418471208, 1649619249, 708777237, 135005188, -1789737017, 1181033251, -1654733885, 807933976, 933336726, 168756485, 800430746, 235472647, 607523346, 463175808, -549592350, -853087253, 1315514151, 2144187058, -358648459, 303761673, 496927619, 1484008492, 875436570, 908925723, -592286098, -1259447718, 1543217312, -1527360942, 1984772923, -1218324778, 2110698419, 1383803177, -583080989, 1584475951, 328696964, -1493871789, -1184312879, 0, -1054020115, 1080041504, -484442884, 2043195825, -1225958565, -725718422, -1924740149, 1742323390, 1917532473, -1797371318, -1730917300, -1326950312, -2058694705, -1150562096, -987041809, 1340451498, -317260805, -2033892541, -1697166003, 1716859699, 294946181, -1966127803, -384763399, 67502594, -25067649, -1594863536, 2017737788, 632987551, 1273211048, -1561112239, 1576969123, -2134884288, 92966799, 1068339858, 566009245, 1883781176, -251333131, 1675607228, 2009183926, -1351230758, 1113792801, 540020752, -451215361, -49351693, -1083321646, -2125673011, 403966988, 641012499, -1020269332, -1092526241, 899848087, -1999879100, 775493399, -1822964540, 1441965991, -58556802, 2051489085, -928226204, -1159242403, 841685273, -426413197, -1063231392, 429425025, -1630449841, -1551901476, 1147544098, 1417554474, 1001099408, 193169544, -1932900794, -953553170, 1809037496, 675025940, -1485185314, -1126015394, 371002123, -1384719397, -616832800, 1683370546, 1951283770, 337512970, -1831122615, 201983494, 1215046692, -1192993700, -1621245246, -1116810285, 1139780780, -995728798, 967348625, 832869781, -751311644, -225740423, -718084121, -1958491960, 1851340599, -625513107, 25988493, -1318791723, -1663938994, 1239460265, -659264404, -1392880042, -217582348, -819598614, -894474907, -191989126, 1206496942, 270010376, 1876277946, -259491720, 1248797989, 1550986798, 941890588, 1475454630, 1942467764, -1756248378, -886839064, -1585652259, -392399756, 1042358047, -1763882165, 1641856445, 226921355, 260409994, -527404944, 2084716094, 1908716981, -861247898, -1864873912, 100991747, -150866186, 470945294, -1029480095, 1784624437, -1359390889, 1775286713, 395413126, -1722236479, 975641885, 666476190, -650583583, -351012616, 733190296, 573772049, -759469719, -1452221991, 126455438, 866620564, 766942107, 1008868894, 361924487, -920589847, -2025206066, -1426107051, 1350051880, -1518673953, 59739276, 1509466529, 159418761, 437718285, 1708834751, -684595482, -2067381694, -793221016, -2101132991, 699439513, 1517759789, 504434447, 2076946608, -1459858348, 1842789307, 742004246};
|
||||||
|
private static final int[] Tinv0 = new int[] {1353184337, 1399144830, -1012656358, -1772214470, -882136261, -247096033, -1420232020, -1828461749, 1442459680, -160598355, -1854485368, 625738485, -52959921, -674551099, -2143013594, -1885117771, 1230680542, 1729870373, -1743852987, -507445667, 41234371, 317738113, -1550367091, -956705941, -413167869, -1784901099, -344298049, -631680363, 763608788, -752782248, 694804553, 1154009486, 1787413109, 2021232372, 1799248025, -579749593, -1236278850, 397248752, 1722556617, -1271214467, 407560035, -2110711067, 1613975959, 1165972322, -529046351, -2068943941, 480281086, -1809118983, 1483229296, 436028815, -2022908268, -1208452270, 601060267, -503166094, 1468997603, 715871590, 120122290, 63092015, -1703164538, -1526188077, -226023376, -1297760477, -1167457534, 1552029421, 723308426, -1833666137, -252573709, -1578997426, -839591323, -708967162, 526529745, -1963022652, -1655493068, -1604979806, 853641733, 1978398372, 971801355, -1427152832, 111112542, 1360031421, -108388034, 1023860118, -1375387939, 1186850381, -1249028975, 90031217, 1876166148, -15380384, 620468249, -1746289194, -868007799, 2006899047, -1119688528, -2004121337, 945494503, -605108103, 1191869601, -384875908, -920746760, 0, -2088337399, 1223502642, -1401941730, 1316117100, -67170563, 1446544655, 517320253, 658058550, 1691946762, 564550760, -783000677, 976107044, -1318647284, 266819475, -761860428, -1634624741, 1338359936, -1574904735, 1766553434, 370807324, 179999714, -450191168, 1138762300, 488053522, 185403662, -1379431438, -1180125651, -928440812, -2061897385, 1275557295, -1143105042, -44007517, -1624899081, -1124765092, -985962940, 880737115, 1982415755, -590994485, 1761406390, 1676797112, -891538985, 277177154, 1076008723, 538035844, 2099530373, -130171950, 288553390, 1839278535, 1261411869, -214912292, -330136051, -790380169, 1813426987, -1715900247, -95906799, 577038663, -997393240, 440397984, -668172970, -275762398, -951170681, -1043253031, -22885748, 906744984, -813566554, 685669029, 646887386, -1530942145, -459458004, 227702864, -1681105046, 1648787028, -1038905866, -390539120, 1593260334, -173030526, -1098883681, 2090061929, -1456614033, -1290656305, 999926984, -1484974064, 1852021992, 2075868123, 158869197, -199730834, 28809964, -1466282109, 1701746150, 2129067946, 147831841, -420997649, -644094022, -835293366, -737566742, -696471511, -1347247055, 824393514, 815048134, -1067015627, 935087732, -1496677636, -1328508704, 366520115, 1251476721, -136647615, 240176511, 804688151, -1915335306, 1303441219, 1414376140, -553347356, -474623586, 461924940, -1205916479, 2136040774, 82468509, 1563790337, 1937016826, 776014843, 1511876531, 1389550482, 861278441, 323475053, -1939744870, 2047648055, -1911228327, -1992551445, -299390514, 902390199, -303751967, 1018251130, 1507840668, 1064563285, 2043548696, -1086863501, -355600557, 1537932639, 342834655, -2032450440, -2114736182, 1053059257, 741614648, 1598071746, 1925389590, 203809468, -1958134744, 1100287487, 1895934009, -558691320, -1662733096, -1866377628, 1636092795, 1890988757, 1952214088, 1113045200};
|
||||||
|
private static final int[] Tinv1 = new int[] { -1477160624, 1698790995, -1541989693, 1579629206, 1806384075, 1167925233, 1492823211, 65227667, -97509291, 1836494326, 1993115793, 1275262245, -672837636, -886389289, 1144333952, -1553812081, 1521606217, 465184103, 250234264, -1057071647, 1966064386, -263421678, -1756983901, -103584826, 1603208167, -1668147819, 2054012907, 1498584538, -2084645843, 561273043, 1776306473, -926314940, -1983744662, 2039411832, 1045993835, 1907959773, 1340194486, -1383534569, -1407137434, 986611124, 1256153880, 823846274, 860985184, 2136171077, 2003087840, -1368671356, -1602093540, 722008468, 1749577816, -45773031, 1826526343, -126135625, -747394269, 38499042, -1893735593, -1420466646, 686535175, -1028313341, 2076542618, 137876389, -2027409166, -1514200142, 1778582202, -2112426660, 483363371, -1267095662, -234359824, -496415071, -187013683, -1106966827, 1647628575, -22625142, 1395537053, 1442030240, -511048398, -336157579, -326956231, -278904662, -1619960314, 275692881, -1977532679, 115185213, 88006062, -1108980410, -1923837515, 1573155077, -737803153, 357589247, -73918172, -373434729, 1128303052, -1629919369, 1122545853, -1953953912, 1528424248, -288851493, 175939911, 256015593, 512030921, 0, -2038429309, -315936184, 1880170156, 1918528590, -15794693, 948244310, -710001378, 959264295, -653325724, -1503893471, 1415289809, 775300154, 1728711857, -413691121, -1762741038, -1852105826, -977239985, 551313826, 1266113129, 437394454, -1164713462, 715178213, -534627261, 387650077, 218697227, -947129683, -1464455751, -1457646392, 435246981, 125153100, -577114437, 1618977789, 637663135, -177054532, 996558021, 2130402100, 692292470, -970732580, -51530136, -236668829, -600713270, -2057092592, 580326208, 298222624, 608863613, 1035719416, 855223825, -1591097491, 798891339, 817028339, 1384517100, -473860144, 380840812, -1183798887, 1217663482, 1693009698, -1929598780, 1072734234, 746411736, -1875696913, 1313441735, -784803391, -1563783938, 198481974, -2114607409, -562387672, -1900553690, -1079165020, -1657131804, -1837608947, -866162021, 1182684258, 328070850, -1193766680, -147247522, -1346141451, -2141347906, -1815058052, 768962473, 304467891, -1716729797, 2098729127, 1671227502, -1153705093, 2015808777, 408514292, -1214583807, -1706064984, 1855317605, -419452290, -809754360, -401215514, -1679312167, 913263310, 161475284, 2091919830, -1297862225, 591342129, -1801075152, 1721906624, -1135709129, -897385306, -795811664, -660131051, -1744506550, -622050825, 1355644686, -158263505, -699566451, -1326496947, 1303039060, 76997855, -1244553501, -2006299621, 523026872, 1365591679, -362898172, 898367837, 1955068531, 1091304238, 493335386, -757362094, 1443948851, 1205234963, 1641519756, 211892090, 351820174, 1007938441, 665439982, -916342987, -451091987, -1320715716, -539845543, 1945261375, -837543815, 935818175, -839429142, -1426235557, 1866325780, -616269690, -206583167, -999769794, 874788908, 1084473951, -1021503886, 635616268, 1228679307, -1794244799, 27801969, -1291056930, -457910116, -1051302768, -2067039391, -1238182544, 1550600308, 1471729730};
|
||||||
|
private static final int[] Tinv2 = new int[] { -195997529, 1098797925, 387629988, 658151006, -1422144661, -1658851003, -89347240, -481586429, 807425530, 1991112301, -863465098, 49620300, -447742761, 717608907, 891715652, 1656065955, -1310832294, -1171953893, -364537842, -27401792, 801309301, 1283527408, 1183687575, -747911431, -1895569569, -1844079204, 1841294202, 1385552473, -1093390973, 1951978273, -532076183, -913423160, -1032492407, -1896580999, 1486449470, -1188569743, -507595185, -1997531219, 550069932, -830622662, -547153846, 451248689, 1368875059, 1398949247, 1689378935, 1807451310, -2114052960, 150574123, 1215322216, 1167006205, -560691348, 2069018616, 1940595667, 1265820162, 534992783, 1432758955, -340654296, -1255210046, -981034373, 936617224, 674296455, -1088179547, 50510442, 384654466, -813028580, 2041025204, 133427442, 1766760930, -630862348, 84334014, 886120290, -1497068802, 775200083, -207445931, -1979370783, -156994069, -2096416276, 1614850799, 1901987487, 1857900816, 557775242, -577356538, 1054715397, -431143235, 1418835341, -999226019, 100954068, 1348534037, -1743182597, -1110009879, 1082772547, -647530594, -391070398, -1995994997, 434583643, -931537938, 2090944266, 1115482383, -2064070370, 0, -2146860154, 724715757, 287222896, 1517047410, 251526143, -2062592456, -1371726123, 758523705, 252339417, 1550328230, 1536938324, 908343854, 168604007, 1469255655, -290139498, -1692688751, -1065332795, -597581280, 2002413899, 303830554, -1813902662, -1597971158, 574374880, 454171927, 151915277, -1947030073, -1238517336, 504678569, -245922535, 1974422535, -1712407587, 2141453664, 33005350, 1918680309, 1715782971, -77908866, 1133213225, 600562886, -306812676, -457677839, 836225756, 1665273989, -1760346078, -964419567, 1250262308, -1143801795, -106032846, 700935585, -1642247377, -1294142672, -2045907886, -1049112349, -1288999914, 1890163129, -1810761144, -381214108, -56048500, -257942977, 2102843436, 857927568, 1233635150, 953795025, -896729438, -728222197, -173617279, 2057644254, -1210440050, -1388337985, 976020637, 2018512274, 1600822220, 2119459398, -1913208301, -661591880, 959340279, -1014827601, 1570750080, -798393197, -714102483, 634368786, -1396163687, 403744637, -1662488989, 1004239803, 650971512, 1500443672, -1695809097, 1334028442, -1780062866, -5603610, -1138685745, 368043752, -407184997, 1867173430, -1612000247, -1339435396, -1540247630, 1059729699, -1513738092, -1573535642, 1316239292, -2097371446, -1864322864, -1489824296, 82922136, -331221030, -847311280, -1860751370, 1299615190, -280801872, -1429449651, -1763385596, -778116171, 1783372680, 750893087, 1699118929, 1587348714, -1946067659, -2013629580, 201010753, 1739807261, -611167534, 283718486, -697494713, -677737375, -1590199796, -128348652, 334203196, -1446056409, 1639396809, 484568549, 1199193265, -761505313, -229294221, 337148366, -948715721, -145495347, -44082262, 1038029935, 1148749531, -1345682957, 1756970692, 607661108, -1547542720, 488010435, -490992603, 1009290057, 234832277, -1472630527, 201907891, -1260872476, 1449431233, -881106556, 852848822, 1816687708, -1194311081};
|
||||||
|
private static final int[] Tinv3 = new int[] {1364240372, 2119394625, 449029143, 982933031, 1003187115, 535905693, -1398056710, 1267925987, 542505520, -1376359050, -2003732788, -182105086, 1341970405, -975713494, 645940277, -1248877726, -565617999, 627514298, 1167593194, 1575076094, -1023249105, -2129465268, -1918658746, 1808202195, 65494927, 362126482, -1075086739, -1780852398, -735214658, 1490231668, 1227450848, -1908094775, 1969916354, -193431154, -1721024936, 668823993, -1095348255, -266883704, -916018144, 2108963534, 1662536415, -444452582, -1755303087, 1648721747, -1310689436, -1148932501, -31678335, -107730168, 1884842056, -1894122171, -1803064098, 1387788411, -1423715469, 1927414347, -480800993, 1714072405, -1308153621, 788775605, -2036696123, -744159177, 821200680, 598910399, 45771267, -312704490, -1976886065, -1483557767, -202313209, 1319232105, 1707996378, 114671109, -786472396, -997523802, 882725678, -1566550541, 87220618, -1535775754, 188345475, 1084944224, 1577492337, -1118760850, 1056541217, -1774385443, -575797954, 1296481766, -1850372780, 1896177092, 74437638, 1627329872, 421854104, -694687299, -1983102144, 1735892697, -1329773848, 126389129, -415737063, 2044456648, -1589179780, 2095648578, -121037180, 0, 159614592, 843640107, 514617361, 1817080410, -33816818, 257308805, 1025430958, 908540205, 174381327, 1747035740, -1680780197, 607792694, 212952842, -1827674281, -1261267218, 463376795, -2142255680, 1638015196, 1516850039, 471210514, -502613357, -1058723168, 1011081250, 303896347, 235605257, -223492213, 767142070, 348694814, 1468340721, -1353971851, -289677927, -1543675777, -140564991, 1555887474, 1153776486, 1530167035, -1955190461, -874723805, -1234633491, -1201409564, -674571215, 1108378979, 322970263, -2078273082, -2055396278, -755483205, -1374604551, -949116631, 491466654, -588042062, 233591430, 2010178497, 728503987, -1449543312, 301615252, 1193436393, -1463513860, -1608892432, 1457007741, 586125363, -2016981431, -641609416, -1929469238, -1741288492, -1496350219, -1524048262, -635007305, 1067761581, 753179962, 1343066744, 1788595295, 1415726718, -155053171, -1863796520, 777975609, -2097827901, -1614905251, 1769771984, 1873358293, -810347995, -935618132, 279411992, -395418724, -612648133, -855017434, 1861490777, -335431782, -2086102449, -429560171, -1434523905, 554225596, -270079979, -1160143897, 1255028335, -355202657, 701922480, 833598116, 707863359, -969894747, 901801634, 1949809742, -56178046, -525283184, 857069735, -246769660, 1106762476, 2131644621, 389019281, 1989006925, 1129165039, -866890326, -455146346, -1629243951, 1276872810, -1044898004, 1182749029, -1660622242, 22885772, -93096825, -80854773, -1285939865, -1840065829, -382511600, 1829980118, -1702075945, 930745505, 1502483704, -343327725, -823253079, -1221211807, -504503012, 2050797895, -1671831598, 1430221810, 410635796, 1941911495, 1407897079, 1599843069, -552308931, 2022103876, -897453137, -1187068824, 942421028, -1033944925, 376619805, -1140054558, 680216892, -12479219, 963707304, 148812556, -660806476, 1687208278, 2069988555, -714033614, 1215585388, -800958536};
|
||||||
|
private int ROUNDS;
|
||||||
|
private int[][] WorkingKey = (int[][])null;
|
||||||
|
private int C0;
|
||||||
|
private int C1;
|
||||||
|
private int C2;
|
||||||
|
private int C3;
|
||||||
|
private boolean forEncryption;
|
||||||
|
|
||||||
|
private int shift(int par1, int par2)
|
||||||
|
{
|
||||||
|
return par1 >>> par2 | par1 << -par2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int FFmulX(int par1)
|
||||||
|
{
|
||||||
|
return (par1 & 2139062143) << 1 ^ ((par1 & -2139062144) >>> 7) * 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int inv_mcol(int par1)
|
||||||
|
{
|
||||||
|
int var2 = this.FFmulX(par1);
|
||||||
|
int var3 = this.FFmulX(var2);
|
||||||
|
int var4 = this.FFmulX(var3);
|
||||||
|
int var5 = par1 ^ var4;
|
||||||
|
return var2 ^ var3 ^ var4 ^ this.shift(var2 ^ var5, 8) ^ this.shift(var3 ^ var5, 16) ^ this.shift(var5, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int subWord(int par1)
|
||||||
|
{
|
||||||
|
return S[par1 & 255] & 255 | (S[par1 >> 8 & 255] & 255) << 8 | (S[par1 >> 16 & 255] & 255) << 16 | S[par1 >> 24 & 255] << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[][] generateWorkingKey(byte[] par1ArrayOfByte, boolean par2)
|
||||||
|
{
|
||||||
|
int var3 = par1ArrayOfByte.length / 4;
|
||||||
|
|
||||||
|
if ((var3 == 4 || var3 == 6 || var3 == 8) && var3 * 4 == par1ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
this.ROUNDS = var3 + 6;
|
||||||
|
int[][] var5 = new int[this.ROUNDS + 1][4];
|
||||||
|
int var4 = 0;
|
||||||
|
int var6;
|
||||||
|
|
||||||
|
for (var6 = 0; var6 < par1ArrayOfByte.length; ++var4)
|
||||||
|
{
|
||||||
|
var5[var4 >> 2][var4 & 3] = par1ArrayOfByte[var6] & 255 | (par1ArrayOfByte[var6 + 1] & 255) << 8 | (par1ArrayOfByte[var6 + 2] & 255) << 16 | par1ArrayOfByte[var6 + 3] << 24;
|
||||||
|
var6 += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
int var7 = this.ROUNDS + 1 << 2;
|
||||||
|
int var8;
|
||||||
|
|
||||||
|
for (var6 = var3; var6 < var7; ++var6)
|
||||||
|
{
|
||||||
|
var8 = var5[var6 - 1 >> 2][var6 - 1 & 3];
|
||||||
|
|
||||||
|
if (var6 % var3 == 0)
|
||||||
|
{
|
||||||
|
var8 = this.subWord(this.shift(var8, 8)) ^ rcon[var6 / var3 - 1];
|
||||||
|
}
|
||||||
|
else if (var3 > 6 && var6 % var3 == 4)
|
||||||
|
{
|
||||||
|
var8 = this.subWord(var8);
|
||||||
|
}
|
||||||
|
|
||||||
|
var5[var6 >> 2][var6 & 3] = var5[var6 - var3 >> 2][var6 - var3 & 3] ^ var8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!par2)
|
||||||
|
{
|
||||||
|
for (var8 = 1; var8 < this.ROUNDS; ++var8)
|
||||||
|
{
|
||||||
|
for (var6 = 0; var6 < 4; ++var6)
|
||||||
|
{
|
||||||
|
var5[var8][var6] = this.inv_mcol(var5[var8][var6]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return var5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Key length not 128/192/256 bits.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(boolean par1, CipherParameters par2CipherParameters) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
if (par2CipherParameters instanceof KeyParameter)
|
||||||
|
{
|
||||||
|
this.WorkingKey = this.generateWorkingKey(((KeyParameter)par2CipherParameters).getKey(), par1);
|
||||||
|
this.forEncryption = par1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("invalid parameter passed to AES init - " + par2CipherParameters.getClass().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the algorithm the cipher implements.
|
||||||
|
*/
|
||||||
|
public String getAlgorithmName()
|
||||||
|
{
|
||||||
|
return "AES";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the block size for this cipher (in bytes).
|
||||||
|
*/
|
||||||
|
public int getBlockSize()
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int processBlock(byte[] par1ArrayOfByte, int par2, byte[] par3ArrayOfByte, int par4) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
if (this.WorkingKey == null)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("AES engine not initialised");
|
||||||
|
}
|
||||||
|
else if (par2 + 16 > par1ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("input buffer too short");
|
||||||
|
}
|
||||||
|
else if (par4 + 16 > par3ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("output buffer too short");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.forEncryption)
|
||||||
|
{
|
||||||
|
this.unpackBlock(par1ArrayOfByte, par2);
|
||||||
|
this.encryptBlock(this.WorkingKey);
|
||||||
|
this.packBlock(par3ArrayOfByte, par4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.unpackBlock(par1ArrayOfByte, par2);
|
||||||
|
this.decryptBlock(this.WorkingKey);
|
||||||
|
this.packBlock(par3ArrayOfByte, par4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {}
|
||||||
|
|
||||||
|
private void unpackBlock(byte[] par1ArrayOfByte, int par2)
|
||||||
|
{
|
||||||
|
int var3 = par2 + 1;
|
||||||
|
this.C0 = par1ArrayOfByte[par2] & 255;
|
||||||
|
this.C0 |= (par1ArrayOfByte[var3++] & 255) << 8;
|
||||||
|
this.C0 |= (par1ArrayOfByte[var3++] & 255) << 16;
|
||||||
|
this.C0 |= par1ArrayOfByte[var3++] << 24;
|
||||||
|
this.C1 = par1ArrayOfByte[var3++] & 255;
|
||||||
|
this.C1 |= (par1ArrayOfByte[var3++] & 255) << 8;
|
||||||
|
this.C1 |= (par1ArrayOfByte[var3++] & 255) << 16;
|
||||||
|
this.C1 |= par1ArrayOfByte[var3++] << 24;
|
||||||
|
this.C2 = par1ArrayOfByte[var3++] & 255;
|
||||||
|
this.C2 |= (par1ArrayOfByte[var3++] & 255) << 8;
|
||||||
|
this.C2 |= (par1ArrayOfByte[var3++] & 255) << 16;
|
||||||
|
this.C2 |= par1ArrayOfByte[var3++] << 24;
|
||||||
|
this.C3 = par1ArrayOfByte[var3++] & 255;
|
||||||
|
this.C3 |= (par1ArrayOfByte[var3++] & 255) << 8;
|
||||||
|
this.C3 |= (par1ArrayOfByte[var3++] & 255) << 16;
|
||||||
|
this.C3 |= par1ArrayOfByte[var3++] << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void packBlock(byte[] par1ArrayOfByte, int par2)
|
||||||
|
{
|
||||||
|
int var3 = par2 + 1;
|
||||||
|
par1ArrayOfByte[par2] = (byte)this.C0;
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C0 >> 8);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C0 >> 16);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C0 >> 24);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)this.C1;
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C1 >> 8);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C1 >> 16);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C1 >> 24);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)this.C2;
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C2 >> 8);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C2 >> 16);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C2 >> 24);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)this.C3;
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C3 >> 8);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C3 >> 16);
|
||||||
|
par1ArrayOfByte[var3++] = (byte)(this.C3 >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void encryptBlock(int[][] par1ArrayOfInteger)
|
||||||
|
{
|
||||||
|
this.C0 ^= par1ArrayOfInteger[0][0];
|
||||||
|
this.C1 ^= par1ArrayOfInteger[0][1];
|
||||||
|
this.C2 ^= par1ArrayOfInteger[0][2];
|
||||||
|
this.C3 ^= par1ArrayOfInteger[0][3];
|
||||||
|
int var2;
|
||||||
|
int var3;
|
||||||
|
int var4;
|
||||||
|
int var5;
|
||||||
|
int var6;
|
||||||
|
|
||||||
|
for (var2 = 1; var2 < this.ROUNDS - 1; this.C3 = T0[var6 & 255] ^ T1[var3 >> 8 & 255] ^ T2[var4 >> 16 & 255] ^ T3[var5 >> 24 & 255] ^ par1ArrayOfInteger[var2++][3])
|
||||||
|
{
|
||||||
|
var3 = T0[this.C0 & 255] ^ T1[this.C1 >> 8 & 255] ^ T2[this.C2 >> 16 & 255] ^ T3[this.C3 >> 24 & 255] ^ par1ArrayOfInteger[var2][0];
|
||||||
|
var4 = T0[this.C1 & 255] ^ T1[this.C2 >> 8 & 255] ^ T2[this.C3 >> 16 & 255] ^ T3[this.C0 >> 24 & 255] ^ par1ArrayOfInteger[var2][1];
|
||||||
|
var5 = T0[this.C2 & 255] ^ T1[this.C3 >> 8 & 255] ^ T2[this.C0 >> 16 & 255] ^ T3[this.C1 >> 24 & 255] ^ par1ArrayOfInteger[var2][2];
|
||||||
|
var6 = T0[this.C3 & 255] ^ T1[this.C0 >> 8 & 255] ^ T2[this.C1 >> 16 & 255] ^ T3[this.C2 >> 24 & 255] ^ par1ArrayOfInteger[var2++][3];
|
||||||
|
this.C0 = T0[var3 & 255] ^ T1[var4 >> 8 & 255] ^ T2[var5 >> 16 & 255] ^ T3[var6 >> 24 & 255] ^ par1ArrayOfInteger[var2][0];
|
||||||
|
this.C1 = T0[var4 & 255] ^ T1[var5 >> 8 & 255] ^ T2[var6 >> 16 & 255] ^ T3[var3 >> 24 & 255] ^ par1ArrayOfInteger[var2][1];
|
||||||
|
this.C2 = T0[var5 & 255] ^ T1[var6 >> 8 & 255] ^ T2[var3 >> 16 & 255] ^ T3[var4 >> 24 & 255] ^ par1ArrayOfInteger[var2][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
var3 = T0[this.C0 & 255] ^ T1[this.C1 >> 8 & 255] ^ T2[this.C2 >> 16 & 255] ^ T3[this.C3 >> 24 & 255] ^ par1ArrayOfInteger[var2][0];
|
||||||
|
var4 = T0[this.C1 & 255] ^ T1[this.C2 >> 8 & 255] ^ T2[this.C3 >> 16 & 255] ^ T3[this.C0 >> 24 & 255] ^ par1ArrayOfInteger[var2][1];
|
||||||
|
var5 = T0[this.C2 & 255] ^ T1[this.C3 >> 8 & 255] ^ T2[this.C0 >> 16 & 255] ^ T3[this.C1 >> 24 & 255] ^ par1ArrayOfInteger[var2][2];
|
||||||
|
var6 = T0[this.C3 & 255] ^ T1[this.C0 >> 8 & 255] ^ T2[this.C1 >> 16 & 255] ^ T3[this.C2 >> 24 & 255] ^ par1ArrayOfInteger[var2++][3];
|
||||||
|
this.C0 = S[var3 & 255] & 255 ^ (S[var4 >> 8 & 255] & 255) << 8 ^ (S[var5 >> 16 & 255] & 255) << 16 ^ S[var6 >> 24 & 255] << 24 ^ par1ArrayOfInteger[var2][0];
|
||||||
|
this.C1 = S[var4 & 255] & 255 ^ (S[var5 >> 8 & 255] & 255) << 8 ^ (S[var6 >> 16 & 255] & 255) << 16 ^ S[var3 >> 24 & 255] << 24 ^ par1ArrayOfInteger[var2][1];
|
||||||
|
this.C2 = S[var5 & 255] & 255 ^ (S[var6 >> 8 & 255] & 255) << 8 ^ (S[var3 >> 16 & 255] & 255) << 16 ^ S[var4 >> 24 & 255] << 24 ^ par1ArrayOfInteger[var2][2];
|
||||||
|
this.C3 = S[var6 & 255] & 255 ^ (S[var3 >> 8 & 255] & 255) << 8 ^ (S[var4 >> 16 & 255] & 255) << 16 ^ S[var5 >> 24 & 255] << 24 ^ par1ArrayOfInteger[var2][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decryptBlock(int[][] par1ArrayOfInteger)
|
||||||
|
{
|
||||||
|
this.C0 ^= par1ArrayOfInteger[this.ROUNDS][0];
|
||||||
|
this.C1 ^= par1ArrayOfInteger[this.ROUNDS][1];
|
||||||
|
this.C2 ^= par1ArrayOfInteger[this.ROUNDS][2];
|
||||||
|
this.C3 ^= par1ArrayOfInteger[this.ROUNDS][3];
|
||||||
|
int var2;
|
||||||
|
int var3;
|
||||||
|
int var4;
|
||||||
|
int var5;
|
||||||
|
int var6;
|
||||||
|
|
||||||
|
for (var6 = this.ROUNDS - 1; var6 > 1; this.C3 = Tinv0[var5 & 255] ^ Tinv1[var4 >> 8 & 255] ^ Tinv2[var3 >> 16 & 255] ^ Tinv3[var2 >> 24 & 255] ^ par1ArrayOfInteger[var6--][3])
|
||||||
|
{
|
||||||
|
var2 = Tinv0[this.C0 & 255] ^ Tinv1[this.C3 >> 8 & 255] ^ Tinv2[this.C2 >> 16 & 255] ^ Tinv3[this.C1 >> 24 & 255] ^ par1ArrayOfInteger[var6][0];
|
||||||
|
var3 = Tinv0[this.C1 & 255] ^ Tinv1[this.C0 >> 8 & 255] ^ Tinv2[this.C3 >> 16 & 255] ^ Tinv3[this.C2 >> 24 & 255] ^ par1ArrayOfInteger[var6][1];
|
||||||
|
var4 = Tinv0[this.C2 & 255] ^ Tinv1[this.C1 >> 8 & 255] ^ Tinv2[this.C0 >> 16 & 255] ^ Tinv3[this.C3 >> 24 & 255] ^ par1ArrayOfInteger[var6][2];
|
||||||
|
var5 = Tinv0[this.C3 & 255] ^ Tinv1[this.C2 >> 8 & 255] ^ Tinv2[this.C1 >> 16 & 255] ^ Tinv3[this.C0 >> 24 & 255] ^ par1ArrayOfInteger[var6--][3];
|
||||||
|
this.C0 = Tinv0[var2 & 255] ^ Tinv1[var5 >> 8 & 255] ^ Tinv2[var4 >> 16 & 255] ^ Tinv3[var3 >> 24 & 255] ^ par1ArrayOfInteger[var6][0];
|
||||||
|
this.C1 = Tinv0[var3 & 255] ^ Tinv1[var2 >> 8 & 255] ^ Tinv2[var5 >> 16 & 255] ^ Tinv3[var4 >> 24 & 255] ^ par1ArrayOfInteger[var6][1];
|
||||||
|
this.C2 = Tinv0[var4 & 255] ^ Tinv1[var3 >> 8 & 255] ^ Tinv2[var2 >> 16 & 255] ^ Tinv3[var5 >> 24 & 255] ^ par1ArrayOfInteger[var6][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
var2 = Tinv0[this.C0 & 255] ^ Tinv1[this.C3 >> 8 & 255] ^ Tinv2[this.C2 >> 16 & 255] ^ Tinv3[this.C1 >> 24 & 255] ^ par1ArrayOfInteger[var6][0];
|
||||||
|
var3 = Tinv0[this.C1 & 255] ^ Tinv1[this.C0 >> 8 & 255] ^ Tinv2[this.C3 >> 16 & 255] ^ Tinv3[this.C2 >> 24 & 255] ^ par1ArrayOfInteger[var6][1];
|
||||||
|
var4 = Tinv0[this.C2 & 255] ^ Tinv1[this.C1 >> 8 & 255] ^ Tinv2[this.C0 >> 16 & 255] ^ Tinv3[this.C3 >> 24 & 255] ^ par1ArrayOfInteger[var6][2];
|
||||||
|
var5 = Tinv0[this.C3 & 255] ^ Tinv1[this.C2 >> 8 & 255] ^ Tinv2[this.C1 >> 16 & 255] ^ Tinv3[this.C0 >> 24 & 255] ^ par1ArrayOfInteger[var6][3];
|
||||||
|
this.C0 = Si[var2 & 255] & 255 ^ (Si[var5 >> 8 & 255] & 255) << 8 ^ (Si[var4 >> 16 & 255] & 255) << 16 ^ Si[var3 >> 24 & 255] << 24 ^ par1ArrayOfInteger[0][0];
|
||||||
|
this.C1 = Si[var3 & 255] & 255 ^ (Si[var2 >> 8 & 255] & 255) << 8 ^ (Si[var5 >> 16 & 255] & 255) << 16 ^ Si[var4 >> 24 & 255] << 24 ^ par1ArrayOfInteger[0][1];
|
||||||
|
this.C2 = Si[var4 & 255] & 255 ^ (Si[var3 >> 8 & 255] & 255) << 8 ^ (Si[var2 >> 16 & 255] & 255) << 16 ^ Si[var5 >> 24 & 255] << 24 ^ par1ArrayOfInteger[0][2];
|
||||||
|
this.C3 = Si[var5 & 255] & 255 ^ (Si[var4 >> 8 & 255] & 255) << 8 ^ (Si[var3 >> 16 & 255] & 255) << 16 ^ Si[var2 >> 24 & 255] << 24 ^ par1ArrayOfInteger[0][3];
|
||||||
|
}
|
||||||
|
}
|
178
src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java
Normal file
178
src/main/java/org/bouncycastle/crypto/io/CipherInputStream.java
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
package org.bouncycastle.crypto.io;
|
||||||
|
|
||||||
|
import java.io.FilterInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import org.bouncycastle.crypto.BufferedBlockCipher;
|
||||||
|
import org.bouncycastle.crypto.StreamCipher;
|
||||||
|
|
||||||
|
public class CipherInputStream extends FilterInputStream
|
||||||
|
{
|
||||||
|
private BufferedBlockCipher theBufferedBlockCipher;
|
||||||
|
private StreamCipher theStreamCipher;
|
||||||
|
private byte[] buf;
|
||||||
|
private byte[] inBuf;
|
||||||
|
private int bufOff;
|
||||||
|
private int maxBuf;
|
||||||
|
private boolean finalized;
|
||||||
|
|
||||||
|
public CipherInputStream(InputStream par1InputStream, BufferedBlockCipher par2BufferedBlockCipher)
|
||||||
|
{
|
||||||
|
super(par1InputStream);
|
||||||
|
this.theBufferedBlockCipher = par2BufferedBlockCipher;
|
||||||
|
this.buf = new byte[par2BufferedBlockCipher.getOutputSize(2048)];
|
||||||
|
this.inBuf = new byte[2048];
|
||||||
|
}
|
||||||
|
|
||||||
|
private int nextChunk() throws IOException
|
||||||
|
{
|
||||||
|
int var1 = super.available();
|
||||||
|
|
||||||
|
if (var1 <= 0)
|
||||||
|
{
|
||||||
|
var1 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var1 > this.inBuf.length)
|
||||||
|
{
|
||||||
|
var1 = super.read(this.inBuf, 0, this.inBuf.length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var1 = super.read(this.inBuf, 0, var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var1 < 0)
|
||||||
|
{
|
||||||
|
if (this.finalized)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (this.theBufferedBlockCipher != null)
|
||||||
|
{
|
||||||
|
this.maxBuf = this.theBufferedBlockCipher.doFinal(this.buf, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.maxBuf = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception var4)
|
||||||
|
{
|
||||||
|
throw new IOException("error processing stream: " + var4.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bufOff = 0;
|
||||||
|
this.finalized = true;
|
||||||
|
|
||||||
|
if (this.bufOff == this.maxBuf)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.bufOff = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (this.theBufferedBlockCipher != null)
|
||||||
|
{
|
||||||
|
this.maxBuf = this.theBufferedBlockCipher.processByte(this.inBuf, 0, var1, this.buf, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.theStreamCipher.processBytes(this.inBuf, 0, var1, this.buf, 0);
|
||||||
|
this.maxBuf = var1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception var3)
|
||||||
|
{
|
||||||
|
throw new IOException("error processing stream: " + var3.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.maxBuf == 0)
|
||||||
|
{
|
||||||
|
return this.nextChunk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.maxBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read() throws IOException
|
||||||
|
{
|
||||||
|
return this.bufOff == this.maxBuf && this.nextChunk() < 0 ? -1 : this.buf[this.bufOff++] & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read(byte[] par1ArrayOfByte) throws IOException
|
||||||
|
{
|
||||||
|
return this.read(par1ArrayOfByte, 0, par1ArrayOfByte.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read(byte[] par1ArrayOfByte, int par2, int par3) throws IOException
|
||||||
|
{
|
||||||
|
if (this.bufOff == this.maxBuf && this.nextChunk() < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int var4 = this.maxBuf - this.bufOff;
|
||||||
|
|
||||||
|
if (par3 > var4)
|
||||||
|
{
|
||||||
|
System.arraycopy(this.buf, this.bufOff, par1ArrayOfByte, par2, var4);
|
||||||
|
this.bufOff = this.maxBuf;
|
||||||
|
return var4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.arraycopy(this.buf, this.bufOff, par1ArrayOfByte, par2, par3);
|
||||||
|
this.bufOff += par3;
|
||||||
|
return par3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long skip(long par1) throws IOException
|
||||||
|
{
|
||||||
|
if (par1 <= 0L)
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int var3 = this.maxBuf - this.bufOff;
|
||||||
|
|
||||||
|
if (par1 > (long)var3)
|
||||||
|
{
|
||||||
|
this.bufOff = this.maxBuf;
|
||||||
|
return (long)var3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.bufOff += (int)par1;
|
||||||
|
return (long)((int)par1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int available() throws IOException
|
||||||
|
{
|
||||||
|
return this.maxBuf - this.bufOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean markSupported()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package org.bouncycastle.crypto.io;
|
||||||
|
|
||||||
|
import java.io.FilterOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import org.bouncycastle.crypto.BufferedBlockCipher;
|
||||||
|
import org.bouncycastle.crypto.StreamCipher;
|
||||||
|
|
||||||
|
public class CipherOutputStream extends FilterOutputStream
|
||||||
|
{
|
||||||
|
private BufferedBlockCipher theBufferedBlockCipher;
|
||||||
|
private StreamCipher theStreamCipher;
|
||||||
|
private byte[] oneByte = new byte[1];
|
||||||
|
private byte[] buf;
|
||||||
|
|
||||||
|
public CipherOutputStream(OutputStream par1OutputStream, BufferedBlockCipher par2BufferedBlockCipher)
|
||||||
|
{
|
||||||
|
super(par1OutputStream);
|
||||||
|
this.theBufferedBlockCipher = par2BufferedBlockCipher;
|
||||||
|
this.buf = new byte[par2BufferedBlockCipher.getBlockSize()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(int par1) throws IOException
|
||||||
|
{
|
||||||
|
this.oneByte[0] = (byte)par1;
|
||||||
|
|
||||||
|
if (this.theBufferedBlockCipher != null)
|
||||||
|
{
|
||||||
|
int var2 = this.theBufferedBlockCipher.processByte(this.oneByte, 0, 1, this.buf, 0);
|
||||||
|
|
||||||
|
if (var2 != 0)
|
||||||
|
{
|
||||||
|
this.out.write(this.buf, 0, var2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.out.write(this.theStreamCipher.returnByte((byte)par1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] par1) throws IOException
|
||||||
|
{
|
||||||
|
this.write(par1, 0, par1.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] par1, int par2, int par3) throws IOException
|
||||||
|
{
|
||||||
|
byte[] var4;
|
||||||
|
|
||||||
|
if (this.theBufferedBlockCipher != null)
|
||||||
|
{
|
||||||
|
var4 = new byte[this.theBufferedBlockCipher.getOutputSize(par3)];
|
||||||
|
int var5 = this.theBufferedBlockCipher.processByte(par1, par2, par3, var4, 0);
|
||||||
|
|
||||||
|
if (var5 != 0)
|
||||||
|
{
|
||||||
|
this.out.write(var4, 0, var5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var4 = new byte[par3];
|
||||||
|
this.theStreamCipher.processBytes(par1, par2, par3, var4, 0);
|
||||||
|
this.out.write(var4, 0, par3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flush() throws IOException
|
||||||
|
{
|
||||||
|
super.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (this.theBufferedBlockCipher != null)
|
||||||
|
{
|
||||||
|
byte[] var1 = new byte[this.theBufferedBlockCipher.getOutputSize(0)];
|
||||||
|
int var2 = this.theBufferedBlockCipher.doFinal(var1, 0);
|
||||||
|
|
||||||
|
if (var2 != 0)
|
||||||
|
{
|
||||||
|
this.out.write(var1, 0, var2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception var3)
|
||||||
|
{
|
||||||
|
throw new IOException("Error closing stream: " + var3.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.flush();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
}
|
139
src/main/java/org/bouncycastle/crypto/modes/CFBBlockCipher.java
Normal file
139
src/main/java/org/bouncycastle/crypto/modes/CFBBlockCipher.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package org.bouncycastle.crypto.modes;
|
||||||
|
|
||||||
|
import org.bouncycastle.crypto.BlockCipher;
|
||||||
|
import org.bouncycastle.crypto.CipherParameters;
|
||||||
|
import org.bouncycastle.crypto.DataLengthException;
|
||||||
|
import org.bouncycastle.crypto.params.ParametersWithIV;
|
||||||
|
|
||||||
|
public class CFBBlockCipher implements BlockCipher
|
||||||
|
{
|
||||||
|
private byte[] IV;
|
||||||
|
private byte[] cfbV;
|
||||||
|
private byte[] cfbOutV;
|
||||||
|
private int blockSize;
|
||||||
|
private BlockCipher cipher = null;
|
||||||
|
private boolean encrypting;
|
||||||
|
|
||||||
|
public CFBBlockCipher(BlockCipher par1BlockCipher, int par2)
|
||||||
|
{
|
||||||
|
this.cipher = par1BlockCipher;
|
||||||
|
this.blockSize = par2 / 8;
|
||||||
|
this.IV = new byte[par1BlockCipher.getBlockSize()];
|
||||||
|
this.cfbV = new byte[par1BlockCipher.getBlockSize()];
|
||||||
|
this.cfbOutV = new byte[par1BlockCipher.getBlockSize()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(boolean par1, CipherParameters par2CipherParameters) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
this.encrypting = par1;
|
||||||
|
|
||||||
|
if (par2CipherParameters instanceof ParametersWithIV)
|
||||||
|
{
|
||||||
|
ParametersWithIV var3 = (ParametersWithIV)par2CipherParameters;
|
||||||
|
byte[] var4 = var3.getIV();
|
||||||
|
|
||||||
|
if (var4.length < this.IV.length)
|
||||||
|
{
|
||||||
|
System.arraycopy(var4, 0, this.IV, this.IV.length - var4.length, var4.length);
|
||||||
|
|
||||||
|
for (int var5 = 0; var5 < this.IV.length - var4.length; ++var5)
|
||||||
|
{
|
||||||
|
this.IV[var5] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.arraycopy(var4, 0, this.IV, 0, this.IV.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reset();
|
||||||
|
|
||||||
|
if (var3.getParameters() != null)
|
||||||
|
{
|
||||||
|
this.cipher.init(true, var3.getParameters());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.reset();
|
||||||
|
this.cipher.init(true, par2CipherParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the algorithm the cipher implements.
|
||||||
|
*/
|
||||||
|
public String getAlgorithmName()
|
||||||
|
{
|
||||||
|
return this.cipher.getAlgorithmName() + "/CFB" + this.blockSize * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the block size for this cipher (in bytes).
|
||||||
|
*/
|
||||||
|
public int getBlockSize()
|
||||||
|
{
|
||||||
|
return this.blockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int processBlock(byte[] par1ArrayOfByte, int par2, byte[] par3ArrayOfByte, int par4) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
return this.encrypting ? this.encryptBlock(par1ArrayOfByte, par2, par3ArrayOfByte, par4) : this.decryptBlock(par1ArrayOfByte, par2, par3ArrayOfByte, par4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int encryptBlock(byte[] par1ArrayOfByte, int par2, byte[] par3ArrayOfByte, int par4) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
if (par2 + this.blockSize > par1ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("input buffer too short");
|
||||||
|
}
|
||||||
|
else if (par4 + this.blockSize > par3ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("output buffer too short");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.cipher.processBlock(this.cfbV, 0, this.cfbOutV, 0);
|
||||||
|
|
||||||
|
for (int var5 = 0; var5 < this.blockSize; ++var5)
|
||||||
|
{
|
||||||
|
par3ArrayOfByte[par4 + var5] = (byte)(this.cfbOutV[var5] ^ par1ArrayOfByte[par2 + var5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.arraycopy(this.cfbV, this.blockSize, this.cfbV, 0, this.cfbV.length - this.blockSize);
|
||||||
|
System.arraycopy(par3ArrayOfByte, par4, this.cfbV, this.cfbV.length - this.blockSize, this.blockSize);
|
||||||
|
return this.blockSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int decryptBlock(byte[] par1ArrayOfByte, int par2, byte[] par3ArrayOfByte, int par4) throws DataLengthException, IllegalStateException
|
||||||
|
{
|
||||||
|
if (par2 + this.blockSize > par1ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("input buffer too short");
|
||||||
|
}
|
||||||
|
else if (par4 + this.blockSize > par3ArrayOfByte.length)
|
||||||
|
{
|
||||||
|
throw new DataLengthException("output buffer too short");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.cipher.processBlock(this.cfbV, 0, this.cfbOutV, 0);
|
||||||
|
System.arraycopy(this.cfbV, this.blockSize, this.cfbV, 0, this.cfbV.length - this.blockSize);
|
||||||
|
System.arraycopy(par1ArrayOfByte, par2, this.cfbV, this.cfbV.length - this.blockSize, this.blockSize);
|
||||||
|
|
||||||
|
for (int var5 = 0; var5 < this.blockSize; ++var5)
|
||||||
|
{
|
||||||
|
par3ArrayOfByte[par4 + var5] = (byte)(this.cfbOutV[var5] ^ par1ArrayOfByte[par2 + var5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.blockSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
System.arraycopy(this.IV, 0, this.cfbV, 0, this.IV.length);
|
||||||
|
this.cipher.reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.bouncycastle.crypto.params;
|
||||||
|
|
||||||
|
import org.bouncycastle.crypto.CipherParameters;
|
||||||
|
|
||||||
|
public class KeyParameter implements CipherParameters
|
||||||
|
{
|
||||||
|
private byte[] key;
|
||||||
|
|
||||||
|
public KeyParameter(byte[] par1ArrayOfByte)
|
||||||
|
{
|
||||||
|
this(par1ArrayOfByte, 0, par1ArrayOfByte.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyParameter(byte[] par1ArrayOfByte, int par2, int par3)
|
||||||
|
{
|
||||||
|
this.key = new byte[par3];
|
||||||
|
System.arraycopy(par1ArrayOfByte, par2, this.key, 0, par3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getKey()
|
||||||
|
{
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.bouncycastle.crypto.params;
|
||||||
|
|
||||||
|
import org.bouncycastle.crypto.CipherParameters;
|
||||||
|
|
||||||
|
public class ParametersWithIV implements CipherParameters
|
||||||
|
{
|
||||||
|
private byte[] iv;
|
||||||
|
private CipherParameters parameters;
|
||||||
|
|
||||||
|
public ParametersWithIV(CipherParameters par1CipherParameters, byte[] par2ArrayOfByte, int par3, int par4)
|
||||||
|
{
|
||||||
|
this.iv = new byte[par4];
|
||||||
|
this.parameters = par1CipherParameters;
|
||||||
|
System.arraycopy(par2ArrayOfByte, par3, this.iv, 0, par4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getIV()
|
||||||
|
{
|
||||||
|
return this.iv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CipherParameters getParameters()
|
||||||
|
{
|
||||||
|
return this.parameters;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bouncycastle.jcajce.provider.config;
|
||||||
|
|
||||||
|
public interface ConfigurableProvider
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bouncycastle.jcajce.provider.config;
|
||||||
|
|
||||||
|
public interface ProviderConfiguration
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
package org.bouncycastle.jcajce.provider.config;
|
||||||
|
|
||||||
|
import java.security.BasicPermission;
|
||||||
|
import java.security.Permission;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import org.bouncycastle.util.Strings;
|
||||||
|
|
||||||
|
public class ProviderConfigurationPermission extends BasicPermission
|
||||||
|
{
|
||||||
|
private final String actions;
|
||||||
|
private final int permissionMask;
|
||||||
|
|
||||||
|
public ProviderConfigurationPermission(String par1Str)
|
||||||
|
{
|
||||||
|
super(par1Str);
|
||||||
|
this.actions = "all";
|
||||||
|
this.permissionMask = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProviderConfigurationPermission(String par1Str, String par2Str)
|
||||||
|
{
|
||||||
|
super(par1Str, par2Str);
|
||||||
|
this.actions = par2Str;
|
||||||
|
this.permissionMask = this.calculateMask(par2Str);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int calculateMask(String par1Str)
|
||||||
|
{
|
||||||
|
StringTokenizer var2 = new StringTokenizer(Strings.toLowerCase(par1Str), " ,");
|
||||||
|
int var3 = 0;
|
||||||
|
|
||||||
|
while (var2.hasMoreTokens())
|
||||||
|
{
|
||||||
|
String var4 = var2.nextToken();
|
||||||
|
|
||||||
|
if (var4.equals("threadlocalecimplicitlyca"))
|
||||||
|
{
|
||||||
|
var3 |= 1;
|
||||||
|
}
|
||||||
|
else if (var4.equals("ecimplicitlyca"))
|
||||||
|
{
|
||||||
|
var3 |= 2;
|
||||||
|
}
|
||||||
|
else if (var4.equals("threadlocaldhdefaultparams"))
|
||||||
|
{
|
||||||
|
var3 |= 4;
|
||||||
|
}
|
||||||
|
else if (var4.equals("dhdefaultparams"))
|
||||||
|
{
|
||||||
|
var3 |= 8;
|
||||||
|
}
|
||||||
|
else if (var4.equals("all"))
|
||||||
|
{
|
||||||
|
var3 |= 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var3 == 0)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("unknown permissions passed to mask");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return var3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActions()
|
||||||
|
{
|
||||||
|
return this.actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean implies(Permission par1Permission)
|
||||||
|
{
|
||||||
|
if (!(par1Permission instanceof ProviderConfigurationPermission))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!this.getName().equals(par1Permission.getName()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ProviderConfigurationPermission var2 = (ProviderConfigurationPermission)par1Permission;
|
||||||
|
return (this.permissionMask & var2.permissionMask) == var2.permissionMask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object par1Obj)
|
||||||
|
{
|
||||||
|
if (par1Obj == this)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!(par1Obj instanceof ProviderConfigurationPermission))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ProviderConfigurationPermission var2 = (ProviderConfigurationPermission)par1Obj;
|
||||||
|
return this.permissionMask == var2.permissionMask && this.getName().equals(var2.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.getName().hashCode() + this.permissionMask;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.bouncycastle.jcajce.provider.util;
|
||||||
|
|
||||||
|
import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
|
||||||
|
|
||||||
|
public abstract class AlgorithmProvider
|
||||||
|
{
|
||||||
|
public abstract void configure(ConfigurableProvider var1);
|
||||||
|
}
|
|
@ -0,0 +1,314 @@
|
||||||
|
package org.bouncycastle.jce.provider;
|
||||||
|
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.Provider;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.bouncycastle.asn1.bc.BCObjectIdentifiers;
|
||||||
|
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
|
||||||
|
import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
|
||||||
|
import org.bouncycastle.jcajce.provider.config.ProviderConfiguration;
|
||||||
|
import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;
|
||||||
|
|
||||||
|
public final class BouncyCastleProvider extends Provider implements ConfigurableProvider
|
||||||
|
{
|
||||||
|
private static String info = "BouncyCastle Security Provider v1.47";
|
||||||
|
public static String PROVIDER_NAME = "BC";
|
||||||
|
public static final ProviderConfiguration CONFIGURATION = new BouncyCastleProviderConfiguration();
|
||||||
|
private static final Map keyInfoConverters = new HashMap();
|
||||||
|
private static final String[] SYMMETRIC_CIPHERS = new String[] {"AES", "ARC4", "Blowfish", "Camellia", "CAST5", "CAST6", "DES", "DESede", "GOST28147", "Grainv1", "Grain128", "HC128", "HC256", "IDEA", "Noekeon", "RC2", "RC5", "RC6", "Rijndael", "Salsa20", "SEED", "Serpent", "Skipjack", "TEA", "Twofish", "VMPC", "VMPCKSA3", "XTEA"};
|
||||||
|
private static final String[] ASYMMETRIC_GENERIC = new String[] {"X509"};
|
||||||
|
private static final String[] ASYMMETRIC_CIPHERS = new String[] {"DSA", "DH", "EC", "RSA", "GOST", "ECGOST", "ElGamal"};
|
||||||
|
private static final String[] DIGESTS = new String[] {"GOST3411", "MD2", "MD4", "MD5", "SHA1", "RIPEMD128", "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA224", "SHA256", "SHA384", "SHA512", "Tiger", "Whirlpool"};
|
||||||
|
|
||||||
|
public BouncyCastleProvider()
|
||||||
|
{
|
||||||
|
super(PROVIDER_NAME, 1.47D, info);
|
||||||
|
AccessController.doPrivileged(new BouncyCastleProviderAction(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup()
|
||||||
|
{
|
||||||
|
this.loadAlgorithms("org.bouncycastle.jcajce.provider.digest.", DIGESTS);
|
||||||
|
this.loadAlgorithms("org.bouncycastle.jcajce.provider.symmetric.", SYMMETRIC_CIPHERS);
|
||||||
|
this.loadAlgorithms("org.bouncycastle.jcajce.provider.asymmetric.", ASYMMETRIC_GENERIC);
|
||||||
|
this.loadAlgorithms("org.bouncycastle.jcajce.provider.asymmetric.", ASYMMETRIC_CIPHERS);
|
||||||
|
this.put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection");
|
||||||
|
this.put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection");
|
||||||
|
this.put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection");
|
||||||
|
this.put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection");
|
||||||
|
this.put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts");
|
||||||
|
this.put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs");
|
||||||
|
this.put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts");
|
||||||
|
this.put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs");
|
||||||
|
this.put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser");
|
||||||
|
this.put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser");
|
||||||
|
this.put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser");
|
||||||
|
this.put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser");
|
||||||
|
this.put("KeyStore.BKS", "org.bouncycastle.jce.provider.JDKKeyStore");
|
||||||
|
this.put("KeyStore.BouncyCastle", "org.bouncycastle.jce.provider.JDKKeyStore$BouncyCastleStore");
|
||||||
|
this.put("KeyStore.PKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
|
||||||
|
this.put("KeyStore.BCPKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
|
||||||
|
this.put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
|
||||||
|
this.put("KeyStore.PKCS12-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
|
||||||
|
this.put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES");
|
||||||
|
this.put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
|
||||||
|
this.put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES");
|
||||||
|
this.put("Alg.Alias.KeyStore.UBER", "BouncyCastle");
|
||||||
|
this.put("Alg.Alias.KeyStore.BOUNCYCASTLE", "BouncyCastle");
|
||||||
|
this.put("Alg.Alias.KeyStore.bouncycastle", "BouncyCastle");
|
||||||
|
this.put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES");
|
||||||
|
this.put("AlgorithmParameters.PKCS12PBE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PKCS12PBE");
|
||||||
|
this.put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC2-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC4", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC2-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC4", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH-CBC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.1", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.2", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.3", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.4", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.5", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWithSHAAnd3KeyTripleDES", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND192BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND256BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND128BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND192BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND256BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND128BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND192BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND256BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND128BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND192BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND256BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND128BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND192BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND256BITAES-CBC-BC", "PKCS12PBE");
|
||||||
|
this.put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
|
||||||
|
this.put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
|
||||||
|
this.put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
|
||||||
|
this.put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
|
||||||
|
this.put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWithSHAAnd3KeyTripleDES", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
|
||||||
|
this.put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES");
|
||||||
|
this.put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES");
|
||||||
|
this.put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES");
|
||||||
|
this.put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES");
|
||||||
|
this.put("Cipher.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndDES");
|
||||||
|
this.put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES");
|
||||||
|
this.put("Cipher.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndRC2");
|
||||||
|
this.put("Cipher.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndDES");
|
||||||
|
this.put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES");
|
||||||
|
this.put("Cipher.PBEWITHSHA1ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndRC2");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd128BitRC2");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd40BitRC2");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND128BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd128BitRC4");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND40BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd40BitRC4");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "PBEWITHSHAAND128BITRC2-CBC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "PBEWITHSHAAND40BITRC2-CBC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "PBEWITHSHAAND128BITRC4");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "PBEWITHSHAAND40BITRC4");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHAAND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHA256AND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHA256AND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHA256AND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITAES-CBC-BC", "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND192BITAES-CBC-BC", "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA1AND256BITAES-CBC-BC", "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-1AND128BITAES-CBC-BC", "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-1AND192BITAES-CBC-BC", "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-1AND256BITAES-CBC-BC", "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-256AND128BITAES-CBC-BC", "PBEWITHSHA256AND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-256AND192BITAES-CBC-BC", "PBEWITHSHA256AND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.Cipher.PBEWITHSHA-256AND256BITAES-CBC-BC", "PBEWITHSHA256AND256BITAES-CBC-BC");
|
||||||
|
this.put("Cipher.PBEWITHMD5AND128BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHMD5AND192BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
|
||||||
|
this.put("Cipher.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndTwofish");
|
||||||
|
this.put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
|
||||||
|
this.put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithSHA1AndRC2_CBC, "PBEWITHSHA1ANDRC2");
|
||||||
|
this.put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.1", "PBEWITHSHAAND128BITRC4");
|
||||||
|
this.put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.2", "PBEWITHSHAAND40BITRC4");
|
||||||
|
this.put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.5", "PBEWITHSHAAND128BITRC2-CBC");
|
||||||
|
this.put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.6", "PBEWITHSHAAND40BITRC2-CBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndRC2_CBC, "PBEWITHSHA1ANDRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndDES");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA1AndDES");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHA1ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA1AndRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndDES3Key");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndDES2Key");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND128BITRC4", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitRC4");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND40BITRC4", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd40BitRC4");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd40BitRC2");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndTwofish");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD5AND128BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And128BitAESCBCOpenSSL");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD5AND192BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And192BitAESCBCOpenSSL");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And256BitAESCBCOpenSSL");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDDES-CBC", "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDRC2-CBC", "PBEWITHMD5ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDDES-CBC", "PBEWITHSHA1ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDRC2-CBC", "PBEWITHSHA1ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndRC2_CBC, "PBEWITHSHA1ANDRC2");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.1", "PBEWITHSHAAND128BITRC4");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.2", "PBEWITHSHAAND40BITRC4");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.3", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.4", "PBEWITHSHAAND2-KEYTRIPLEDES-CBC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.5", "PBEWITHSHAAND128BITRC2-CBC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.6", "PBEWITHSHAAND40BITRC2-CBC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHHMACSHA", "PBEWITHHMACSHA1");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.1.3.14.3.2.26", "PBEWITHHMACSHA1");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWithSHAAnd3KeyTripleDES", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitAESBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd192BitAESBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHAAND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd256BitAESBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHA256AND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA256And128BitAESBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHA256AND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA256And192BitAESBC");
|
||||||
|
this.put("SecretKeyFactory.PBEWITHSHA256AND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA256And256BitAESBC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND128BITAES-CBC-BC", "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND192BITAES-CBC-BC", "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND256BITAES-CBC-BC", "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND128BITAES-CBC-BC", "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND192BITAES-CBC-BC", "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND256BITAES-CBC-BC", "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND128BITAES-CBC-BC", "PBEWITHSHA256AND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND192BITAES-CBC-BC", "PBEWITHSHA256AND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND256BITAES-CBC-BC", "PBEWITHSHA256AND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PBEWITHSHAAND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PBEWITHSHAAND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PBEWITHSHAAND256BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
|
||||||
|
this.put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
|
||||||
|
this.addMacAlgorithms();
|
||||||
|
this.put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi");
|
||||||
|
this.put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi");
|
||||||
|
this.put("CertPathValidator.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
|
||||||
|
this.put("CertPathBuilder.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
|
||||||
|
this.put("CertPathValidator.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
|
||||||
|
this.put("CertPathBuilder.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
|
||||||
|
this.put("CertStore.Collection", "org.bouncycastle.jce.provider.CertStoreCollectionSpi");
|
||||||
|
this.put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi");
|
||||||
|
this.put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi");
|
||||||
|
this.put("Alg.Alias.CertStore.X509LDAP", "LDAP");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAlgorithms(String par1Str, String[] par2ArrayOfStr)
|
||||||
|
{
|
||||||
|
for (int var3 = 0; var3 != par2ArrayOfStr.length; ++var3)
|
||||||
|
{
|
||||||
|
Class var4 = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ClassLoader var5 = this.getClass().getClassLoader();
|
||||||
|
|
||||||
|
if (var5 != null)
|
||||||
|
{
|
||||||
|
var4 = var5.loadClass(par1Str + par2ArrayOfStr[var3] + "$Mappings");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var4 = Class.forName(par1Str + par2ArrayOfStr[var3] + "$Mappings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException var7)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var4 != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
((AlgorithmProvider)var4.newInstance()).configure(this);
|
||||||
|
}
|
||||||
|
catch (Exception var6)
|
||||||
|
{
|
||||||
|
var6.printStackTrace();
|
||||||
|
throw new InternalError("cannot create instance of " + par1Str + par2ArrayOfStr[var3] + "$Mappings : " + var6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMacAlgorithms()
|
||||||
|
{
|
||||||
|
this.put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
|
||||||
|
this.put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797");
|
||||||
|
this.put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
|
||||||
|
this.put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC");
|
||||||
|
this.put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4");
|
||||||
|
this.put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING");
|
||||||
|
this.put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384");
|
||||||
|
this.put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512");
|
||||||
|
this.put("Mac.PBEWITHHMACSHA", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
|
||||||
|
this.put("Mac.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
|
||||||
|
this.put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160");
|
||||||
|
this.put("Alg.Alias.Mac.1.3.14.3.2.26", "PBEWITHHMACSHA");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doSetup(BouncyCastleProvider par0BouncyCastleProvider)
|
||||||
|
{
|
||||||
|
par0BouncyCastleProvider.setup();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.bouncycastle.jce.provider;
|
||||||
|
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
|
class BouncyCastleProviderAction implements PrivilegedAction
|
||||||
|
{
|
||||||
|
final BouncyCastleProvider theBouncyCastleProvider;
|
||||||
|
|
||||||
|
BouncyCastleProviderAction(BouncyCastleProvider par1BouncyCastleProvider)
|
||||||
|
{
|
||||||
|
this.theBouncyCastleProvider = par1BouncyCastleProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object run()
|
||||||
|
{
|
||||||
|
BouncyCastleProvider.doSetup(this.theBouncyCastleProvider);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.bouncycastle.jce.provider;
|
||||||
|
|
||||||
|
import java.security.Permission;
|
||||||
|
import org.bouncycastle.jcajce.provider.config.ProviderConfiguration;
|
||||||
|
import org.bouncycastle.jcajce.provider.config.ProviderConfigurationPermission;
|
||||||
|
|
||||||
|
class BouncyCastleProviderConfiguration implements ProviderConfiguration
|
||||||
|
{
|
||||||
|
private static Permission BC_EC_LOCAL_PERMISSION = new ProviderConfigurationPermission(BouncyCastleProvider.PROVIDER_NAME, "threadLocalEcImplicitlyCa");
|
||||||
|
private static Permission BC_EC_PERMISSION = new ProviderConfigurationPermission(BouncyCastleProvider.PROVIDER_NAME, "ecImplicitlyCa");
|
||||||
|
private static Permission BC_DH_LOCAL_PERMISSION = new ProviderConfigurationPermission(BouncyCastleProvider.PROVIDER_NAME, "threadLocalDhDefaultParams");
|
||||||
|
private static Permission BC_DH_PERMISSION = new ProviderConfigurationPermission(BouncyCastleProvider.PROVIDER_NAME, "DhDefaultParams");
|
||||||
|
private ThreadLocal ecThreadSpec = new ThreadLocal();
|
||||||
|
private ThreadLocal dhThreadSpec = new ThreadLocal();
|
||||||
|
}
|
33
src/main/java/org/bouncycastle/util/Strings.java
Normal file
33
src/main/java/org/bouncycastle/util/Strings.java
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package org.bouncycastle.util;
|
||||||
|
|
||||||
|
public final class Strings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A locale independent version of toLowerCase that returns a US ASCII lowercase String.
|
||||||
|
*/
|
||||||
|
public static String toLowerCase(String par0Str)
|
||||||
|
{
|
||||||
|
boolean var1 = false;
|
||||||
|
char[] var2 = par0Str.toCharArray();
|
||||||
|
|
||||||
|
for (int var3 = 0; var3 != var2.length; ++var3)
|
||||||
|
{
|
||||||
|
char var4 = var2[var3];
|
||||||
|
|
||||||
|
if (65 <= var4 && 90 >= var4)
|
||||||
|
{
|
||||||
|
var1 = true;
|
||||||
|
var2[var3] = (char)(var4 - 65 + 97);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var1)
|
||||||
|
{
|
||||||
|
return new String(var2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return par0Str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user