Commit ff2f7104 authored by Torsten Grote's avatar Torsten Grote

Merge branch 'crypto-api-code-cleanup' into 'master'

Minor code cleanups for crypto API

See merge request !1076
parents d00094ed 68c40f0c
Pipeline #3190 passed with stage
in 9 minutes and 49 seconds
package org.briarproject.bramble.api.contact;
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 PendingContactId(byte[] 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
* 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 {
......
......@@ -5,7 +5,7 @@ import org.briarproject.bramble.api.transport.TransportKeys;
/**
* 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 {
......
package org.briarproject.bramble.api.transport;
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;
......@@ -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
* given transport in a given rotation period.
*/
@Immutable
@NotNullByDefault
public class IncomingKeys {
private final SecretKey tagKey, headerKey;
......
package org.briarproject.bramble.api.transport;
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
* transport in a given rotation period.
*/
@Immutable
@NotNullByDefault
public class OutgoingKeys {
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.crypto.SecretKey;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.plugin.TransportId;
import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class StreamContext {
private final ContactId contactId;
......
package org.briarproject.bramble.api.transport;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.plugin.TransportId;
import javax.annotation.concurrent.Immutable;
/**
* Keys for communicating with a given contact over a given transport.
*/
@Immutable
@NotNullByDefault
public class TransportKeys {
private final TransportId transportId;
......@@ -13,11 +18,11 @@ public class TransportKeys {
public TransportKeys(TransportId transportId, IncomingKeys inPrev,
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr) {
if (inPrev.getRotationPeriod() != inCurr.getRotationPeriod() - 1)
if (inPrev.getRotationPeriod() != outCurr.getRotationPeriod() - 1)
throw new IllegalArgumentException();
if (inNext.getRotationPeriod() != inCurr.getRotationPeriod() + 1)
if (inCurr.getRotationPeriod() != outCurr.getRotationPeriod())
throw new IllegalArgumentException();
if (outCurr.getRotationPeriod() != inCurr.getRotationPeriod())
if (inNext.getRotationPeriod() != outCurr.getRotationPeriod() + 1)
throw new IllegalArgumentException();
this.transportId = transportId;
this.inPrev = inPrev;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment