CI/CD / preconditions (pull_request) Successful in 2s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m0s
CI/CD / test_and_check_app (pull_request) Successful in 7m2s
CI/CD / Publish immutable image (pull_request) Skipped
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m35s
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
import { Buffer } from 'node:buffer';
|
|
import { createHash, generateKeyPairSync, sign } from 'node:crypto';
|
|
|
|
export function signedFixture(bytes) {
|
|
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
|
|
const keyId = Buffer.alloc(8, 7);
|
|
const key = Buffer.concat([
|
|
Buffer.from('Ed'),
|
|
keyId,
|
|
publicKey.export({ type: 'spki', format: 'der' }).subarray(-32),
|
|
]);
|
|
const signature = sign(
|
|
null,
|
|
createHash('blake2b512').update(bytes).digest(),
|
|
privateKey,
|
|
);
|
|
const trusted = 'timestamp:123456';
|
|
const globalSignature = sign(
|
|
null,
|
|
Buffer.concat([signature, Buffer.from(trusted)]),
|
|
privateKey,
|
|
);
|
|
return {
|
|
publicKey: Buffer.from(
|
|
`untrusted comment: test\n${key.toString('base64')}\n`,
|
|
).toString('base64'),
|
|
signature: Buffer.from(
|
|
`untrusted comment: test\n${Buffer.concat([Buffer.from('ED'), keyId, signature]).toString('base64')}\ntrusted comment: ${trusted}\n${globalSignature.toString('base64')}\n`,
|
|
).toString('base64'),
|
|
};
|
|
}
|