Skip to content

Commit

Permalink
Update hsm-service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Nov 11, 2024
1 parent 7c055f7 commit a147414
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/src/ee/services/hsm/hsm-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const hsmServiceFactory = ({ hsmModule: { isInitialized, pkcs11 } }: THsm
pkcs11.C_VerifyFinal(sessionHandle, hmac);
} catch (error) {
logger.error(error, "HSM: HMAC verification failed");
throw new Error("Decryption failed"); // Generic error for failed verification
throw new Error("HSM: Decryption failed"); // Generic error for failed verification
}

// Only decrypt if verification passed
Expand All @@ -318,8 +318,8 @@ export const hsmServiceFactory = ({ hsmModule: { isInitialized, pkcs11 } }: THsm
// Create a new buffer from the decrypted data
return Buffer.from(decryptedData);
} catch (error) {
logger.error("Decryption error:", error);
throw new Error(`Decryption failed: ${(error as Error)?.message}`);
logger.error(error, "HSM: Failed to perform decryption");
throw new Error("HSM: Decryption failed"); // Generic error for failed decryption, to avoid leaking details about why it failed (such as padding related errors)
}
};

Expand Down

0 comments on commit a147414

Please sign in to comment.