Skip to content

Commit 77fcd13

Browse files
samspychergrealish
authored andcommitted
Add NONEwithRSA MessageDigest and incorporate typecast for Buffer methods
1 parent 9ab564a commit 77fcd13

File tree

7 files changed

+852
-11
lines changed

7 files changed

+852
-11
lines changed

parsec-client-java/src/main/java/org/parallaxsecond/parsec/client/jna/UnixSocketChannel.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.NonNull;
66
import lombok.extern.slf4j.Slf4j;
77

8+
import java.nio.Buffer;
89
import java.nio.ByteBuffer;
910
import java.nio.channels.ByteChannel;
1011
import java.nio.file.Files;
@@ -36,7 +37,7 @@ public int read(ByteBuffer dst) {
3637
while (read < toRead) {
3738
read += (int) UnixSocket.readSocket(this.socket, dst, toRead - read);
3839
log.debug("expected: {}, read: {}", toRead, read);
39-
dst.position(pos + read);
40+
((Buffer)dst).position(pos + read);
4041
}
4142
return toRead;
4243
}
@@ -48,7 +49,7 @@ public int write(ByteBuffer src) {
4849
int pos = src.position();
4950
while (written < toWrite) {
5051
written += (int) UnixSocket.writeSocket(socket, src, toWrite - written);
51-
src.position(pos + written);
52+
((Buffer)src).position(pos + written);
5253
}
5354
return written;
5455
}

parsec-interface-java/src/main/java/org/parallaxsecond/parsec/protocol/requests/request/RequestBody.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import lombok.RequiredArgsConstructor;
55

66
import java.io.IOException;
7+
import java.nio.Buffer;
78
import java.nio.ByteBuffer;
89
import java.nio.ByteOrder;
910
import java.nio.channels.ReadableByteChannel;
@@ -21,7 +22,7 @@ public static RequestBody readFromStream(ReadableByteChannel channel, int len)
2122
throws IOException {
2223
ByteBuffer buf = ByteBuffer.allocate(len).order(ByteOrder.LITTLE_ENDIAN);
2324
channel.read(buf);
24-
buf.flip();
25+
((Buffer)buf).flip();
2526
return new RequestBody(buf);
2627
}
2728

parsec-interface-java/src/main/java/org/parallaxsecond/parsec/protocol/requests/request/common/WireHeader_1_0.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static WireHeader_1_0 readFromStream(ReadableByteChannel channel) throws
6363
ByteBuffer buf = ByteBuffer.allocate(REQUEST_HDR_SIZE + 6).order(ByteOrder.LITTLE_ENDIAN);
6464

6565
channel.read(buf);
66-
buf.flip();
66+
((Buffer)buf).flip();
6767

6868
int magicNumber = buf.getInt();
6969
if (magicNumber != MAGIC_NUMBER) {

parsec-interface-java/src/main/java/org/parallaxsecond/parsec/protocol/requests/response/ResponseBody.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.extern.slf4j.Slf4j;
66

77
import java.io.IOException;
8+
import java.nio.Buffer;
89
import java.nio.ByteBuffer;
910
import java.nio.ByteOrder;
1011
import java.nio.channels.ReadableByteChannel;
@@ -27,8 +28,8 @@ public static ResponseBody readFromStream(ReadableByteChannel channel, int len)
2728
if (read != len) {
2829
log.warn("expected to read {} but only got {}", len, read);
2930
}
30-
buf.flip();
31-
buf.limit(Math.min(len, read));
31+
((Buffer)buf).flip();
32+
((Buffer)buf).limit(Math.min(len, read));
3233

3334
return new ResponseBody(buf.slice());
3435
}

parsec-jca-java/src/main/java/org/parallaxsecond/parsec/jce/provider/ParsecRsaSignature.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ public enum ParsecRsaSignature implements ParsecSignatureInfo {
2020
NONE_WITH_RSA("NONEwithRSA",
2121
pkcs1(),
2222
() -> new MessageDigest("NONE"){
23-
byte input0;
24-
byte[] input1;
23+
byte[] input;
2524
@Override
2625
protected void engineUpdate(byte input) {
27-
this.input0 = input;
26+
throw new UnsupportedOperationException("not implemented");
2827
}
2928

3029
@Override
3130
protected void engineUpdate(byte[] input, int offset, int len) {
32-
this.input1 = input;
31+
32+
this.input = input;
3333
}
3434

3535
@Override
36-
protected byte[] engineDigest() {return input1;}
36+
protected byte[] engineDigest() {
37+
return input;}
3738

3839
@Override
3940
protected void engineReset() {}
Binary file not shown.

tmp/hs_err_pid1.log

+837
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)