Package net.minecraft.util
Class Crypt
java.lang.Object
net.minecraft.util.Crypt
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) 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[] p_216083_) static PublicKeybyteToPublicKey(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 SecretKeydecryptByteToSecretKey(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 KeyPairstatic SecretKeystatic CipherCreates a Cipher instance using the AES/CFB8/NoPadding algorithm.static StringpemRsaPrivateKeyToString(PrivateKey p_216077_) static StringrsaPublicKeyToString(PublicKey p_216079_) private static <T extends Key>
TrsaStringToKey(String pKeyBase64, String pHeader, String pFooter, Crypt.ByteArrayToKeyFunction<T> pKeyFunction) private static CiphersetupCipher(int pOpMode, String pTransformation, Key pKey) Creates the Cipher Instance.static PrivateKeystringToPemRsaPrivateKey(String pKeyBase64) static PublicKeystringToRsaPublicKey(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
-