mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Merge branch 'crypto-api-code-cleanup' into 'master'
Minor code cleanups for crypto API See merge request briar/briar!1076
This commit is contained in:
@@ -1,11 +1,25 @@
|
|||||||
package org.briarproject.bramble.api.contact;
|
package org.briarproject.bramble.api.contact;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.ThreadSafe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type-safe wrapper for a byte array that uniquely identifies a
|
||||||
|
* {@link PendingContact}.
|
||||||
|
*/
|
||||||
|
@ThreadSafe
|
||||||
|
@NotNullByDefault
|
||||||
public class PendingContactId extends UniqueId {
|
public class PendingContactId extends UniqueId {
|
||||||
|
|
||||||
public PendingContactId(byte[] id) {
|
public PendingContactId(byte[] id) {
|
||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof PendingContactId && super.equals(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.briarproject.bramble.api.crypto;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Crypto operations for the key agreement protocol - see
|
* Crypto operations for the key agreement protocol - see
|
||||||
* https://code.briarproject.org/akwizgran/briar-spec/blob/master/protocols/BQP.md
|
* https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BQP.md
|
||||||
*/
|
*/
|
||||||
public interface KeyAgreementCrypto {
|
public interface KeyAgreementCrypto {
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.briarproject.bramble.api.transport.TransportKeys;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Crypto operations for the transport security protocol - see
|
* Crypto operations for the transport security protocol - see
|
||||||
* https://code.briarproject.org/akwizgran/briar-spec/blob/master/protocols/BTP.md
|
* https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BTP.md
|
||||||
*/
|
*/
|
||||||
public interface TransportCrypto {
|
public interface TransportCrypto {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.briarproject.bramble.api.transport;
|
package org.briarproject.bramble.api.transport;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.transport.TransportConstants.REORDERING_WINDOW_SIZE;
|
import static org.briarproject.bramble.api.transport.TransportConstants.REORDERING_WINDOW_SIZE;
|
||||||
|
|
||||||
@@ -8,6 +11,8 @@ import static org.briarproject.bramble.api.transport.TransportConstants.REORDERI
|
|||||||
* Contains transport keys for receiving streams from a given contact over a
|
* Contains transport keys for receiving streams from a given contact over a
|
||||||
* given transport in a given rotation period.
|
* given transport in a given rotation period.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class IncomingKeys {
|
public class IncomingKeys {
|
||||||
|
|
||||||
private final SecretKey tagKey, headerKey;
|
private final SecretKey tagKey, headerKey;
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package org.briarproject.bramble.api.transport;
|
package org.briarproject.bramble.api.transport;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains transport keys for sending streams to a given contact over a given
|
* Contains transport keys for sending streams to a given contact over a given
|
||||||
* transport in a given rotation period.
|
* transport in a given rotation period.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class OutgoingKeys {
|
public class OutgoingKeys {
|
||||||
|
|
||||||
private final SecretKey tagKey, headerKey;
|
private final SecretKey tagKey, headerKey;
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ package org.briarproject.bramble.api.transport;
|
|||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
import org.briarproject.bramble.api.plugin.TransportId;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class StreamContext {
|
public class StreamContext {
|
||||||
|
|
||||||
private final ContactId contactId;
|
private final ContactId contactId;
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package org.briarproject.bramble.api.transport;
|
package org.briarproject.bramble.api.transport;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
import org.briarproject.bramble.api.plugin.TransportId;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys for communicating with a given contact over a given transport.
|
* Keys for communicating with a given contact over a given transport.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class TransportKeys {
|
public class TransportKeys {
|
||||||
|
|
||||||
private final TransportId transportId;
|
private final TransportId transportId;
|
||||||
@@ -13,11 +18,11 @@ public class TransportKeys {
|
|||||||
|
|
||||||
public TransportKeys(TransportId transportId, IncomingKeys inPrev,
|
public TransportKeys(TransportId transportId, IncomingKeys inPrev,
|
||||||
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr) {
|
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr) {
|
||||||
if (inPrev.getRotationPeriod() != inCurr.getRotationPeriod() - 1)
|
if (inPrev.getRotationPeriod() != outCurr.getRotationPeriod() - 1)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
if (inNext.getRotationPeriod() != inCurr.getRotationPeriod() + 1)
|
if (inCurr.getRotationPeriod() != outCurr.getRotationPeriod())
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
if (outCurr.getRotationPeriod() != inCurr.getRotationPeriod())
|
if (inNext.getRotationPeriod() != outCurr.getRotationPeriod() + 1)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
this.transportId = transportId;
|
this.transportId = transportId;
|
||||||
this.inPrev = inPrev;
|
this.inPrev = inPrev;
|
||||||
|
|||||||
Reference in New Issue
Block a user