|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.PrivateKeyFile
public class PrivateKeyFile
This helper class reads and writes files in the same "eepPriv.dat" format used by the client code. The format is:
- Destination (387 bytes if no certificate, otherwise longer) - Public key (256 bytes) - Signing Public key (128 bytes) - Cert. type (1 byte) - Cert. length (2 bytes) - Certificate if length != 0 - Private key (256 bytes) - Signing Private key (20 bytes, or length specified by key certificate) Total: 663 or more bytes
Field Summary | |
---|---|
protected Destination |
dest
|
protected File |
file
|
protected PrivateKey |
privKey
|
protected SigningPrivateKey |
signingPrivKey
|
Constructor Summary | |
---|---|
PrivateKeyFile(File file)
|
|
PrivateKeyFile(File file,
Destination dest,
PrivateKey pk,
SigningPrivateKey spk)
|
|
PrivateKeyFile(File file,
I2PClient client)
|
|
PrivateKeyFile(File file,
I2PSession session)
|
|
PrivateKeyFile(File file,
PublicKey pubkey,
SigningPublicKey spubkey,
Certificate cert,
PrivateKey pk,
SigningPrivateKey spk)
|
|
PrivateKeyFile(File file,
PublicKey pubkey,
SigningPublicKey spubkey,
Certificate cert,
PrivateKey pk,
SigningPrivateKey spk,
byte[] padding)
|
|
PrivateKeyFile(String file)
|
Method Summary | |
---|---|
static boolean |
checkSignature(Signature s,
byte[] data,
SigningPublicKey spk)
|
Destination |
createIfAbsent()
Also reads in the file to get the privKey and signingPrivKey, which aren't available from I2PClient. |
static String |
estimateHashCashTime(int hashEffort)
|
Destination |
getDestination()
If the destination is not set, read it in from the file. |
PrivateKey |
getPrivKey()
|
SigningPrivateKey |
getSigningPrivKey()
|
static void |
main(String[] args)
Create a new PrivateKeyFile, or modify an existing one, with various types of Certificates. |
I2PSession |
open()
|
I2PSession |
open(Properties opts)
|
Certificate |
setCertType(int t)
Change cert type - caller must also call write(). |
void |
setDestination(Destination d)
|
Certificate |
setHashCashCert(int effort)
change to hashcash cert - caller must also call write() |
Certificate |
setKeyCert(SigType type)
Change cert type - caller must also call write(). |
Certificate |
setSignedCert(PrivateKeyFile pkf2)
sign this dest by dest found in pkf2 - caller must also call write() |
String |
toString()
|
boolean |
validateKeyPairs()
Verify that the PublicKey matches the PrivateKey, and the SigningPublicKey matches the SigningPrivateKey. |
static boolean |
verifySignature(Destination d)
Sample code to verify a 3rd party signature. |
void |
write()
Copied from I2PClientImpl.createDestination() |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final File file
protected Destination dest
protected PrivateKey privKey
protected SigningPrivateKey signingPrivKey
Constructor Detail |
---|
public PrivateKeyFile(String file)
public PrivateKeyFile(File file)
public PrivateKeyFile(File file, I2PClient client)
public PrivateKeyFile(File file, I2PSession session)
public PrivateKeyFile(File file, Destination dest, PrivateKey pk, SigningPrivateKey spk)
IllegalArgumentException
- on mismatch of spubkey and spk typespublic PrivateKeyFile(File file, PublicKey pubkey, SigningPublicKey spubkey, Certificate cert, PrivateKey pk, SigningPrivateKey spk)
IllegalArgumentException
- on mismatch of spubkey and spk typespublic PrivateKeyFile(File file, PublicKey pubkey, SigningPublicKey spubkey, Certificate cert, PrivateKey pk, SigningPrivateKey spk, byte[] padding)
padding
- null OK, must be non-null if spubkey length < 128
IllegalArgumentException
- on mismatch of spubkey and spk typesMethod Detail |
---|
public static void main(String[] args)
public Destination createIfAbsent() throws I2PException, IOException, DataFormatException
I2PException
IOException
DataFormatException
public Destination getDestination() throws I2PSessionException, IOException, DataFormatException
I2PSessionException
IOException
DataFormatException
public void setDestination(Destination d)
public Certificate setCertType(int t)
public Certificate setKeyCert(SigType type)
public Certificate setHashCashCert(int effort)
public Certificate setSignedCert(PrivateKeyFile pkf2)
public PrivateKey getPrivKey()
public SigningPrivateKey getSigningPrivKey()
public I2PSession open() throws I2PSessionException, IOException
I2PSessionException
IOException
public I2PSession open(Properties opts) throws I2PSessionException, IOException
I2PSessionException
IOException
public void write() throws IOException, DataFormatException
IOException
DataFormatException
public boolean validateKeyPairs()
public String toString()
toString
in class Object
public static String estimateHashCashTime(int hashEffort)
public static boolean verifySignature(Destination d)
public static boolean checkSignature(Signature s, byte[] data, SigningPublicKey spk)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |