MCPcopy Create free account
hub / github.com/pollinations/pollinations / derLength

Function derLength

shared/github/app-auth.ts:70–79  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

68// ---- minimal DER encoding for the PKCS#1 -> PKCS#8 wrap ----
69
70function derLength(n: number): number[] {
71 if (n < 0x80) return [n];
72 const bytes: number[] = [];
73 let v = n;
74 while (v > 0) {
75 bytes.unshift(v & 0xff);
76 v >>= 8;
77 }
78 return [0x80 | bytes.length, ...bytes];
79}
80
81function derTLV(tag: number, content: Uint8Array): Uint8Array {
82 return Uint8Array.from([tag, ...derLength(content.length), ...content]);

Callers 1

derTLVFunction · 0.85

Calls 1

unshiftMethod · 0.80

Tested by

no test coverage detected