Closed Bug 572289 Opened 16 years ago Closed 15 years ago

SEC_ASN1EncodeInteger cannot correctly encode some integer values

Categories

(NSS :: Libraries, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED
3.12.10

People

(Reporter: nelson, Assigned: nelson)

References

Details

Attachments

(1 file, 3 obsolete files)

SEC_ASN1EncodeInteger cannot correctly encode integers in these ranges: 0x00000080-0x000000ff 0x00008000-0x0000ffff 0x00800000-0x00ffffff It incorrectly concludes that those numbers are negative numbers. It does not ensure that a zero byte is placed in front of them in the encoding to keep them positive.
Attached patch Patch v1 for NSS trunk (obsolete) — — Splinter Review
This seems to fix the problem, but I want to make sure it causes no regressions before requesting review.
Attached patch Patch v2 for NSS trunk (obsolete) — — Splinter Review
This is even better.
Attachment #451487 - Attachment is obsolete: true
Target Milestone: 3.12.7 → 3.12.9
Another (minor?) problem with SEC_ASN1EncodeInteger is that it doesn't encode negative values in the minimum number of octets. For example, -129 should be encoded as the following value octets: FF 7F But SEC_ASN1EncodeInteger encodes -129 as the following value octects on a 32-bit system: FF FF FF 7F Similarly, -128 should be 80 but is encoded as FF FF FF 80
Attached patch Patch v4 — — Splinter Review
Fix the incorrect encoding of a nonnegative value. Fix a confusing comment that seems to imply there is an *unsigned* DER encoding of INTEGER. The 'make_unsigned' parameter is renamed 'is_unsigned' to suggest that it means the 'value' argument is truly an unsigned type. (Perhaps 'value_is_unsigned' or even 'value_is_signed', with the opposite sense, is a better name.) I also added a test program.
Attachment #451476 - Attachment is obsolete: true
Attachment #451498 - Attachment is obsolete: true
Attachment #503244 - Flags: superreview?(rrelyea)
Attachment #503244 - Flags: review?(nelson)
Target Milestone: 3.12.9 → 3.12.10
Comment on attachment 503244 [details] [diff] [review] Patch v4 I like this MUCH better than my previous patch! Thanks.
Attachment #503244 - Flags: review?(nelson) → review+
Patch checked in on the NSS trunk (NSS 3.13). Checking in lib/util/secasn1e.c; /cvsroot/mozilla/security/nss/lib/util/secasn1e.c,v <-- secasn1e.c new revision: 1.22; previous revision: 1.21 done RCS file: /cvsroot/mozilla/security/nss/cmd/tests/encodeinttest.c,v done Checking in cmd/tests/encodeinttest.c; /cvsroot/mozilla/security/nss/cmd/tests/encodeinttest.c,v <-- encodeinttest.c initial revision: 1.1 done Checking in cmd/tests/manifest.mn; /cvsroot/mozilla/security/nss/cmd/tests/manifest.mn,v <-- manifest.mn new revision: 1.10; previous revision: 1.9 done The bug fix (but not the test program) checked in on the NSS_3_12_BRANCH (3.12.10). Checking in secasn1e.c; /cvsroot/mozilla/security/nss/lib/util/secasn1e.c,v <-- secasn1e.c new revision: 1.21.66.1; previous revision: 1.21 done Filed bug 625239 for the problem I described in comment 5.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Attachment #503244 - Flags: superreview?(rrelyea)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: