Skip to content

Commit

Permalink
Remove Digest Completely
Browse files Browse the repository at this point in the history
  • Loading branch information
Akamig committed Oct 30, 2023
1 parent e0d5c13 commit 86cdf8f
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions @planetarium/account-aws-kms/src/AwsKmsAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,17 @@ export class AwsKmsAccount implements Account {
return Promise.resolve(this.publicKey);
}

async sign(message: Message, isDigest: boolean = false): Promise<Signature> {
let finalMessage = message;

if (isDigest) {
const digest = await crypto.subtle.digest(
"SHA-256",
crypto.encode(message)
);
const digestArray = new Uint8Array(digest);
finalMessage = digestArray;
}
async sign(message: Message): Promise<Signature> {
const digest = await crypto.subtle.digest(
"SHA-256",
crypto.encode(message)
);
const digestArray = new Uint8Array(digest);

const cmd = new SignCommand({
KeyId: this.keyId,
Message: finalMessage,
MessageType: isDigest ? "DIGEST" : "RAW",
Message: digestArray,
MessageType: "DIGEST",
SigningAlgorithm: "ECDSA_SHA_256",
});
const response = await this.#client.send(cmd);
Expand Down

0 comments on commit 86cdf8f

Please sign in to comment.