Comments (7)
I don't believe TlsUtils,readUint16 can return a negative value, the problem must be elsewhere. There are quite a few checks on the record sanity in RecordStream.readRecord, let me know if you think some check is missing there. I have to guess perhaps you are using offerInput by passing a fixed buffer to each call (see javadoc for why that would be a problem).
We're keen to fix this if there's an error, but I think we'll need a small test case that shows the problem.
from bc-java.
Hello @peterdettman , thank you for your quick reply. At my machine this unit test always fails. It seems to fit your hint with the fixed buffer, but I really see no other way for using this method.
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bouncycastle.crypto.tls.TlsProtocol;
import org.bouncycastle.crypto.tls.TlsServerProtocol;
import org.junit.Assert;
import org.junit.Test;
public class BouncyCastleTlsProtocolTest {
private static final Logger LOG = LogManager.getLogger();
private final TlsProtocol protocol = new TlsServerProtocol(null);
private final Random random = new Random();
@Test(expected = IOException.class)
public void tlsProtocolTest() throws IOException {
byte[] bytes;
for (int i = 0; i < 1000; i++) {
bytes = new byte[3];
this.random.nextBytes(bytes);
this.protocol.offerInput(bytes);
}
}
}
from bc-java.
Hello BC team, this is still an issue for me. @peterdettman was right, I do use org.bouncycastle.crypto.tls.TlsProtocol.offerInput(byte[])
to offer my received data to the TLS protocol. But I really do not understand, what @peterdettman means with his hint on "passing a fixed buffer to each call" is a problem. Can someone please explain this to me? How can the input byte array not be a fixed buffer? How is this method supposed to be used? I read all the tests and javadoc but I just don't get it - sorry for this.
from bc-java.
I found the reason of my problem. Example: if the 4th and 5th byte are set to 0xFF the TLS protocol calculates a total length of 65540 bytes for the first TLS record. Only after actually receiving 65540 bytes TLS protocol goest into safeReadRecord();
which then throws an exception.
I expected TLS protocol to be more strict. I expected you can not send any non-TLS data to TLS protocol without instant termination. What do you think about this? Is it worth changing?
from bc-java.
So I can see now the problem that TlsProtocol.offerInput is not applying the same immediate checks to the TLS record header fields (once it has them) that RecordStream does. We will fix this aspect.
I'm still unclear if you meant something more than that by "strict".
from bc-java.
Yes @peterdettman, with "strict" I just meant an earlier check of received data against protocol specifications. Thank you for your quick reply and the fixing notice.
from bc-java.
Fixed in our git, should be mirrored here soon.
Basically, if we don't yet have a full record, but we do have the full record header, then we will validate the header fields. This matches the behaviour of blocking-mode.
from bc-java.
Related Issues (20)
- Converting Ed25519, Ed448 keys fails if encoding has leading 0 HOT 1
- When gradle `plugin` transitive dependency: Unsupported class file major version 65 HOT 1
- New version of bouncy castle library generates inordinate number INFO Logging messages - ProvTlsServer handshaking
- Wrong ASN1 encoding of RSASSAPSSparams HOT 4
- https://www.bouncycastle.org/ is down HOT 1
- Feature Request: Private Key Offloading HOT 7
- .jar filename has a different version after build HOT 1
- org.bouncycastle.crypto.fips.FipsOperationError: Module checksum failed: expected [9f6751f059ab42f7d83e4e107881438036787e1e1821cd23a53c4b8181cc300f] got [db22a19266bc3d8485b00ed8fa24f2454b584bed02a365701c8900037d86099e] HOT 1
- TlsFatalAlert: internal_error(80) at JcaTlsRSASigner.generateRawSignature with custom RSA provider
- java.lang.NoClassDefFoundError: org/bouncycastle/util/Pack
- Caused by: java.lang.ClassNotFoundException: Didn't find class "org.bouncycastle.jce.provider.BouncyCastleProvider"
- Support configuring signature_algorithms_cert extension which differ from signature_algorithms extension HOT 1
- Support creating CMSSignedDataParser
- org.bouncycastle.tls.TlsFatalAlertReceived: access_denied(49) HOT 1
- PGP test fails HOT 1
- Add support for parsing passphrase protected OpenSSH keys
- Dilithium3 signatures not compliant to fips204 Table 2. HOT 4
- Support rfc9579 in PKCS12 keystores (and in FIPS mode)
- `BCrypt.generate(...)` is error-prone HOT 1
- Incorrect determination of expire date
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bc-java.