public class AdbCrypto
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
KEY_LENGTH_BITS
The ADB RSA key length in bits
|
static int |
KEY_LENGTH_BYTES
The ADB RSA key length in bytes
|
static int |
KEY_LENGTH_WORDS
The ADB RSA key length in words
|
static byte[] |
SIGNATURE_PADDING
The RSA signature padding as a byte array
|
static int[] |
SIGNATURE_PADDING_AS_INT
The RSA signature padding as an int array
|
Constructor and Description |
---|
AdbCrypto() |
Modifier and Type | Method and Description |
---|---|
static AdbCrypto |
generateAdbKeyPair(AdbBase64 base64)
Creates a new AdbCrypto object by generating a new key pair.
|
byte[] |
getAdbPublicKeyPayload()
Gets the RSA public key in ADB format.
|
static AdbCrypto |
loadAdbKeyPair(AdbBase64 base64,
java.io.File privateKey,
java.io.File publicKey)
Creates a new AdbCrypto object from a key pair loaded from files.
|
void |
saveAdbKeyPair(java.io.File privateKey,
java.io.File publicKey)
Saves the AdbCrypto's key pair to the specified files.
|
byte[] |
signAdbTokenPayload(byte[] payload)
Signs the ADB SHA1 payload with the private key of this object.
|
public static final int KEY_LENGTH_BITS
public static final int KEY_LENGTH_BYTES
public static final int KEY_LENGTH_WORDS
public static final int[] SIGNATURE_PADDING_AS_INT
public static byte[] SIGNATURE_PADDING
public static AdbCrypto loadAdbKeyPair(AdbBase64 base64, java.io.File privateKey, java.io.File publicKey) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException
base64
- Implementation of base 64 conversion interface required by ADBprivateKey
- File containing the RSA private keypublicKey
- File containing the RSA public keyjava.io.IOException
- If the files cannot be readjava.security.NoSuchAlgorithmException
- If an RSA key factory cannot be foundjava.security.spec.InvalidKeySpecException
- If a PKCS8 or X509 key spec cannot be foundpublic static AdbCrypto generateAdbKeyPair(AdbBase64 base64) throws java.security.NoSuchAlgorithmException
base64
- Implementation of base 64 conversion interface required by ADBjava.security.NoSuchAlgorithmException
- If an RSA key factory cannot be foundpublic byte[] signAdbTokenPayload(byte[] payload) throws java.security.GeneralSecurityException
payload
- SHA1 payload to signjava.security.GeneralSecurityException
- If signing failspublic byte[] getAdbPublicKeyPayload() throws java.io.IOException
java.io.IOException
- If the key cannot be retrivedpublic void saveAdbKeyPair(java.io.File privateKey, java.io.File publicKey) throws java.io.IOException
privateKey
- The file to store the encoded private keypublicKey
- The file to store the encoded public keyjava.io.IOException
- If the files cannot be written