Loading packages/fedify/src/runtime/key.ts +9 −4 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ export async function importSpki(pem: string): Promise<CryptoKey> { } catch (_) { throw new TypeError("Invalid PEM-SPKI format."); } const pki = PublicKeyInfo.fromBER(spki); const spkiArrayBuffer = spki.slice().buffer; const pki = PublicKeyInfo.fromBER(spkiArrayBuffer); const oid = pki.algorithm.algorithmId; const algorithm = algorithms[oid]; if (algorithm == null) { Loading @@ -41,7 +42,7 @@ export async function importSpki(pem: string): Promise<CryptoKey> { } return await crypto.subtle.importKey( "spki", spki, spkiArrayBuffer, algorithm, true, ["verify"], Loading Loading @@ -110,7 +111,11 @@ export async function importMultibaseKey(key: string): Promise<CryptoKey> { format: "der", type: "pkcs1", }); const spki = keyObject.export({ type: "spki", format: "der" }).buffer; const exported = keyObject.export({ type: "spki", format: "der" }); const spki = exported instanceof Uint8Array ? exported : new Uint8Array(exported); return await crypto.subtle.importKey( "spki", new Uint8Array(spki), Loading @@ -121,7 +126,7 @@ export async function importMultibaseKey(key: string): Promise<CryptoKey> { } else if (code === 0xed) { // ed25519-pub return await crypto.subtle.importKey( "raw", content, content.slice(), "Ed25519", true, ["verify"], Loading packages/fedify/src/sig/http.test.ts +1 −1 Original line number Diff line number Diff line Loading @@ -671,7 +671,7 @@ test("verifyRequest() [rfc9421] manual POST verification", async () => { const signatureVerified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", rsaPublicKey2.publicKey, parsedSignature.sig1, parsedSignature.sig1.slice(), new TextEncoder().encode(signatureBase), ); Loading packages/fedify/src/sig/http.ts +1 −1 Original line number Diff line number Diff line Loading @@ -1196,7 +1196,7 @@ async function verifyRequestRfc9421( const verified = await crypto.subtle.verify( algorithm, key.publicKey, sigBytes, sigBytes.slice(), signatureBaseBytes, ); Loading packages/fedify/src/sig/ld.ts +2 −2 Original line number Diff line number Diff line Loading @@ -313,7 +313,7 @@ export async function verifySignature( const verified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", key.publicKey, signature, signature.slice(), messageBytes, ); if (verified) return key; Loading @@ -339,7 +339,7 @@ export async function verifySignature( const verified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", key.publicKey, signature, signature.slice(), messageBytes, ); return verified ? key : null; Loading packages/fedify/src/sig/proof.ts +1 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ async function verifyProofInternal( const verified = await crypto.subtle.verify( "Ed25519", publicKey.publicKey, proof.proofValue, proof.proofValue.slice(), digest, ); if (!verified) { Loading Loading
packages/fedify/src/runtime/key.ts +9 −4 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ export async function importSpki(pem: string): Promise<CryptoKey> { } catch (_) { throw new TypeError("Invalid PEM-SPKI format."); } const pki = PublicKeyInfo.fromBER(spki); const spkiArrayBuffer = spki.slice().buffer; const pki = PublicKeyInfo.fromBER(spkiArrayBuffer); const oid = pki.algorithm.algorithmId; const algorithm = algorithms[oid]; if (algorithm == null) { Loading @@ -41,7 +42,7 @@ export async function importSpki(pem: string): Promise<CryptoKey> { } return await crypto.subtle.importKey( "spki", spki, spkiArrayBuffer, algorithm, true, ["verify"], Loading Loading @@ -110,7 +111,11 @@ export async function importMultibaseKey(key: string): Promise<CryptoKey> { format: "der", type: "pkcs1", }); const spki = keyObject.export({ type: "spki", format: "der" }).buffer; const exported = keyObject.export({ type: "spki", format: "der" }); const spki = exported instanceof Uint8Array ? exported : new Uint8Array(exported); return await crypto.subtle.importKey( "spki", new Uint8Array(spki), Loading @@ -121,7 +126,7 @@ export async function importMultibaseKey(key: string): Promise<CryptoKey> { } else if (code === 0xed) { // ed25519-pub return await crypto.subtle.importKey( "raw", content, content.slice(), "Ed25519", true, ["verify"], Loading
packages/fedify/src/sig/http.test.ts +1 −1 Original line number Diff line number Diff line Loading @@ -671,7 +671,7 @@ test("verifyRequest() [rfc9421] manual POST verification", async () => { const signatureVerified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", rsaPublicKey2.publicKey, parsedSignature.sig1, parsedSignature.sig1.slice(), new TextEncoder().encode(signatureBase), ); Loading
packages/fedify/src/sig/http.ts +1 −1 Original line number Diff line number Diff line Loading @@ -1196,7 +1196,7 @@ async function verifyRequestRfc9421( const verified = await crypto.subtle.verify( algorithm, key.publicKey, sigBytes, sigBytes.slice(), signatureBaseBytes, ); Loading
packages/fedify/src/sig/ld.ts +2 −2 Original line number Diff line number Diff line Loading @@ -313,7 +313,7 @@ export async function verifySignature( const verified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", key.publicKey, signature, signature.slice(), messageBytes, ); if (verified) return key; Loading @@ -339,7 +339,7 @@ export async function verifySignature( const verified = await crypto.subtle.verify( "RSASSA-PKCS1-v1_5", key.publicKey, signature, signature.slice(), messageBytes, ); return verified ? key : null; Loading
packages/fedify/src/sig/proof.ts +1 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ async function verifyProofInternal( const verified = await crypto.subtle.verify( "Ed25519", publicKey.publicKey, proof.proofValue, proof.proofValue.slice(), digest, ); if (!verified) { Loading