Package net.minecraft.util
Class Crypt
java.lang.Object
net.minecraft.util.Crypt
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
Crypt.ByteArrayToKeyFunction<T extends Key>
static final record
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final int
private static final String
private static final String
static final Base64.Encoder
static final String
private static final String
private static final String
static final com.mojang.serialization.Codec
<PrivateKey> static final com.mojang.serialization.Codec
<PublicKey> private static final String
static final String
static final int
static final String
private static final String
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PrivateKey
byteToPrivateKey
(byte[] p_216083_) static PublicKey
byteToPublicKey
(byte[] p_13601_) Create a new PublicKey from encoded X.509 dataprivate static byte[]
cipherData
(int pOpMode, Key pKey, byte[] pData) Encrypt or decrypt byte[] data using the specified keystatic SecretKey
decryptByteToSecretKey
(PrivateKey pKey, byte[] pSecretKeyEncrypted) Decrypt shared secret AES key using RSA private keystatic byte[]
decryptUsingKey
(Key pKey, byte[] pData) Decrypt byte[] data with RSA private keyprivate static byte[]
digestData
(byte[]... pData) static byte[]
digestData
(String pServerId, PublicKey pPublicKey, SecretKey pSecretKey) Compute a serverId hash for use by sendSessionRequest()static byte[]
encryptUsingKey
(Key pKey, byte[] pData) Encrypt byte[] data with RSA public keystatic KeyPair
static SecretKey
static Cipher
Creates a Cipher instance using the AES/CFB8/NoPadding algorithm.static String
pemRsaPrivateKeyToString
(PrivateKey p_216077_) static String
rsaPublicKeyToString
(PublicKey p_216079_) private static <T extends Key>
TrsaStringToKey
(String pKeyBase64, String pHeader, String pFooter, Crypt.ByteArrayToKeyFunction<T> pKeyFunction) private static Cipher
setupCipher
(int pOpMode, String pTransformation, Key pKey) Creates the Cipher Instance.static PrivateKey
stringToPemRsaPrivateKey
(String pKeyBase64) static PublicKey
stringToRsaPublicKey
(String pKeyBase64)
-
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 pServerId, PublicKey pPublicKey, SecretKey pSecretKey) throws CryptException Compute a serverId hash for use by sendSessionRequest()- Throws:
CryptException
-
digestData
- Throws:
Exception
-
rsaStringToKey
private static <T extends Key> T rsaStringToKey(String pKeyBase64, String pHeader, String pFooter, Crypt.ByteArrayToKeyFunction<T> pKeyFunction) 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 pKey, byte[] pSecretKeyEncrypted) 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
Creates the Cipher Instance.- Throws:
Exception
-
getCipher
Creates a Cipher instance using the AES/CFB8/NoPadding algorithm. Used for protocol encryption.- Throws:
CryptException
-