Skip to content

Commit

Permalink
repaired some obvious errors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thsc42 committed Nov 1, 2020
1 parent f96c8c5 commit 52d836d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/net/sharksystem/asap/protocol/ASAP_1_0.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
* Descriptions of ASAP protocol data units and some constants
*/
public interface ASAP_1_0 {
int CMD_MASK = 0x7; // 0111
int ENCRYPTED_MASK = 0x1; // 0001
byte ENCRYPTED_CMD = 1;

int CMD_MASK = 0x6; // 0110 - first bit tells if encrypted or not
byte OFFER_CMD = 0;
byte INTEREST_CMD = 2;
byte ASSIMILATE_CMD = 4;

int ENCRYPTED_MASK = 0x1; // 0001
byte ENCRYPTED_CMD = 1;
String ANY_FORMAT = "ASAP_ANY_FORMAT";
String ASAP_MANAGEMENT_FORMAT = "asap/control";
int ERA_NOT_DEFINED = -1;
Expand Down
22 changes: 11 additions & 11 deletions src/net/sharksystem/asap/protocol/ASAP_Modem_Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

public class ASAP_Modem_Impl implements ASAP_1_0 {
private final BasicKeyStore signAndEncryptionKeyStorage;
private final ASAPUndecryptableMessageHandler unencryptableMessageHandler;
private final ASAPUndecryptableMessageHandler undecryptableMessageHandler;

public ASAP_Modem_Impl() {
this(null, null);
}

public ASAP_Modem_Impl(ASAPUndecryptableMessageHandler unencryptableMessageHandler) {
this(null, unencryptableMessageHandler);
public ASAP_Modem_Impl(ASAPUndecryptableMessageHandler undecryptableMessageHandler) {
this(null, undecryptableMessageHandler);
}

public ASAP_Modem_Impl(BasicKeyStore signAndEncryptionKeyStorage) {
this(signAndEncryptionKeyStorage, null);
}

public ASAP_Modem_Impl(BasicKeyStore signAndEncryptionKeyStorage,
ASAPUndecryptableMessageHandler unencryptableMessageHandler) {
ASAPUndecryptableMessageHandler undecryptableMessageHandler) {
this.signAndEncryptionKeyStorage = signAndEncryptionKeyStorage;
this.unencryptableMessageHandler = unencryptableMessageHandler;
this.undecryptableMessageHandler = undecryptableMessageHandler;
}

// Character are transmitted as bytes: number of bytes (first byte), content following, 0 mean no content
Expand Down Expand Up @@ -184,17 +184,17 @@ public ASAP_PDU_1_0 readPDU(InputStream is) throws IOException, ASAPException {
InputStream decryptedIS = cryptoMessage.doDecryption();
is = decryptedIS;
} else {
// we cannot decrypt this message - we are not recipient - but we keep and redistribute
// we cannot decrypt this message - we are not recipient - but we can keep and redistribute it
ASAPCryptoAlgorithms.EncryptedMessagePackage encryptedASAPMessage = cryptoMessage.getEncryptedMessage();
if(this.unencryptableMessageHandler != null) {
System.out.println(this.getLogStart() + "call handler to handle unencryptable message");
this.unencryptableMessageHandler.handleUndecryptableMessage(
if(this.undecryptableMessageHandler != null) {
System.out.println(this.getLogStart() + "call handler to handle undecryptable message");
this.undecryptableMessageHandler.handleUndecryptableMessage(
encryptedASAPMessage, cryptoMessage.getReceiver());
} else {
System.out.println(this.getLogStart() + "no handler for unencryptable messages found");
System.out.println(this.getLogStart() + "no handler for undecryptable messages found");
}
// throw exception anyway - could not create PDU
throw new ASAPSecurityException("unencryptable message received");
throw new ASAPSecurityException("undecryptable message received");
}
}

Expand Down

0 comments on commit 52d836d

Please sign in to comment.