This commit is contained in:
ayunami2000 2022-01-22 16:18:15 -05:00
parent a71aa786d5
commit fbe96f6469
6 changed files with 18935 additions and 18821 deletions

File diff suppressed because one or more lines are too long

View File

@ -185,7 +185,7 @@ public class CryptManager
try
{
Cipher var3 = Cipher.getInstance(par1Str);
var3.init(par0, par2Key);
var3.init(par0, (java.security.Key) par2Key);
return var3;
}
catch (InvalidKeyException var4)

View File

@ -0,0 +1,84 @@
package me.ayunami2000.ayuncraft;
import java.math.BigInteger;
import java.nio.ByteBuffer;
public class ParseRSAPublicKey {
private static final int SEQUENCE = 0x30;
private static final int INTEGER = 0x02;
private final ByteBuffer derBuf;
public ParseRSAPublicKey(byte[] der) {
derBuf = ByteBuffer.wrap(der);
}
public byte get() {
return derBuf.get();
}
/**
* @return the next byte of the buffer as an int
*/
public int getAsInt() {
return get() & 0xff;
}
public byte[] getArray(int len) {
byte [] arr = new byte[len];
derBuf.get(arr);
return arr;
}
public int parseId() {
// Only the low-tag form is legal.
int idOctect = getAsInt();
if (idOctect >= 0x31) {
throw new RuntimeException("Invalid identifier octets");
}
return idOctect;
}
public long parseLength() {
int octet1 = getAsInt();
if (octet1 < 128) {
// short form of length
return octet1;
} else {
// long form of length
int lengthOfLength = octet1 & 0x7f;
BigInteger bigLen = new BigInteger(1, getArray(lengthOfLength));
if (bigLen.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0){
throw new RuntimeException("Length is too long");
}
return bigLen.longValue();
}
}
public BigInteger parseInteger() {
if (parseId() != INTEGER) {
throw new RuntimeException("expected SEQUENCE tag");
}
long length = parseLength();
if (length > Integer.MAX_VALUE){
throw new RuntimeException("Length is too long");
}
return new BigInteger(1, getArray((int) length));
}
public BigInteger[] parse() {
// Parse SEQUENCE header
if (parseId() != SEQUENCE) {
throw new RuntimeException("expected SEQUENCE tag");
}
@SuppressWarnings("unused")
long seqLength = parseLength(); // We ignore this
// Parse INTEGER modulus
BigInteger n = parseInteger();
BigInteger e = parseInteger();
return new BigInteger[] {n, e};
}
}

View File

@ -61,6 +61,11 @@ public class CryptManager
b[i] = (byte) (a.get(i) & 0xFF);
}
*/
//ParseRSAPublicKey parser = new ParseRSAPublicKey(par0ArrayOfByte);
//BigInteger[] results = parser.parse();
//return new RSAPublicKeySpec(results[0],results[1]);
return new ModifiablePublicKey("RSA","X.509",par0ArrayOfByte);
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package me.ayunami2000.ayuncraft.java.security.spec;
public interface AlgorithmParameterSpec { }

View File

@ -23,24 +23,10 @@
*
*/
package java.security.spec;
package me.ayunami2000.ayuncraft.java.security.spec;
import java.math.BigInteger;
/**
* This class specifies an RSA public key.
*
* @author Jan Luehe
*
*
* @see java.security.Key
* @see java.security.KeyFactory
* @see KeySpec
* @see X509EncodedKeySpec
* @see RSAPrivateKeySpec
* @see RSAPrivateCrtKeySpec
*/
public class RSAPublicKeySpec implements KeySpec {
private final BigInteger modulus;