<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/regress/lib/libcrypto/asn1, branch master</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=master</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2026-01-04T09:51:42+00:00</updated>
<entry>
<title>i2c_ASN1_BIT_STRING() vs ASN1_STRING_FLAG_BITS_LEFT</title>
<updated>2026-01-04T09:51:42+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-04T09:51:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=f65bd896414ed2e25bad00527fa4f1c5fabdad09'/>
<id>urn:sha1:f65bd896414ed2e25bad00527fa4f1c5fabdad09</id>
<content type='text'>
A nasty quirk in the bit string handling is that the serialization
produced by i2d_ASN1_BIT_STRING() depends on whether the the magic
ASN1_STRING_FLAG_BITS_LEFT is set.

If ASN1_STRING_FLAG_BITS_LEFT is set, the number of unused bits is
carried in a-&gt;flags &amp; 0x07 and the remainder of the bit string is
in a-&gt;data. This is terrible and undocumented but handled correctly.

If ASN1_STRING_FLAG_BITS_LEFT is not set, all trailing zero bits are
(intended to be) chopped off with all sorts of hilarious side effects.
I broke this quite thoroughly when I incorrectly ported an overflow
check from BoringSSL in:
https://github.com/openbsd/src/commit/f81cc285d2aed8b36615119a306533696f3eb66c

The result is that we currently return ret = a-&gt;length + 1 for both NULL
and non-NULL pp. The calls to asn1_ex_i2c() in asn1_i2d_ex_primitive()
thus report consistent lengths back, making it succeed.

asn1_i2d_ex_primitive() therefore skips a-&gt;length + 1 bytes, while
i2c_ASN1_BIT_STRING() only overwrites len + 1 bytes, which are possibly
fewer. So a caller passing in an output buffer containing garbage
(malloc) will get some of that garbage back in the encoding. Further,
i2c_ASN1_BIT_STRING() also advances that pointer by the possibly reduced
len + 1, but that fortunately doesn't matter since that's an effect
local to asn1_ex_i2c(), the only caller of i2c_ASN1_BIT_STRING().

The last bit is that the current behavior may set bogus unused bits
coming from the scanning backward madness. I added such an example in
the parent commit.

The fix is simple: use len after the truncation effect was established,
not the original a-&gt;length, turning this commit into what my backport
should have been.

This fixes the two currently failing regress tests, so remove expected
failure marker again.

ok jsing kenjiro
</content>
</entry>
<entry>
<title>asn1basic: add missing test from BoringSSL's test suite</title>
<updated>2026-01-04T09:43:52+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-04T09:43:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=e25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4'/>
<id>urn:sha1:e25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4</id>
<content type='text'>
This is another test that fails due to the bug in i2c_ASN1_BIT_STRING().
</content>
</entry>
<entry>
<title>asn1basic: switch test to expect correct encoding</title>
<updated>2026-01-04T09:42:32+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-04T09:42:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=d35a685166b500418ee47359c5cfcd27c97b3eae'/>
<id>urn:sha1:d35a685166b500418ee47359c5cfcd27c97b3eae</id>
<content type='text'>
This test fails, so mark the asn1basic test as an expected failure
</content>
</entry>
<entry>
<title>asn1basic: add example showing current bogus encoding</title>
<updated>2026-01-04T09:36:34+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-04T09:36:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=92a00177b1792955d45f8653ea60eb986b21c90a'/>
<id>urn:sha1:92a00177b1792955d45f8653ea60eb986b21c90a</id>
<content type='text'>
There is a bug in i2c_ASN1_BIT_STRING() resulting in nonsense encoding of
some BIT STRINGs with trailing zeroes if ASN1_STRING_FLAG_BITS_LEFT is not
set (a rare corner case). This test currently passes when it shouldn't.
</content>
</entry>
<entry>
<title>Port most of BoringSSL's TEST(ASN1Test, SetBit)</title>
<updated>2025-12-18T09:15:28+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-12-18T09:15:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=2681c4505dbb93940f461387b894b73e6ffedaff'/>
<id>urn:sha1:2681c4505dbb93940f461387b894b73e6ffedaff</id>
<content type='text'>
Exercises the batshit crazy truncation behavior of ASN1_BIT_STRING_set_bit()

Based on https://boringssl-review.googlesource.com/c/boringssl/+/48225
(still under ISC).
</content>
</entry>
<entry>
<title>asn1complex: use ASN1_STRING_get0_data() instead of ASN1_STRING_data()</title>
<updated>2025-12-07T09:35:20+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-12-07T09:35:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=b5b75e6cf83ebe9db12ceae1310ec8c4717af461'/>
<id>urn:sha1:b5b75e6cf83ebe9db12ceae1310ec8c4717af461</id>
<content type='text'>
</content>
</entry>
<entry>
<title>asn1: merge invalid generalized time tests into invalid time tests</title>
<updated>2025-05-22T04:54:14+00:00</updated>
<author>
<name>joshua</name>
<email></email>
</author>
<published>2025-05-22T04:54:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=2d4388ef345bddaf009d20ea924bb76d9d803be6'/>
<id>urn:sha1:2d4388ef345bddaf009d20ea924bb76d9d803be6</id>
<content type='text'>
Previously, invalid generalized time tests were split into a separate
set of test vectors and a flag was used when calling the test function to
indicate they should be tested as generalized only.

This simplifies the code a bit, and makes converting to the new test
framework easier.

ok jsing
</content>
</entry>
<entry>
<title>asn1object: improve error message to include returned value</title>
<updated>2025-02-26T09:57:39+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-02-26T09:57:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=472c19f8213572489b9c799c51c1c4c1f54469f9'/>
<id>urn:sha1:472c19f8213572489b9c799c51c1c4c1f54469f9</id>
<content type='text'>
From Kenjiro Nakayama
</content>
</entry>
<entry>
<title>asn1time: indicate which comparison function failed</title>
<updated>2024-07-21T13:25:11+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-07-21T13:25:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=e9d81543648b215b7a990d14f1ec580de42eff13'/>
<id>urn:sha1:e9d81543648b215b7a990d14f1ec580de42eff13</id>
<content type='text'>
extracted from a diff by Kenjiro Nakayama
</content>
</entry>
<entry>
<title>asn1object: zap trailing whitespace</title>
<updated>2024-05-29T17:23:05+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-05-29T17:23:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=48544c515c7eb12f6d6f680bd1432c6912e981e1'/>
<id>urn:sha1:48544c515c7eb12f6d6f680bd1432c6912e981e1</id>
<content type='text'>
</content>
</entry>
</feed>
