mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1642687 - land NSS 2bd2f3267dc5 UPGRADE_NSS_RELEASE, r=jcj
2020-06-22 Kevin Jacobs <kjacobs@mozilla.com> * lib/util/quickder.c: Bug 1646520 - Stricter leading-zero checks for ASN.1 INTEGER values. r=jcj This patch adjusts QuickDER to strictly enforce INTEGER encoding with respect to leading zeros: - If the MSB of the first (value) octet is set, a single zero byte MAY be present to make the value positive. This singular pad byte is removed. - Otherwise, the first octet must not be zero. [2bd2f3267dc5] [tip] Differential Revision: https://phabricator.services.mozilla.com/D80543
This commit is contained in:
parent
7fb8c3b457
commit
34be3870be
@ -1 +1 @@
|
||||
699541a7793b
|
||||
2bd2f3267dc5
|
@ -10,3 +10,4 @@
|
||||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
|
@ -742,15 +742,18 @@ DecodeItem(void* dest,
|
||||
switch (tagnum) {
|
||||
/* special cases of primitive types */
|
||||
case SEC_ASN1_INTEGER: {
|
||||
/* remove leading zeroes if the caller requested
|
||||
siUnsignedInteger
|
||||
This is to allow RSA key operations to work */
|
||||
SECItem* destItem = (SECItem*)((char*)dest +
|
||||
templateEntry->offset);
|
||||
if (destItem && (siUnsignedInteger == destItem->type)) {
|
||||
while (temp.len > 1 && temp.data[0] == 0) { /* leading 0 */
|
||||
/* A leading 0 is only allowed when a value
|
||||
* would otherwise be interpreted as negative. */
|
||||
if (temp.len > 1 && temp.data[0] == 0) {
|
||||
temp.data++;
|
||||
temp.len--;
|
||||
if (!(temp.data[0] & 0x80)) {
|
||||
PORT_SetError(SEC_ERROR_BAD_DER);
|
||||
rv = SECFailure;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user