Search in sources :

Example 16 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class ActiveProfileBlock method getData.

@Override
public byte[] getData() {
    ByteBuf byteBuf = new ByteBuf(2);
    byteBuf.putShort(activeProfile.getValue());
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 17 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class AppLayerProcessor method onInboundMessage.

@Override
public void onInboundMessage(Object message, Pipeline pipeline) throws Exception {
    if (!(message instanceof DataMessage))
        return;
    DataMessage dataMessage = (DataMessage) message;
    ByteBuf byteBuf = new ByteBuf(dataMessage.getData().length);
    byteBuf.putBytes(dataMessage.getData());
    AppLayerMessage appLayerMessage = AppLayerMessage.deserialize(byteBuf);
    Log.d("SightService", "RECEIVE: " + appLayerMessage.getClass());
    pipeline.receive(appLayerMessage);
    Answers.getInstance().logCustom(new CustomEvent("Received Application Layer Message").putCustomAttribute("Message", appLayerMessage.getClass().getSimpleName()));
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) AppLayerMessage(sugar.free.sightparser.applayer.messages.AppLayerMessage) DataMessage(sugar.free.sightparser.authlayer.DataMessage) ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 18 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class AuthLayerProcessor method onInboundMessage.

@Override
public void onInboundMessage(Object message, Pipeline pipeline) throws Exception {
    if (!(message instanceof ByteBuf))
        return;
    ByteBuf data = (ByteBuf) message;
    while (data.size() >= 37) {
        int length = data.getUInt16LE(4);
        if (data.size() < length + 8)
            return;
        try {
            AuthLayerMessage authLayerMessage = AuthLayerMessage.deserialize(data, pipeline.getLastNonceReceived(), pipeline.getDerivedKeys() != null ? pipeline.getDerivedKeys().getIncomingKey() : null);
            pipeline.setLastNonceReceived(authLayerMessage.getNonce());
            pipeline.setCommID(authLayerMessage.getCommID());
            pipeline.receive(authLayerMessage);
        } catch (InvalidNonceError | InvalidAuthCRCError | InvalidTrailerError e) {
            data.shift(data.size());
            throw e;
        }
    }
}
Also used : AuthLayerMessage(sugar.free.sightparser.authlayer.AuthLayerMessage) CRCAuthLayerMessage(sugar.free.sightparser.authlayer.CRCAuthLayerMessage) InvalidNonceError(sugar.free.sightparser.error.InvalidNonceError) InvalidAuthCRCError(sugar.free.sightparser.error.InvalidAuthCRCError) ByteBuf(sugar.free.sightparser.pipeline.ByteBuf) InvalidTrailerError(sugar.free.sightparser.error.InvalidTrailerError)

Example 19 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class ByteProcessor method onOutboundMessage.

@Override
public void onOutboundMessage(Object message, Pipeline pipeline) throws Exception {
    if (!(message instanceof ByteBuf))
        return;
    ByteBuf data = (ByteBuf) message;
    while (data.size() > 0) {
        pipeline.getOutputStream().write(data.readBytes(data.size() >= 110 ? 110 : data.size()));
        pipeline.getOutputStream().flush();
    }
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 20 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class Cryptograph method produceCCMPrimitive.

private static byte[] produceCCMPrimitive(byte headerByte, byte[] nonce, short number) {
    ByteBuf byteBuf = new ByteBuf(16);
    byteBuf.putByte(headerByte);
    byteBuf.putBytes(nonce);
    byteBuf.putShort(number);
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Aggregations

ByteBuf (sugar.free.sightparser.pipeline.ByteBuf)35 SuppressLint (android.annotation.SuppressLint)3 InvalidAuthCRCError (sugar.free.sightparser.error.InvalidAuthCRCError)2 InvalidNonceError (sugar.free.sightparser.error.InvalidNonceError)2 InvalidTrailerError (sugar.free.sightparser.error.InvalidTrailerError)2 CustomEvent (com.crashlytics.android.answers.CustomEvent)1 BigInteger (java.math.BigInteger)1 HistoryFrame (sugar.free.sightparser.applayer.descriptors.history_frames.HistoryFrame)1 AppLayerMessage (sugar.free.sightparser.applayer.messages.AppLayerMessage)1 AuthLayerMessage (sugar.free.sightparser.authlayer.AuthLayerMessage)1 CRCAuthLayerMessage (sugar.free.sightparser.authlayer.CRCAuthLayerMessage)1 DataMessage (sugar.free.sightparser.authlayer.DataMessage)1 InvalidAppCRCError (sugar.free.sightparser.error.InvalidAppCRCError)1 InvalidAppVersionError (sugar.free.sightparser.error.InvalidAppVersionError)1 InvalidAuthVersionError (sugar.free.sightparser.error.InvalidAuthVersionError)1 UnknownAppErrorCodeError (sugar.free.sightparser.error.UnknownAppErrorCodeError)1 UnknownAppMessageError (sugar.free.sightparser.error.UnknownAppMessageError)1 UnknownAuthMessageError (sugar.free.sightparser.error.UnknownAuthMessageError)1 UnknownServiceError (sugar.free.sightparser.error.UnknownServiceError)1