public class EncryptedLeaseSet extends LeaseSet2
EncryptedLeaseSet provides privacy and authentication enhancements over standard LeaseSet2:
Key Features:
LeaseSet.getSigningKey() for the blinded key (revocation key in super)Usage:
Authentication Methods:
BlindData.AUTH_NONE - No authentication requiredBlindData.AUTH_DH - Diffie-Hellman key exchange authenticationBlindData.AUTH_PSK - Pre-shared key authenticationImplementation Status: PRELIMINARY - Subject to change as the proposal evolves
_expires, _flags, _offlineSignature, _options, _published, _transientExpires, _transientSigningPublicKey_byteified, _checked, _destination, _encryptionKey, _lastExpiration, _leases, _signingKey, MAX_LEASES_signature, KEY_TYPE_ENCRYPTED_LS2, KEY_TYPE_LEASESET, KEY_TYPE_LS2, KEY_TYPE_META_LS2, KEY_TYPE_ROUTERINFO, KEY_TYPE_SERVICE_LIST, KEY_TYPE_SERVICE_RECORD| Constructor and Description |
|---|
EncryptedLeaseSet() |
| Modifier and Type | Method and Description |
|---|---|
void |
encrypt(int authType,
List<? extends SimpleDataStructure> clientKeys)
Throws IllegalStateException if not initialized.
|
void |
encrypt(SessionKey skey)
Throws IllegalStateException if not initialized.
|
boolean |
equals(Object object) |
LeaseSet2 |
getDecryptedLeaseSet() |
PublicKey |
getEncryptionKey(Set<EncType> supported)
If more than one key, return the first supported one.
|
List<PublicKey> |
getEncryptionKeys()
This returns all the keys.
|
Hash |
getHash()
This must be used instead of getDestination().getHash().
|
Lease |
getLease(int index) |
int |
getLeaseCount()
Gets the number of leases in this leaseset.
|
protected SigningPublicKey |
getSigningPublicKey()
Overridden to return the blinded key so super.verifySignature() will work.
|
int |
getType()
Get the type of the data structure.
|
int |
hashCode()
the destination has enough randomness in it to use it by itself for speed
|
void |
readBytes(InputStream in)
This does NOT validate the signature
|
protected void |
readHeader(InputStream in)
Overridden because we have a blinded key, not a dest
|
protected void |
readOfflineBytes(InputStream in)
Overridden because we have a blinded key, not a dest
|
void |
setClientPrivateKey(PrivateKey privKey)
Must be set before verify for per-client auth.
|
void |
setDestination(Destination dest)
Overridden to set the blinded key.
|
void |
setSecret(String secret)
Must be set before sign or verify.
|
void |
setSigningKey(SigningPublicKey spk)
Overridden to set the blinded key.
|
void |
sign(SigningPrivateKey key)
Sign the structure using the supplied signing key.
|
void |
sign(SigningPrivateKey key,
int authType,
List<? extends SimpleDataStructure> clientKeys)
Sign the structure using the supplied signing key.
|
int |
size()
Number of bytes, NOT including signature
|
String |
toString() |
boolean |
verifyOfflineSignature()
Overridden because we have a blinded key, not a dest
|
boolean |
verifySignature()
Overridden to decrypt if possible, and verify inner sig also.
|
boolean |
verifySignature(PrivateKey clientKey)
Decrypt if possible, and verify inner sig also.
|
protected void |
writeBytesWithoutSig(OutputStream out)
Before encrypt() is called, the inner leaseset.
|
protected void |
writeHeader(OutputStream out)
Overridden because we have a blinded key, not a dest
|
protected void |
writeOfflineBytes(OutputStream out)
Overridden because we have a blinded key, not a dest
|
addEncryptionKey, addLease, getBlindedHash, getBytes, getEncryptionKey, getExpires, getOption, getOptions, getPublished, getReceivedAsPublished, getTransientExpiration, getTransientSigningKey, isBlindedWhenPublished, isCurrent, isOffline, isUnpublished, offlineSign, setBlindedHash, setBlindedWhenPublished, setOfflineSignature, setOptions, setPublished, setUnpublished, verifyOfflineSignature, writeBody, writeBytesgetDate, getDestination, getEarliestLeaseDate, getKeysAndCert, getLatestLeaseDate, getSigningKey, setEncryptionKey, setReceivedBygetReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setSignature, validateRoutingKeycalculateHash, fromBase64, fromByteArray, read, toBase64, toByteArraypublic void encrypt(int authType,
List<? extends SimpleDataStructure> clientKeys)
authType - 0, 1, or 3, see BlindDataclientKeys - The client's X25519 public or private keys, null if unusedIllegalStateExceptionpublic void encrypt(SessionKey skey)
encrypt in class LeaseSet2skey - ignoredIllegalStateExceptionpublic LeaseSet2 getDecryptedLeaseSet()
public PublicKey getEncryptionKey(Set<EncType> supported)
getEncryptionKey in class LeaseSet2supported - what return types are allowedpublic List<PublicKey> getEncryptionKeys()
LeaseSet2getEncryptionKeys in class LeaseSet2public Hash getHash()
getHash in class DatabaseEntryIllegalStateExceptionpublic Lease getLease(int index)
public int getLeaseCount()
LeaseSetgetLeaseCount in class LeaseSetprotected SigningPublicKey getSigningPublicKey()
getSigningPublicKey in class DatabaseEntrypublic int getType()
DatabaseEntrypublic int hashCode()
public void readBytes(InputStream in) throws DataFormatException, IOException
readBytes in interface DataStructurereadBytes in class LeaseSet2in - stream to read fromIllegalStateException - if called more than once or Destination already setDataFormatException - if the data is improperly formattedIOException - if there was a problem reading the streamprotected void readHeader(InputStream in) throws DataFormatException, IOException
readHeader in class LeaseSet2DataFormatExceptionIOExceptionprotected void readOfflineBytes(InputStream in) throws DataFormatException, IOException
readOfflineBytes in class LeaseSet2DataFormatExceptionIOExceptionpublic void setClientPrivateKey(PrivateKey privKey)
privKey - non-nullpublic void setDestination(Destination dest)
setDestination in class LeaseSetdest - non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519IllegalStateException - if already signedIllegalArgumentException - if not EdDSApublic void setSecret(String secret)
secret - null or "" for none (default)public void setSigningKey(SigningPublicKey spk)
setSigningKey in class LeaseSet2spk - unblinded key non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519IllegalStateException - if already signedIllegalArgumentException - if not EdDSApublic void sign(SigningPrivateKey key) throws DataFormatException
sign in class LeaseSet2IllegalStateException - if already signedDataFormatExceptionpublic void sign(SigningPrivateKey key, int authType, List<? extends SimpleDataStructure> clientKeys) throws DataFormatException
authType - 0, 1, or 3, see BlindDataclientKeys - X25519 public keys for DH, private keys for PSKIllegalStateException - if already signedDataFormatExceptionpublic boolean verifyOfflineSignature()
verifyOfflineSignature in class LeaseSet2public boolean verifySignature()
verifySignature in class LeaseSet2public boolean verifySignature(PrivateKey clientKey)
clientKey - PrivateKey for DH or PSK, or null if noneprotected void writeBytesWithoutSig(OutputStream out) throws DataFormatException, IOException
writeBytesWithoutSig in class LeaseSet2DataFormatExceptionIOExceptionprotected void writeHeader(OutputStream out) throws DataFormatException, IOException
writeHeader in class LeaseSet2DataFormatExceptionIOExceptionprotected void writeOfflineBytes(OutputStream out) throws DataFormatException, IOException
writeOfflineBytes in class LeaseSet2DataFormatExceptionIOException