Skip to content

Commit f42bd2d

Browse files
Added EmbeddedSignatureBlob component method
1 parent daf9bd2 commit f42bd2d

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

Security/CodeSigning/sigblob.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assertEquals, assertInstanceOf } from '@std/assert';
2-
import { PLBoolean, PLDictionary } from '@hqtsm/plist';
2+
import { PLBoolean, PLData, PLDictionary } from '@hqtsm/plist';
33
import { assertThrowsMacOSError } from '../../spec/assert.ts';
44
import {
55
CPU_ARCHITECTURES,
@@ -171,6 +171,38 @@ Deno.test('EmbeddedSignatureBlob: blobData', () => {
171171
}, errSecCSSignatureInvalid);
172172
});
173173

174+
Deno.test('EmbeddedSignatureBlob: component', () => {
175+
{
176+
const maker = new EmbeddedSignatureBlob_Maker();
177+
const made = EmbeddedSignatureBlob_Maker.make(maker);
178+
const component = EmbeddedSignatureBlob.component(
179+
made,
180+
cdSignatureSlot,
181+
);
182+
assertEquals(component, null);
183+
}
184+
{
185+
const maker = new EmbeddedSignatureBlob_Maker();
186+
const filler = new ArrayBuffer(16);
187+
for (let a = new Uint8Array(filler), i = filler.byteLength; i--;) {
188+
a[i] = i;
189+
}
190+
const blob = new BlobCore(filler);
191+
BlobCore.initialize(blob, cdRequirementsSlot, filler.byteLength);
192+
EmbeddedSignatureBlob_Maker.add(maker, cdRequirementsSlot, blob);
193+
const made = EmbeddedSignatureBlob_Maker.make(maker);
194+
const component = EmbeddedSignatureBlob.component(
195+
made,
196+
cdRequirementsSlot,
197+
);
198+
assertInstanceOf(component, PLData);
199+
assertEquals(
200+
new Uint8Array(component.buffer),
201+
new Uint8Array(filler),
202+
);
203+
}
204+
});
205+
174206
Deno.test('EmbeddedSignatureBlob: fixtures', async () => {
175207
const signedFictures = fixtures.filter((f) =>
176208
[...f.archs.values()].filter(Boolean).length

Security/CodeSigning/sigblob.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ export class EmbeddedSignatureBlob<
5959
MacOSError.throwMe(errSecCSSignatureInvalid);
6060
}
6161

62+
/**
63+
* Find blob data for slot.
64+
*
65+
* @param _this This.
66+
* @param slot Slot.
67+
* @returns Blob data or null.
68+
*/
69+
public static component(
70+
_this: EmbeddedSignatureBlob,
71+
slot: CodeDirectory_SpecialSlot,
72+
): PLData | null {
73+
const blob = EmbeddedSignatureBlob.find(_this, slot);
74+
if (blob) {
75+
return EmbeddedSignatureBlob.blobData(slot, blob);
76+
}
77+
return null;
78+
}
79+
6280
static {
6381
toStringTag(this, 'EmbeddedSignatureBlob');
6482
constant(this, 'typeMagic');

0 commit comments

Comments
 (0)