Initial Commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { UNIVERSAL_TAGS } from "../asn1/asn1.types.js";
|
||||
import { encodeAsn1, makePrimitive } from "../asn1/encoder.js";
|
||||
import { X509Error } from "../errors/error-codes.js";
|
||||
import { decodeSubjectKeyIdentifier } from "./subject-key-id.js";
|
||||
|
||||
describe("decodeSubjectKeyIdentifier", () => {
|
||||
it("decodes SKI keyIdentifier byte-identically", { timeout: 5000 }, () => {
|
||||
const ki = new Uint8Array(20).fill(0x5a);
|
||||
const der = encodeAsn1(
|
||||
makePrimitive("universal", UNIVERSAL_TAGS.OCTET_STRING, ki)
|
||||
);
|
||||
const ski = decodeSubjectKeyIdentifier(der);
|
||||
expect(Array.from(ski.keyIdentifier)).toEqual(Array.from(ki));
|
||||
});
|
||||
|
||||
it("rejects non-OCTET-STRING input", { timeout: 5000 }, () => {
|
||||
expect(() =>
|
||||
decodeSubjectKeyIdentifier(new Uint8Array([0x02, 0x01, 0x00]))
|
||||
).toThrowError(X509Error);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user