mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Null safety cleanups.
This commit is contained in:
@@ -42,6 +42,7 @@ import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_AUTH;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_RESPONSES;
|
||||
@@ -453,15 +454,13 @@ class IntroduceeProtocolEngine
|
||||
localAuthor.getId());
|
||||
|
||||
// add the keys to the new contact
|
||||
//noinspection ConstantConditions
|
||||
keys = keyManager
|
||||
.addContact(txn, c.getId(), new SecretKey(s.getMasterKey()),
|
||||
timestamp, s.getLocal().alice, false);
|
||||
keys = keyManager.addContact(txn, c.getId(),
|
||||
new SecretKey(requireNonNull(s.getMasterKey())),
|
||||
timestamp, s.getLocal().alice, false);
|
||||
|
||||
// add signed transport properties for the contact
|
||||
//noinspection ConstantConditions
|
||||
transportPropertyManager.addRemoteProperties(txn, c.getId(),
|
||||
s.getRemote().transportProperties);
|
||||
requireNonNull(s.getRemote().transportProperties));
|
||||
|
||||
// Broadcast IntroductionSucceededEvent, because contact got added
|
||||
IntroductionSucceededEvent e = new IntroductionSucceededEvent(c);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.security.GeneralSecurityException;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_ACTIVATE_MAC;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_ALICE_MAC_KEY;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_AUTH_MAC;
|
||||
@@ -71,13 +72,12 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public SecretKey deriveMasterKey(IntroduceeSession s)
|
||||
throws GeneralSecurityException {
|
||||
return deriveMasterKey(
|
||||
s.getLocal().ephemeralPublicKey,
|
||||
s.getLocal().ephemeralPrivateKey,
|
||||
s.getRemote().ephemeralPublicKey,
|
||||
requireNonNull(s.getLocal().ephemeralPublicKey),
|
||||
requireNonNull(s.getLocal().ephemeralPrivateKey),
|
||||
requireNonNull(s.getRemote().ephemeralPublicKey),
|
||||
s.getLocal().alice
|
||||
);
|
||||
}
|
||||
@@ -109,7 +109,6 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public byte[] authMac(SecretKey macKey, IntroduceeSession s,
|
||||
AuthorId localAuthorId) {
|
||||
// the macKey is not yet available in the session at this point
|
||||
@@ -129,10 +128,9 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void verifyAuthMac(byte[] mac, IntroduceeSession s,
|
||||
AuthorId localAuthorId) throws GeneralSecurityException {
|
||||
verifyAuthMac(mac, new SecretKey(s.getRemote().macKey),
|
||||
verifyAuthMac(mac, new SecretKey(requireNonNull(s.getRemote().macKey)),
|
||||
s.getIntroducer().getId(), localAuthorId, s.getLocal(),
|
||||
s.getRemote().author.getId(), s.getRemote());
|
||||
}
|
||||
@@ -148,7 +146,6 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private byte[] getAuthMacInputs(AuthorId introducerId,
|
||||
AuthorId localAuthorId, Common local, AuthorId remoteAuthorId,
|
||||
Common remote) {
|
||||
@@ -156,13 +153,15 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
localAuthorId,
|
||||
local.acceptTimestamp,
|
||||
local.ephemeralPublicKey,
|
||||
clientHelper.toDictionary(local.transportProperties)
|
||||
clientHelper.toDictionary(requireNonNull(
|
||||
local.transportProperties))
|
||||
);
|
||||
BdfList remoteInfo = BdfList.of(
|
||||
remoteAuthorId,
|
||||
remote.acceptTimestamp,
|
||||
remote.ephemeralPublicKey,
|
||||
clientHelper.toDictionary(remote.transportProperties)
|
||||
clientHelper.toDictionary(requireNonNull(
|
||||
remote.transportProperties))
|
||||
);
|
||||
BdfList macList = BdfList.of(
|
||||
introducerId,
|
||||
@@ -187,10 +186,9 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void verifySignature(byte[] signature, IntroduceeSession s)
|
||||
throws GeneralSecurityException {
|
||||
SecretKey macKey = new SecretKey(s.getRemote().macKey);
|
||||
SecretKey macKey = new SecretKey(requireNonNull(s.getRemote().macKey));
|
||||
verifySignature(macKey, s.getRemote().author.getPublicKey(), signature);
|
||||
}
|
||||
|
||||
|
||||
@@ -1309,13 +1309,10 @@ public class IntroductionIntegrationTest
|
||||
Message m = ch.getMessage(id);
|
||||
BdfList body = ch.getMessageAsList(id);
|
||||
if (type == ACCEPT) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseAcceptMessage(m, body);
|
||||
} else if (type == DECLINE) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseDeclineMessage(m, body);
|
||||
} else if (type == AUTH) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseAuthMessage(m, body);
|
||||
} else throw new AssertionError("Not implemented");
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ public class PrivateGroupManagerIntegrationTest
|
||||
addGroup();
|
||||
|
||||
// create and add test message with no previousMsgId
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
GroupMessage msg = groupMessageFactory
|
||||
.createGroupMessage(groupId0, clock.currentTimeMillis(), null,
|
||||
author0, "test", null);
|
||||
|
||||
Reference in New Issue
Block a user