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[] keyBytes) static PublicKeybyteToPublicKey(byte[] encodedKey) Create a new PublicKey from encoded X.509 dataprivate static byte[]cipherData(int opMode, Key key, byte[] data) Encrypt or decrypt byte[] data using the specified keystatic SecretKeydecryptByteToSecretKey(PrivateKey key, byte[] secretKeyEncrypted) Decrypt shared secret AES key using RSA private keystatic byte[]decryptUsingKey(Key key, byte[] data) Decrypt byte[] data with RSA private keyprivate static byte[]digestData(byte[]... data) static byte[]digestData(String serverId, PublicKey publicKey, SecretKey secretKey) Compute a serverId hash for use by sendSessionRequest()static byte[]encryptUsingKey(Key key, byte[] data) Encrypt byte[] data with RSA public keystatic KeyPairstatic SecretKeystatic CipherCreates a Cipher instance using the AES/CFB8/NoPadding algorithm.static Stringstatic Stringprivate static <T extends Key>
TrsaStringToKey(String keyBase64, String header, String footer, Crypt.ByteArrayToKeyFunction<T> keyFunction) private static CiphersetupCipher(int opMode, String transformation, Key key) Creates the Cipher Instance.static PrivateKeystringToPemRsaPrivateKey(String keyBase64) static PublicKeystringToRsaPublicKey(String keyBase64)
-
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 secretKey) throws CryptException Compute a serverId hash for use by sendSessionRequest()- Throws:
CryptException
-
digestData
- Throws:
Exception
-
rsaStringToKey
private static <T extends Key> T rsaStringToKey(String keyBase64, String header, String footer, Crypt.ByteArrayToKeyFunction<T> keyFunction) 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 key, byte[] secretKeyEncrypted) 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
-