src/AdbLib/doc/com/cgutman/adblib/AdbCrypto.html
com.cgutman.adblib
java.lang.Object
public classAdbCryptoextends java.lang.Object
This class encapsulates the ADB cryptography functions and provides an interface for the storage and retrieval of keys. Author:Cameron Gutman
Fields | 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
|
Constructors | Constructor and Description |
| --- |
| AdbCrypto() |
Methods | 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.
|
-
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final int KEY_LENGTH_BITS
The ADB RSA key length in bits See Also:Constant Field Values
-
public static final int KEY_LENGTH_BYTES
The ADB RSA key length in bytes See Also:Constant Field Values
-
public static final int KEY_LENGTH_WORDS
The ADB RSA key length in words See Also:Constant Field Values
-
public static final int[] SIGNATURE_PADDING_AS_INT
The RSA signature padding as an int array
-
public static byte[] SIGNATURE_PADDING
The RSA signature padding as a byte array
-
public AdbCrypto()
-
public static[AdbCrypto](../../../com/cgutman/adblib/AdbCrypto.html "class in com.cgutman.adblib")loadAdbKeyPair([AdbBase64](../../../com/cgutman/adblib/AdbBase64.html "interface in com.cgutman.adblib")base64,
java.io.File privateKey,
java.io.File publicKey)
throws java.io.IOException,
java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
Creates a new AdbCrypto object from a key pair loaded from files.
Parameters:base64 - Implementation of base 64 conversion interface required by ADBprivateKey - File containing the RSA private keypublicKey - File containing the RSA public keyReturns:New AdbCrypto objectThrows:java.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 found
-
public static[AdbCrypto](../../../com/cgutman/adblib/AdbCrypto.html "class in com.cgutman.adblib")generateAdbKeyPair([AdbBase64](../../../com/cgutman/adblib/AdbBase64.html "interface in com.cgutman.adblib")base64)
throws java.security.NoSuchAlgorithmException
Creates a new AdbCrypto object by generating a new key pair.
Parameters:base64 - Implementation of base 64 conversion interface required by ADBReturns:A new AdbCrypto objectThrows:java.security.NoSuchAlgorithmException - If an RSA key factory cannot be found
-
public byte[] signAdbTokenPayload(byte[] payload)
throws java.security.GeneralSecurityException
Signs the ADB SHA1 payload with the private key of this object.
Parameters:payload - SHA1 payload to signReturns:Signed SHA1 payloadThrows:java.security.GeneralSecurityException - If signing fails
-
public byte[] getAdbPublicKeyPayload()
throws java.io.IOException
Gets the RSA public key in ADB format.
Returns:Byte array containing the RSA public key in ADB format.Throws:java.io.IOException - If the key cannot be retrived
-
public void saveAdbKeyPair(java.io.File privateKey,
java.io.File publicKey)
throws java.io.IOException
Saves the AdbCrypto's key pair to the specified files.
Parameters:privateKey - The file to store the encoded private keypublicKey - The file to store the encoded public keyThrows:java.io.IOException - If the files cannot be written