1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-23 06:42:24 +03:00
Commit Graph

13 Commits

Author SHA1 Message Date
Yuri Schimke
25814afb80 Move tls tests to Junit 5 (#6372) 2020-11-01 09:12:12 -05:00
Jesse Wilson
b1963bf8d8 Implement DER constraints on date formats (#6213)
The time zone must be 'Z', and cannot be an offset like '+0000'. That
is allowed by ASN.1 but not by DER.

Closes: https://github.com/square/okhttp/issues/6210
2020-08-05 19:50:44 -04:00
Jesse Wilson
548f601f69 Fix some issues discovered by simple fuzzing (#6181)
We were throwing IllegalArgumentException or ParseException but
want to throw only ProtocolException or EOFException.
2020-07-11 20:03:35 -04:00
Jesse Wilson
cf367d9339 Add defensive checks for malformed ASN.1 DER (#6180)
If the date is before 1950-01-01, use a four-digit year

If the self-delimiting object identifer exceeds the enclosing object's
size, fail.

If a nested object exceeds its enclosing object's size, fail.
2020-07-11 10:38:11 -04:00
Jesse Wilson
19e9a8ffd3 Drop support for indefinite length in DER (#6166)
This is a feature of ASN.1 that DER doesn't use, and in fact it forbids.
2020-07-05 08:12:29 +01:00
cketti
c04b57edac Add limits to what length values DerReader supports (#6164)
* Add limits to what length values DerReader supports

With this change DerReader doesn't support reading values with a length
greater than Long.MAX_VALUE. That shouldn't be a problem in practice.

* Make DerReader check length is encoded in shortest form possible

* Spotless and IntelliJ disagree on import order

Co-authored-by: Jesse Wilson <jesse@swank.ca>
2020-07-03 08:47:25 -04:00
Jesse Wilson
353a52b970 Improve code style for the new DER package (#6157)
Improve docs, fix some names, fix some internal APIs.
2020-06-30 06:14:49 +01:00
Jesse Wilson
45df82e15b Honor RFC 5280 when choosing a time format (#6154)
We switch to 4-digit years at the last possible moment.
2020-06-29 10:11:13 -04:00
Jesse Wilson
c3d453c1b9 Fix bugs so we can roundtrip certificates (#6151)
This gets us to the point where the byte-for-byte encoding is equiavalent
to what bouncycastle was producing.

This shook out some bugs:
 - We weren't boxing the version
 - We weren't clearing the constructed bit on boxed extensions
 - We weren't encoding null when we needed to be
2020-06-28 08:02:31 +01:00
Jesse Wilson
6e212cd7f5 Move tag management in DerAdapters (#6148)
Previously the caller was responsible for decoding the tag on the
adapter it called. This was easy for basic tags, but proved problematic
for tags like CHOICE and ANY and typehint-dependent tags, because the
caller didn't have enough information.

This moves the tag reading and writing into the DerAdapter itself. If
it encounters a tag it can't understand, it assumes it's own value has
been skipped and returns a default.

This turns out to be a bit easier to reason about, and hopefully will
make it easier to implement AlgorithmIdentifier.parameters, which has
values that are optional or not depending on what the type hint is.
2020-06-27 14:50:52 -04:00
Jesse Wilson
70f12ff56f Limited support for decoding extensions (#6145) 2020-06-25 18:51:26 -04:00
Jesse Wilson
e736f927f8 DER encoder (#6139)
I haven't yet implemented certificate encoding
2020-06-25 07:17:29 -04:00
Jesse Wilson
653a446092 Early implementation of an ASN.1 DER decoder (#6135)
* Early implementation of an ASN.1 DER decoder

My goal is to finish the implementation to support an ASN.1 DER encoder
and then to change okhttp-tls to no longer depend on BouncyCastle.

* Update okhttp-tls/src/main/kotlin/okhttp3/tls/internal/der/DerReader.kt

Co-authored-by: Benoît Quenaudon <bquenaudon@squareup.com>

Co-authored-by: Benoît Quenaudon <bquenaudon@squareup.com>
2020-06-20 20:33:59 -04:00