Skip to content

Commit

Permalink
Add missing certification extension type LocalIntegerValueBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Feb 5, 2024
1 parent ad1566e commit a2fe39c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dist/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ class Certificate {
let kv;

let v = ext.parsedValue || ext.extnValue;
if (v.valueBlock) v = decodeValue(v.valueBlock);
try {
if (v.valueBlock) {
v = decodeValue(v.valueBlock);
}
kv = resolveOid(ext.extnID, v);
} catch (err) {
if (ext.critical === false) {
Expand Down
4 changes: 3 additions & 1 deletion dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40014,8 +40014,10 @@ class Certificate1 {
for (const ext of this._cert.extensions){
let kv;
let v = ext.parsedValue || ext.extnValue;
if (v.valueBlock) v = decodeValue(v.valueBlock);
try {
if (v.valueBlock) {
v = decodeValue(v.valueBlock);
}
kv = resolveOid(ext.extnID, v);
} catch (err) {
if (ext.critical === false) {
Expand Down
8 changes: 6 additions & 2 deletions lib/certUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ class Certificate {
let kv;

let v = ext.parsedValue || ext.extnValue;
if (v.valueBlock) v = decodeValue(v.valueBlock);
try {
if (v.valueBlock) {
v = decodeValue(v.valueBlock);
}
kv = resolveOid(ext.extnID, v);
} catch (err) {
if (ext.critical === false) {
Expand Down Expand Up @@ -284,6 +286,8 @@ function decodeValue(valueBlock) {
// console.log("blockType", blockType);
// console.log("valueBlock", valueBlock);
switch (blockType) {
case "LocalIntegerValueBlock":
return valueBlock.valueDec;
case "LocalOctetStringValueBlock":
return valueBlock.valueHex;
case "LocalUtf8StringValueBlock":
Expand Down Expand Up @@ -576,4 +580,4 @@ const helpers = {
resolveOid,
};

export { Certificate, CertManager, CRL, helpers };
export { Certificate, CertManager, CRL, helpers };
5 changes: 5 additions & 0 deletions test/certUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ describe("cert utils", function() {
assert.isTrue(u2fTransports.has("usb"));
});

it("does not throw for non-critical extensions, when unknown extension types are included", function() {
const cert = new Certificate(h.certs.certificateWithIntegerExtension);
const extensions = cert.getExtensions();
});

it("returns correct extensions for root", function() {
const cert = new Certificate(h.certs.yubicoRoot);
const extensions = cert.getExtensions();
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/fido2-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3784,12 +3784,15 @@ const tpmAttestation = new Uint8Array([

const truUCert = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNTekNDQWZLZ0F3SUJBZ0lVVzNYSzh5eXdiQVdsaWdsaXhJRjYzZHZxWXk4d0NnWUlLb1pJemowRUF3SXcKZkRFTE1Ba0dBMVVFQmhNQ1ZWTXhFVEFQQmdOVkJBZ01DRU52Ykc5eVlXUnZNUTh3RFFZRFZRUUhEQVpFWlc1MgpaWEl4RXpBUkJnTlZCQW9NQ2xSeWRWVXNJRWx1WXk0eElqQWdCZ05WQkFzTUdVRjFkR2hsYm5ScFkyRjBiM0lnClFYUjBaWE4wWVhScGIyNHhFREFPQmdOVkJBTU1CM1J5ZFhVdVlXa3dJQmNOTWpNeE1UQXpNakF6TmpVeFdoZ1AKTWpBMU16RXdNall5TURNMk5URmFNSHd4Q3pBSkJnTlZCQVlUQWxWVE1SRXdEd1lEVlFRSURBaERiMnh2Y21GawpiekVQTUEwR0ExVUVCd3dHUkdWdWRtVnlNUk13RVFZRFZRUUtEQXBVY25WVkxDQkpibU11TVNJd0lBWURWUVFMCkRCbEJkWFJvWlc1MGFXTmhkRzl5SUVGMGRHVnpkR0YwYVc5dU1SQXdEZ1lEVlFRRERBZDBjblYxTG1GcE1Ga3cKRXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVOQXZidGNjTXI3ai9TUldtcUlFWlRSV05KeWo2bXNZcgo1bEd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/wQCMAAwDQYJKoZIhvcNAQELBQADggEBAGl5dmZIe5GOHFOAvVUaWFWyet89UCHWKmLBTXXfuoPwYqatxGhVqIeiV4nAuFF127294SzJcMgzycToui5/g8OUonTvs9xWF9yH23fXjGcBWoGErlF7DqkycOz2NtjPhGwEfBnE++0/KRc/IN6bu7u/XPXNwNmCLcg0reERI23NO/ZftcWebjRBCwY3p6l0ahalKmrgqOi7bhU1AjbHmiEvJgeBcpZphS87eikierMO5PmwvdbV3okNseEoaeoHDDQ7Av6RwCtKCXwYupRs6sULgUwo0fz2znURA+zSuTzK4iZ/hmQvRVJtQBPtfpwBEmNEdwwZ1A+VxfspsYzA7AU=";

const certs = {
yubiKeyAttestation,
yubicoRoot,
feitianFido2,
tpmAttestation,
truUCert,
certificateWithIntegerExtension,
};

/** ******************************************************************************
Expand Down

0 comments on commit a2fe39c

Please sign in to comment.