Back to Solopi

AdbCrypto

src/AdbLib/doc/com/cgutman/adblib/AdbCrypto.html

0.12.07.1 KB
Original Source

com.cgutman.adblib

Class AdbCrypto

  • java.lang.Object

    • com.cgutman.adblib.AdbCrypto

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

Field Summary

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 |

Constructor Summary

Constructors | Constructor and Description | | --- | | AdbCrypto() |

Method Summary

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. |

- 

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

- 

KEY_LENGTH_BITS

public static final int KEY_LENGTH_BITS

The ADB RSA key length in bits See Also:Constant Field Values

- 

KEY_LENGTH_BYTES

public static final int KEY_LENGTH_BYTES

The ADB RSA key length in bytes See Also:Constant Field Values

- 

KEY_LENGTH_WORDS

public static final int KEY_LENGTH_WORDS

The ADB RSA key length in words See Also:Constant Field Values

- 

SIGNATURE_PADDING_AS_INT

public static final int[] SIGNATURE_PADDING_AS_INT

The RSA signature padding as an int array

- 

SIGNATURE_PADDING

public static byte[] SIGNATURE_PADDING

The RSA signature padding as a byte array

Constructor Detail

- 

AdbCrypto

public AdbCrypto()

Method Detail

- 

loadAdbKeyPair

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

- 

generateAdbKeyPair

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

- 

signAdbTokenPayload

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

- 

getAdbPublicKeyPayload

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

- 

saveAdbKeyPair

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