Skip to content

Commit

Permalink
fix: RSA fixes for suite
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jan 14, 2023
1 parent 3df79ab commit 834642a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class SphereonJsonWebSignature2020 extends SphereonLdSignature {
getSuiteForVerification(): any {
const verifier = {
// returns a JWS detached
verify: async (args: { data: Uint8Array }): Promise<boolean> => {
verify: async (args: { data: Uint8Array; signature: Uint8Array }): Promise<boolean> => {
return true
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const applyJwa = async (k: any, options?: any) => {
const verifier = options?.verifier !== undefined ? options.verifier : await getVerifier(k, options)
k.verifier = () => verifier as any
if (k.privateKey || options?.signer !== undefined) {
const signer = options?.signer ? options.signer : await getSigner(k, options)
const signer = options?.signer !== undefined ? options.signer : await getSigner(k, options)
k.signer = () => signer as any
}
return k
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export class JsonWebSignature {
}

async verifySignature({ verifyData, verificationMethod, proof }: any) {
if (verificationMethod.publicKeyJwk) {
const key = verificationMethod.publicKeyJwk as CryptoKey
return await crypto.subtle.verify(key.algorithm?.name ? key.algorithm.name : 'SHA-256', key, new Uint8Array(proof.jws), verifyData)
}
const verifier = await verificationMethod.verifier()
return verifier.verify({ data: verifyData, signature: proof.jws })
}
Expand Down

0 comments on commit 834642a

Please sign in to comment.