Class Crypt
java.lang.Object
net.minecraft.util.Crypt
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceCrypt.ByteArrayToKeyFunction<T extends Key>static final recordstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final intprivate static final Stringprivate static final Stringstatic final Base64.Encoderstatic final Stringprivate static final Stringprivate static final Stringstatic final com.mojang.serialization.Codec<PrivateKey> static final com.mojang.serialization.Codec<PublicKey> private static final Stringstatic final Stringstatic final intstatic final Stringprivate static final Stringprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PrivateKeybyteToPrivateKey(byte[] keyData) static PublicKeybyteToPublicKey(byte[] keyData) Create a new PublicKey from encoded X.509 dataprivate static byte[]cipherData(int cipherOpMode, Key key, byte[] input) Encrypt or decrypt byte[] data using the specified keystatic SecretKeydecryptByteToSecretKey(PrivateKey privateKey, byte[] keyData) Decrypt shared secret AES key using RSA private keystatic byte[]decryptUsingKey(Key key, byte[] input) Decrypt byte[] data with RSA private keyprivate static byte[]digestData(byte[]... inputs) static byte[]digestData(String serverId, PublicKey publicKey, SecretKey sharedKey) Compute a serverId hash for use by sendSessionRequest()static byte[]encryptUsingKey(Key key, byte[] input) Encrypt byte[] data with RSA public keystatic KeyPairstatic SecretKeystatic CipherCreates a Cipher instance using the AES/CFB8/NoPadding algorithm.static StringpemRsaPrivateKeyToString(PrivateKey privateKey) static StringrsaPublicKeyToString(PublicKey publicKey) private static <T extends Key>
TrsaStringToKey(String input, String header, String footer, Crypt.ByteArrayToKeyFunction<T> byteArrayToKey) private static CiphersetupCipher(int cipherOpMode, String algorithm, Key key) Creates the Cipher Instance.static PrivateKeystringToPemRsaPrivateKey(String rsaString) static PublicKeystringToRsaPublicKey(String rsaString)
-
Field Details
-
SYMMETRIC_ALGORITHM
- See Also:
-
SYMMETRIC_BITS
private static final int SYMMETRIC_BITS- See Also:
-
ASYMMETRIC_ALGORITHM
- See Also:
-
ASYMMETRIC_BITS
private static final int ASYMMETRIC_BITS- See Also:
-
BYTE_ENCODING
- See Also:
-
HASH_ALGORITHM
- See Also:
-
SIGNING_ALGORITHM
- See Also:
-
SIGNATURE_BYTES
public static final int SIGNATURE_BYTES- See Also:
-
PEM_RSA_PRIVATE_KEY_HEADER
- See Also:
-
PEM_RSA_PRIVATE_KEY_FOOTER
- See Also:
-
RSA_PUBLIC_KEY_HEADER
- See Also:
-
RSA_PUBLIC_KEY_FOOTER
- See Also:
-
MIME_LINE_SEPARATOR
- See Also:
-
MIME_ENCODER
-
PUBLIC_KEY_CODEC
-
PRIVATE_KEY_CODEC
-
-
Constructor Details
-
Crypt
public Crypt()
-
-
Method Details
-
generateSecretKey
- Throws:
CryptException
-
generateKeyPair
- Throws:
CryptException
-
digestData
public static byte[] digestData(String serverId, PublicKey publicKey, SecretKey sharedKey) throws CryptException Compute a serverId hash for use by sendSessionRequest()- Throws:
CryptException
-
digestData
-
rsaStringToKey
private static <T extends Key> T rsaStringToKey(String input, String header, String footer, Crypt.ByteArrayToKeyFunction<T> byteArrayToKey) throws CryptException - Throws:
CryptException
-
stringToPemRsaPrivateKey
- Throws:
CryptException
-
stringToRsaPublicKey
- Throws:
CryptException
-
rsaPublicKeyToString
-
pemRsaPrivateKeyToString
-
byteToPrivateKey
- Throws:
CryptException
-
byteToPublicKey
Create a new PublicKey from encoded X.509 data- Throws:
CryptException
-
decryptByteToSecretKey
public static SecretKey decryptByteToSecretKey(PrivateKey privateKey, byte[] keyData) throws CryptException Decrypt shared secret AES key using RSA private key- Throws:
CryptException
-
encryptUsingKey
Encrypt byte[] data with RSA public key- Throws:
CryptException
-
decryptUsingKey
Decrypt byte[] data with RSA private key- Throws:
CryptException
-
cipherData
Encrypt or decrypt byte[] data using the specified key- Throws:
CryptException
-
setupCipher
-
getCipher
Creates a Cipher instance using the AES/CFB8/NoPadding algorithm. Used for protocol encryption.- Throws:
CryptException
-