public class EncryptedLeaseSet extends LeaseSet2
_expires, _flags, _offlineSignature, _options, _published, _transientExpires, _transientSigningPublicKey
_byteified, _checked, _destination, _encryptionKey, _lastExpiration, _leases, _receivedAsPublished, _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() |
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, getPublished, getReceivedAsPublished, getTransientSigningKey, isBlindedWhenPublished, isCurrent, isOffline, isUnpublished, offlineSign, setBlindedHash, setBlindedWhenPublished, setOfflineSignature, setOptions, setUnpublished, verifyOfflineSignature, writeBody, writeBytes
getDate, getDestination, getEarliestLeaseDate, getKeysAndCert, getLatestLeaseDate, getReceivedAsReply, getReceivedBy, getSigningKey, setEncryptionKey, setReceivedAsPublished, setReceivedAsReply, setReceivedBy, verifySignature
getRoutingKey, getSignature, isLeaseSet, isLeaseSet, setSignature, validateRoutingKey
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
public LeaseSet2 getDecryptedLeaseSet()
public void setSecret(String secret)
secret
- null or "" for none (default)public void setClientPrivateKey(PrivateKey privKey)
privKey
- non-nullpublic int getType()
DatabaseEntry
public int getLeaseCount()
getLeaseCount
in class LeaseSet
public Lease getLease(int index)
public List<PublicKey> getEncryptionKeys()
LeaseSet2
getEncryptionKeys
in class LeaseSet2
public PublicKey getEncryptionKey(Set<EncType> supported)
getEncryptionKey
in class LeaseSet2
supported
- what return types are allowedpublic void setDestination(Destination dest)
setDestination
in class LeaseSet
dest
- non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519IllegalStateException
- if already signedIllegalArgumentException
- if not EdDSApublic void setSigningKey(SigningPublicKey spk)
setSigningKey
in class LeaseSet2
spk
- unblinded key non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519IllegalStateException
- if already signedIllegalArgumentException
- if not EdDSAprotected SigningPublicKey getSigningPublicKey()
getSigningPublicKey
in class DatabaseEntry
public void readBytes(InputStream in) throws DataFormatException, IOException
readBytes
in interface DataStructure
readBytes
in class LeaseSet2
in
- 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 writeBytesWithoutSig(OutputStream out) throws DataFormatException, IOException
writeBytesWithoutSig
in class LeaseSet2
DataFormatException
IOException
public boolean verifyOfflineSignature()
verifyOfflineSignature
in class LeaseSet2
protected void readHeader(InputStream in) throws DataFormatException, IOException
readHeader
in class LeaseSet2
DataFormatException
IOException
protected void writeHeader(OutputStream out) throws DataFormatException, IOException
writeHeader
in class LeaseSet2
DataFormatException
IOException
protected void readOfflineBytes(InputStream in) throws DataFormatException, IOException
readOfflineBytes
in class LeaseSet2
DataFormatException
IOException
protected void writeOfflineBytes(OutputStream out) throws DataFormatException, IOException
writeOfflineBytes
in class LeaseSet2
DataFormatException
IOException
public Hash getHash()
getHash
in class DatabaseEntry
IllegalStateException
public void encrypt(SessionKey skey)
encrypt
in class LeaseSet2
skey
- ignoredIllegalStateException
public 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 unusedIllegalStateException
public void sign(SigningPrivateKey key) throws DataFormatException
sign
in class LeaseSet2
IllegalStateException
- if already signedDataFormatException
public 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 signedDataFormatException
public boolean verifySignature()
verifySignature
in class LeaseSet2
public boolean verifySignature(PrivateKey clientKey)
clientKey
- PrivateKey for DH or PSK, or null if nonepublic int hashCode()