UNPKG

@indrajala/asn1der

Version:

parse ASN.1 DER structures

124 lines 4.74 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); require("mocha"); const asn1der_1 = require("../asn1der"); const google_1 = require("./data/pem/google"); const x509FM4DD_1 = require("./data/pem/x509FM4DD"); describe('parseDER - FM4DD certs', () => __awaiter(void 0, void 0, void 0, function* () { it('it should be able to parse the FM4DD sample certs', () => __awaiter(void 0, void 0, void 0, function* () { const parsedCount = x509FM4DD_1.certs .map(cert => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(cert)).length == 1); } catch (e) { return false; } }) .filter(parsed => parsed) .length; chai_1.expect(x509FM4DD_1.certs.length) .to .equal(parsedCount); })); it('it should be able to parse the FM4DD sample csrs', () => __awaiter(void 0, void 0, void 0, function* () { const parsedCount = x509FM4DD_1.csrs .map(csr => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(csr)).length == 1); } catch (e) { console.error(e); return false; } }) .filter(parsed => parsed) .length; chai_1.expect(x509FM4DD_1.csrs.length) .to .equal(parsedCount); })); it('it should be able to parse the google HW attestation RSA TEE cert chain certs', () => __awaiter(void 0, void 0, void 0, function* () { const source = google_1.rsaTEE; const parsedCount = source .map(cert => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(cert)).length == 1); } catch (e) { console.error(e); return false; } }) .filter(parsed => parsed) .length; chai_1.expect(source.length) .to .equal(parsedCount); })); it('it should be able to parse the google HW attestation EC TEE cert chain certs', () => __awaiter(void 0, void 0, void 0, function* () { const source = google_1.ecTEE; const parsedCount = source .map(cert => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(cert)).length == 1); } catch (e) { console.error(e); return false; } }) .filter(parsed => parsed) .length; chai_1.expect(source.length) .to .equal(parsedCount); })); it('it should be able to parse the google HW attestation RSA StrongBox cert chain certs', () => __awaiter(void 0, void 0, void 0, function* () { const source = google_1.rsaStrongBox; const parsedCount = source .map(cert => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(cert)).length == 1); } catch (e) { console.error(e); return false; } }) .filter(parsed => parsed) .length; chai_1.expect(source.length) .to .equal(parsedCount); })); it('it should be able to parse the google HW attestation EC StrongBox cert chain certs', () => __awaiter(void 0, void 0, void 0, function* () { const source = google_1.ecStrongBox; const parsedCount = source .map(cert => { try { return (asn1der_1.parseDER(asn1der_1.pemToDER(cert)).length == 1); } catch (e) { console.error(e); return false; } }) .filter(parsed => parsed) .length; chai_1.expect(source.length) .to .equal(parsedCount); })); })); //# sourceMappingURL=parseDER.bulk.spec.js.map