java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.data.SigningPrivateKey
net.i2p.crypto.RSASigningPrivateCrtKey
- All Implemented Interfaces:
Destroyable, DataStructure
A SigningPrivateKey that retains the Chinese Remainder Theorem parameters, so it can be converted back to a Java CRT key.
By preserving the CRT parameters across a Java to I2P to Java conversion, we speed up signing by about 3.3x, and the parameters are correctly serialized in PEM format when stored to a keystore.
The CRT parameters are NOT retained when this object is serialized via getData().
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RSAPrivateCrtKeyThe Java CRT key the signature is made with.Fields inherited from class SigningPrivateKey
KEYSIZE_BYTESModifier and TypeFieldDescriptionstatic final intDefault key size in bytes (20 for DSA-SHA1).Fields inherited from class SimpleDataStructure
_dataConstructor Summary
ConstructorsModifierConstructorDescriptionprivateRSASigningPrivateCrtKey(RSAPrivateCrtKey pk, SigType type, byte[] data) Wraps a Java CRT key together with its encoded form.Method Summary
Modifier and TypeMethodDescriptionstatic RSASigningPrivateCrtKeyJava private CRT key.The Java key wrapped by this object.Methods inherited from class SigningPrivateKey
blind, destroy, equals, getType, hashCode, isDestroyed, isOffline, length, toPublic, toStringModifier and TypeMethodDescriptionblind(SigningPrivateKey alpha) Only for SigType EdDSA_SHA512_Ed25519.voiddestroy()Destroy this key and clear its data, per the javax.security.auth.Destroyable interface.booleanEqual if the keys are equal.getType()Signature type of this private key.inthashCode()Hash code combining the type and data.booleanWhether this key has been destroyed.booleanConstant time.intlength()Key length in bytes, determined by the signature type.toPublic()Converts this signing private key to its public equivalent.toString()Key summary for log messages.Methods inherited from class SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytesModifier and TypeMethodDescriptionSHA256 hash of the byte array, or null if data is null.voidfromBase64(String data) Data from the base64 string.voidfromByteArray(byte[] data) Does the same thing asSimpleDataStructure.setData(byte[])but null not allowed.byte[]getData()Data reference (not a copy).protected intread(InputStream in, byte[] target) Repeated reads until the buffer is full or IOException is thrown.voidreadBytes(InputStream in) Data read from the stream.voidsetData(byte[] data) The byte array data, or null.toBase64()Renders the structure into modified base 64 notation.byte[]Same thing as getData().voidwriteBytes(OutputStream out) Writes the data to the output stream.
Field Details
_crt
The Java CRT key the signature is made with.
Constructor Details
RSASigningPrivateCrtKey
Wraps a Java CRT key together with its encoded form.- Parameters:
pk- the Java private keytype- the signature typedata- the encoded key
Method Details
fromJavaKey
public static RSASigningPrivateCrtKey fromJavaKey(RSAPrivateCrtKey pk) throws GeneralSecurityException Java private CRT key.- Parameters:
pk- the Java private CRT key- Returns:
- the I2P signing private key
- Throws:
IllegalArgumentException- if data is not correct lengthGeneralSecurityException- if the modulus bit length matches none of the known RSA key sizes
toJavaKey
The Java key wrapped by this object.- Returns:
- the underlying CRT key, never null